Lines Matching refs:dev
64 drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle)
67 dev->ctx_bitmap == NULL) {
75 clear_bit(ctx_handle, dev->ctx_bitmap);
76 dev->context_sareas[ctx_handle] = NULL;
82 drm_ctxbitmap_next(drm_device_t *dev)
86 if (dev->ctx_bitmap == NULL)
90 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
96 set_bit(bit, dev->ctx_bitmap);
98 if ((bit+1) > dev->max_context) {
99 dev->max_context = (bit+1);
100 if (dev->context_sareas != NULL) {
102 ctx_sareas = drm_realloc(dev->context_sareas,
103 (dev->max_context - 1) *
104 sizeof (*dev->context_sareas),
105 dev->max_context *
106 sizeof (*dev->context_sareas),
109 clear_bit(bit, dev->ctx_bitmap);
113 dev->context_sareas = ctx_sareas;
114 dev->context_sareas[bit] = NULL;
117 dev->context_sareas = drm_alloc(dev->max_context *
118 sizeof (*dev->context_sareas), KM_NOSLEEP);
119 if (dev->context_sareas == NULL) {
120 clear_bit(bit, dev->ctx_bitmap);
124 dev->context_sareas[bit] = NULL;
133 drm_ctxbitmap_init(drm_device_t *dev)
139 dev->ctx_bitmap = drm_calloc(1, DRM_PAGE_SIZE, DRM_MEM_CTXBITMAP);
140 if (dev->ctx_bitmap == NULL) {
144 dev->context_sareas = NULL;
145 dev->max_context = -1;
149 temp = drm_ctxbitmap_next(dev);
156 drm_ctxbitmap_cleanup(drm_device_t *dev)
159 if (dev->context_sareas != NULL)
160 drm_free(dev->context_sareas,
161 sizeof (*dev->context_sareas) *
162 dev->max_context,
164 drm_free(dev->ctx_bitmap, DRM_PAGE_SIZE, DRM_MEM_CTXBITMAP);
192 if (dev->max_context < 0 || request.ctx_id >= (unsigned)
193 dev->max_context) {
198 map = dev->context_sareas[request.ctx_id];
243 TAILQ_FOREACH(map, &dev->maplist, link) {
245 if (dev->max_context < 0)
247 if (request.ctx_id >= (unsigned)dev->max_context)
249 dev->context_sareas[request.ctx_id] = map;
264 drm_context_switch(drm_device_t *dev, int old, int new)
266 if (test_and_set_bit(0, &dev->context_flag)) {
274 if (new == dev->last_context) {
275 clear_bit(0, &dev->context_flag);
283 drm_context_switch_complete(drm_device_t *dev, int new)
285 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
287 if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
296 clear_bit(0, &dev->context_flag);
353 ctx.handle = drm_ctxbitmap_next(dev);
356 ctx.handle = drm_ctxbitmap_next(dev);
362 if (dev->driver->context_ctor && ctx.handle != DRM_KERNEL_CONTEXT) {
363 dev->driver->context_ctor(dev, ctx.handle);
405 return (drm_context_switch(dev, dev->last_context, ctx.handle));
418 (void) drm_context_switch_complete(dev, ctx.handle);
434 if (dev->driver->context_dtor) {
436 dev->driver->context_dtor(dev, ctx.handle);
440 drm_ctxbitmap_free(dev, ctx.handle);