Lines Matching refs:dev

60 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)  in drm_legacy_ctxbitmap_free()  argument
62 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_ctxbitmap_free()
65 mutex_lock(&dev->struct_mutex); in drm_legacy_ctxbitmap_free()
66 idr_remove(&dev->ctx_idr, ctx_handle); in drm_legacy_ctxbitmap_free()
67 mutex_unlock(&dev->struct_mutex); in drm_legacy_ctxbitmap_free()
79 static int drm_legacy_ctxbitmap_next(struct drm_device * dev) in drm_legacy_ctxbitmap_next() argument
83 mutex_lock(&dev->struct_mutex); in drm_legacy_ctxbitmap_next()
84 ret = idr_alloc(&dev->ctx_idr, NULL, DRM_RESERVED_CONTEXTS, 0, in drm_legacy_ctxbitmap_next()
86 mutex_unlock(&dev->struct_mutex); in drm_legacy_ctxbitmap_next()
97 void drm_legacy_ctxbitmap_init(struct drm_device * dev) in drm_legacy_ctxbitmap_init() argument
99 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_ctxbitmap_init()
102 idr_init(&dev->ctx_idr); in drm_legacy_ctxbitmap_init()
113 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev) in drm_legacy_ctxbitmap_cleanup() argument
115 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_ctxbitmap_cleanup()
118 mutex_lock(&dev->struct_mutex); in drm_legacy_ctxbitmap_cleanup()
119 idr_destroy(&dev->ctx_idr); in drm_legacy_ctxbitmap_cleanup()
120 mutex_unlock(&dev->struct_mutex); in drm_legacy_ctxbitmap_cleanup()
132 void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) in drm_legacy_ctxbitmap_flush() argument
136 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_ctxbitmap_flush()
139 mutex_lock(&dev->ctxlist_mutex); in drm_legacy_ctxbitmap_flush()
141 list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) { in drm_legacy_ctxbitmap_flush()
144 if (dev->driver->context_dtor) in drm_legacy_ctxbitmap_flush()
145 dev->driver->context_dtor(dev, pos->handle); in drm_legacy_ctxbitmap_flush()
147 drm_legacy_ctxbitmap_free(dev, pos->handle); in drm_legacy_ctxbitmap_flush()
153 mutex_unlock(&dev->ctxlist_mutex); in drm_legacy_ctxbitmap_flush()
174 int drm_legacy_getsareactx(struct drm_device *dev, void *data, in drm_legacy_getsareactx() argument
181 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_getsareactx()
184 mutex_lock(&dev->struct_mutex); in drm_legacy_getsareactx()
186 map = idr_find(&dev->ctx_idr, request->ctx_id); in drm_legacy_getsareactx()
188 mutex_unlock(&dev->struct_mutex); in drm_legacy_getsareactx()
193 list_for_each_entry(_entry, &dev->maplist, head) { in drm_legacy_getsareactx()
201 mutex_unlock(&dev->struct_mutex); in drm_legacy_getsareactx()
221 int drm_legacy_setsareactx(struct drm_device *dev, void *data, in drm_legacy_setsareactx() argument
228 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_setsareactx()
231 mutex_lock(&dev->struct_mutex); in drm_legacy_setsareactx()
232 list_for_each_entry(r_list, &dev->maplist, head) { in drm_legacy_setsareactx()
238 mutex_unlock(&dev->struct_mutex); in drm_legacy_setsareactx()
246 if (IS_ERR(idr_replace(&dev->ctx_idr, map, request->ctx_id))) in drm_legacy_setsareactx()
249 mutex_unlock(&dev->struct_mutex); in drm_legacy_setsareactx()
270 static int drm_context_switch(struct drm_device * dev, int old, int new) in drm_context_switch() argument
272 if (test_and_set_bit(0, &dev->context_flag)) { in drm_context_switch()
279 if (new == dev->last_context) { in drm_context_switch()
280 clear_bit(0, &dev->context_flag); in drm_context_switch()
298 static int drm_context_switch_complete(struct drm_device *dev, in drm_context_switch_complete() argument
301 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ in drm_context_switch_complete()
311 clear_bit(0, &dev->context_flag); in drm_context_switch_complete()
325 int drm_legacy_resctx(struct drm_device *dev, void *data, in drm_legacy_resctx() argument
332 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_resctx()
359 int drm_legacy_addctx(struct drm_device *dev, void *data, in drm_legacy_addctx() argument
366 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_addctx()
369 tmp_handle = drm_legacy_ctxbitmap_next(dev); in drm_legacy_addctx()
372 tmp_handle = drm_legacy_ctxbitmap_next(dev); in drm_legacy_addctx()
393 mutex_lock(&dev->ctxlist_mutex); in drm_legacy_addctx()
394 list_add(&ctx_entry->head, &dev->ctxlist); in drm_legacy_addctx()
395 mutex_unlock(&dev->ctxlist_mutex); in drm_legacy_addctx()
409 int drm_legacy_getctx(struct drm_device *dev, void *data, in drm_legacy_getctx() argument
414 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_getctx()
434 int drm_legacy_switchctx(struct drm_device *dev, void *data, in drm_legacy_switchctx() argument
439 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_switchctx()
443 return drm_context_switch(dev, dev->last_context, ctx->handle); in drm_legacy_switchctx()
457 int drm_legacy_newctx(struct drm_device *dev, void *data, in drm_legacy_newctx() argument
462 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_newctx()
466 drm_context_switch_complete(dev, file_priv, ctx->handle); in drm_legacy_newctx()
482 int drm_legacy_rmctx(struct drm_device *dev, void *data, in drm_legacy_rmctx() argument
487 if (!drm_core_check_feature(dev, DRIVER_LEGACY)) in drm_legacy_rmctx()
492 if (dev->driver->context_dtor) in drm_legacy_rmctx()
493 dev->driver->context_dtor(dev, ctx->handle); in drm_legacy_rmctx()
494 drm_legacy_ctxbitmap_free(dev, ctx->handle); in drm_legacy_rmctx()
497 mutex_lock(&dev->ctxlist_mutex); in drm_legacy_rmctx()
498 if (!list_empty(&dev->ctxlist)) { in drm_legacy_rmctx()
501 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { in drm_legacy_rmctx()
508 mutex_unlock(&dev->ctxlist_mutex); in drm_legacy_rmctx()