xserver only actually uses a small part of it nowadays.
Kill a few other dead bits from the drmP.h while i'm here.
#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) || \
#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;
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 *);
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 */
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 */
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);
/* 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 *);
DRM_LOCK();
clear_bit(ctx_handle, dev->ctx_bitmap);
- dev->context_sareas[ctx_handle] = NULL;
DRM_UNLOCK();
return;
}
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;
}
DRM_UNLOCK();
return ENOMEM;
}
- dev->context_sareas = NULL;
dev->max_context = -1;
DRM_UNLOCK();
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)
{
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)
{
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)
{
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),
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;
}
dev->irq_enabled = 1;
- dev->context_flag = 0;
-
mtx_init(&dev->irq_lock, IPL_BIO);
/* Before installing handler */