From a6fe3ca567fc25de9273c7bb92bdc57c2cb67b9f Mon Sep 17 00:00:00 2001 From: oga Date: Wed, 13 Aug 2008 19:30:11 +0000 Subject: [PATCH] Kill a bunch of the drm context code that nothing uses anymore, the xserver only actually uses a small part of it nowadays. Kill a few other dead bits from the drmP.h while i'm here. --- sys/dev/pci/drm/drmP.h | 25 +----- sys/dev/pci/drm/drm_context.c | 148 +--------------------------------- sys/dev/pci/drm/drm_drv.c | 12 ++- sys/dev/pci/drm/drm_irq.c | 2 - 4 files changed, 7 insertions(+), 180 deletions(-) diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index 77ccf7912fc..66766471048 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -258,10 +258,6 @@ typedef u_int8_t u8; #define DRM_UDELAY(udelay) DELAY(udelay) #define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */ -#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \ - (_map) = (_dev)->context_sareas[_ctx]; \ -} while(0) - #define LOCK_TEST_WITH_RETURN(dev, file_priv) \ do { \ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \ @@ -524,7 +520,7 @@ typedef struct drm_vbl_sig { #define DRM_ATI_GART_IGP 3 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) -1) -#define upper_32_bits(_val) (((u64)(_val)) >> 32) +#define upper_32_bits(_val) ((u_int32_t)(((_val) >> 16) >> 16)) struct drm_ati_pcigart_info { int gart_table_location; @@ -547,16 +543,9 @@ struct drm_driver_info { void (*reclaim_buffers_locked)(struct drm_device *, struct drm_file *); int (*dma_ioctl)(struct drm_device *, void *, struct drm_file *); - void (*dma_ready)(struct drm_device *); int (*dma_quiescent)(struct drm_device *); - int (*dma_flush_block_and_flush)(struct drm_device *, int, - drm_lock_flags_t); - int (*dma_flush_unblock)(struct drm_device *, int, - drm_lock_flags_t); int (*context_ctor)(struct drm_device *, int); int (*context_dtor)(struct drm_device *, int); - int (*kernel_context_switch)(struct drm_device *, int, int); - int (*kernel_context_switch_unlock)(struct drm_device *); void (*irq_preinstall)(struct drm_device *); int (*irq_postinstall)(struct drm_device *); void (*irq_uninstall)(struct drm_device *); @@ -651,7 +640,6 @@ struct drm_device { struct drm_memrange handle_mm; drm_map_list_t maplist; - drm_local_map_t **context_sareas; int max_context; drm_lock_data_t lock; /* Information on hardware lock */ @@ -674,9 +662,6 @@ struct drm_device { int pci_slot; int pci_func; - atomic_t context_flag; /* Context swapping flag */ - int last_context; /* Last current context */ - /* VBLANK support */ int vblank_disable_allowed; int *vbl_queue; /* vbl wait channel */ @@ -744,9 +729,6 @@ void drm_ioremapfree(drm_local_map_t *); int drm_mtrr_add(unsigned long, size_t, int); int drm_mtrr_del(int, unsigned long, size_t, int); -int drm_context_switch(struct drm_device *, int, int); -int drm_context_switch_complete(struct drm_device *, int); - int drm_ctxbitmap_init(struct drm_device *); void drm_ctxbitmap_cleanup(struct drm_device *); void drm_ctxbitmap_free(struct drm_device *, int); @@ -846,13 +828,8 @@ int drm_noop(struct drm_device *, void *, struct drm_file *); /* Context IOCTL support (drm_context.c) */ int drm_resctx(struct drm_device *, void *, struct drm_file *); int drm_addctx(struct drm_device *, void *, struct drm_file *); -int drm_modctx(struct drm_device *, void *, struct drm_file *); int drm_getctx(struct drm_device *, void *, struct drm_file *); -int drm_switchctx(struct drm_device *, void *, struct drm_file *); -int drm_newctx(struct drm_device *, void *, struct drm_file *); int drm_rmctx(struct drm_device *, void *, struct drm_file *); -int drm_setsareactx(struct drm_device *, void *, struct drm_file *); -int drm_getsareactx(struct drm_device *, void *, struct drm_file *); /* Drawable IOCTL support (drm_drawable.c) */ int drm_adddraw(struct drm_device *, void *, struct drm_file *); diff --git a/sys/dev/pci/drm/drm_context.c b/sys/dev/pci/drm/drm_context.c index fcf0d2552f6..144131818c0 100644 --- a/sys/dev/pci/drm/drm_context.c +++ b/sys/dev/pci/drm/drm_context.c @@ -50,7 +50,6 @@ drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle) DRM_LOCK(); clear_bit(ctx_handle, dev->ctx_bitmap); - dev->context_sareas[ctx_handle] = NULL; DRM_UNLOCK(); return; } @@ -72,34 +71,8 @@ drm_ctxbitmap_next(struct drm_device *dev) set_bit(bit, dev->ctx_bitmap); DRM_DEBUG("drm_ctxbitmap_next bit : %d\n", bit); - if ((bit+1) > dev->max_context) { - int old_context = dev->max_context; + if ((bit+1) > dev->max_context) dev->max_context = (bit+1); - if (dev->context_sareas != NULL) { - drm_local_map_t **ctx_sareas; - - ctx_sareas = drm_realloc(dev->context_sareas, - old_context * sizeof(*dev->context_sareas), - dev->max_context * sizeof(*dev->context_sareas), M_DRM); - if (ctx_sareas == NULL) { - clear_bit(bit, dev->ctx_bitmap); - DRM_UNLOCK(); - return -1; - } - dev->context_sareas = ctx_sareas; - dev->context_sareas[bit] = NULL; - } else { - /* max_context == 1 at this point */ - dev->context_sareas = drm_calloc(dev->max_context, - sizeof(*dev->context_sareas), DRM_MEM_CTXLIST); - if (dev->context_sareas == NULL) { - clear_bit(bit, dev->ctx_bitmap); - DRM_UNLOCK(); - return -1; - } - dev->context_sareas[bit] = NULL; - } - } DRM_UNLOCK(); return bit; } @@ -116,7 +89,6 @@ drm_ctxbitmap_init(struct drm_device *dev) DRM_UNLOCK(); return ENOMEM; } - dev->context_sareas = NULL; dev->max_context = -1; DRM_UNLOCK(); @@ -132,101 +104,10 @@ void drm_ctxbitmap_cleanup(struct drm_device *dev) { DRM_LOCK(); - drm_free(dev->context_sareas, - sizeof(dev->context_sareas) * dev->max_context, DRM_MEM_CTXLIST); drm_free(dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); DRM_UNLOCK(); } -/* ================================================================ - * Per Context SAREA Support - */ - -int -drm_getsareactx(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - drm_ctx_priv_map_t *request = data; - drm_local_map_t *map; - - DRM_LOCK(); - if (dev->max_context < 0 || - request->ctx_id >= (unsigned) dev->max_context) { - DRM_UNLOCK(); - return EINVAL; - } - - map = dev->context_sareas[request->ctx_id]; - DRM_UNLOCK(); - - request->handle = map->handle; - - return 0; -} - -int -drm_setsareactx(struct drm_device *dev, void *data, struct drm_file *file_priv) -{ - drm_ctx_priv_map_t *request = data; - drm_local_map_t *map = NULL; - - DRM_LOCK(); - TAILQ_FOREACH(map, &dev->maplist, link) { - if (map->handle == request->handle) { - if (dev->max_context < 0) - goto bad; - if (request->ctx_id >= (unsigned) dev->max_context) - goto bad; - dev->context_sareas[request->ctx_id] = map; - DRM_UNLOCK(); - return 0; - } - } - -bad: - DRM_UNLOCK(); - return EINVAL; -} - -/* ================================================================ - * The actual DRM context handling routines - */ - -int -drm_context_switch(struct drm_device *dev, int old, int new) -{ - if ( test_and_set_bit( 0, &dev->context_flag ) ) { - DRM_ERROR( "Reentering -- FIXME\n" ); - return EBUSY; - } - - DRM_DEBUG( "Context switch from %d to %d\n", old, new ); - - if ( new == dev->last_context ) { - clear_bit( 0, &dev->context_flag ); - return 0; - } - - return 0; -} - -int -drm_context_switch_complete(struct drm_device *dev, int new) -{ - dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ - - if ( !_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ) { - DRM_ERROR( "Lock isn't held after context switch\n" ); - } - - /* If a context switch is ever initiated - when the kernel holds the lock, release - that lock here. */ - clear_bit( 0, &dev->context_flag ); - - return 0; -} - int drm_resctx(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -274,13 +155,6 @@ drm_addctx(struct drm_device *dev, void *data, struct drm_file *file_priv) return 0; } -int -drm_modctx(struct drm_device *dev, void *data, struct drm_file *file_priv) -{ - /* This does nothing */ - return 0; -} - int drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -292,26 +166,6 @@ drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv) return 0; } -int -drm_switchctx(struct drm_device *dev, void *data, struct drm_file *file_priv) -{ - drm_ctx_t *ctx = data; - - DRM_DEBUG( "%d\n", ctx->handle ); - return drm_context_switch(dev, dev->last_context, ctx->handle); -} - -int -drm_newctx(struct drm_device *dev, void *data, struct drm_file *file_priv) -{ - drm_ctx_t *ctx = data; - - DRM_DEBUG( "%d\n", ctx->handle ); - drm_context_switch_complete(dev, ctx->handle); - - return 0; -} - int drm_rmctx(struct drm_device *dev, void *data, struct drm_file *file_priv) { diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index 994595b8123..88fc5316ed8 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -70,15 +70,15 @@ static drm_ioctl_desc_t drm_ioctls[256] = { DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_rmmap_ioctl, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH), + DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_noop, DRM_AUTH), DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH), DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), @@ -257,8 +257,6 @@ drm_firstopen(struct drm_device *dev) dev->lock.lock_queue = 0; dev->irq_enabled = 0; - dev->context_flag = 0; - dev->last_context = 0; dev->if_version = 0; dev->buf_pgid = 0; diff --git a/sys/dev/pci/drm/drm_irq.c b/sys/dev/pci/drm/drm_irq.c index 30ba65057d6..4777a5c9345 100644 --- a/sys/dev/pci/drm/drm_irq.c +++ b/sys/dev/pci/drm/drm_irq.c @@ -91,8 +91,6 @@ drm_irq_install(struct drm_device *dev) } dev->irq_enabled = 1; - dev->context_flag = 0; - mtx_init(&dev->irq_lock, IPL_BIO); /* Before installing handler */ -- 2.20.1