Lines Matching refs:dev
54 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle) in drm_legacy_ctxbitmap_free() argument
56 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_ctxbitmap_free()
57 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_ctxbitmap_free()
60 mutex_lock(&dev->struct_mutex); in drm_legacy_ctxbitmap_free()
61 idr_remove(&dev->ctx_idr, ctx_handle); in drm_legacy_ctxbitmap_free()
62 mutex_unlock(&dev->struct_mutex); in drm_legacy_ctxbitmap_free()
74 static int drm_legacy_ctxbitmap_next(struct drm_device * dev) in drm_legacy_ctxbitmap_next() argument
78 mutex_lock(&dev->struct_mutex); in drm_legacy_ctxbitmap_next()
79 ret = idr_alloc(&dev->ctx_idr, NULL, DRM_RESERVED_CONTEXTS, 0, in drm_legacy_ctxbitmap_next()
81 mutex_unlock(&dev->struct_mutex); in drm_legacy_ctxbitmap_next()
92 void drm_legacy_ctxbitmap_init(struct drm_device * dev) in drm_legacy_ctxbitmap_init() argument
94 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_ctxbitmap_init()
95 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_ctxbitmap_init()
98 idr_init(&dev->ctx_idr); in drm_legacy_ctxbitmap_init()
109 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev) in drm_legacy_ctxbitmap_cleanup() argument
111 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_ctxbitmap_cleanup()
112 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_ctxbitmap_cleanup()
115 mutex_lock(&dev->struct_mutex); in drm_legacy_ctxbitmap_cleanup()
116 idr_destroy(&dev->ctx_idr); in drm_legacy_ctxbitmap_cleanup()
117 mutex_unlock(&dev->struct_mutex); in drm_legacy_ctxbitmap_cleanup()
129 void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) in drm_legacy_ctxbitmap_flush() argument
133 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_ctxbitmap_flush()
134 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_ctxbitmap_flush()
137 mutex_lock(&dev->ctxlist_mutex); in drm_legacy_ctxbitmap_flush()
139 list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) { in drm_legacy_ctxbitmap_flush()
142 if (dev->driver->context_dtor) in drm_legacy_ctxbitmap_flush()
143 dev->driver->context_dtor(dev, pos->handle); in drm_legacy_ctxbitmap_flush()
145 drm_legacy_ctxbitmap_free(dev, pos->handle); in drm_legacy_ctxbitmap_flush()
151 mutex_unlock(&dev->ctxlist_mutex); in drm_legacy_ctxbitmap_flush()
172 int drm_legacy_getsareactx(struct drm_device *dev, void *data, in drm_legacy_getsareactx() argument
179 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_getsareactx()
180 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_getsareactx()
183 mutex_lock(&dev->struct_mutex); in drm_legacy_getsareactx()
185 map = idr_find(&dev->ctx_idr, request->ctx_id); in drm_legacy_getsareactx()
187 mutex_unlock(&dev->struct_mutex); in drm_legacy_getsareactx()
192 list_for_each_entry(_entry, &dev->maplist, head) { in drm_legacy_getsareactx()
200 mutex_unlock(&dev->struct_mutex); in drm_legacy_getsareactx()
220 int drm_legacy_setsareactx(struct drm_device *dev, void *data, in drm_legacy_setsareactx() argument
227 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_setsareactx()
228 drm_core_check_feature(dev, DRIVER_MODESET)) 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()
310 clear_bit(0, &dev->context_flag); in drm_context_switch_complete()
324 int drm_legacy_resctx(struct drm_device *dev, void *data, in drm_legacy_resctx() argument
331 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_resctx()
332 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_resctx()
359 int drm_legacy_addctx(struct drm_device *dev, void *data, in drm_legacy_addctx() argument
365 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_addctx()
366 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_addctx()
369 ctx->handle = drm_legacy_ctxbitmap_next(dev); in drm_legacy_addctx()
372 ctx->handle = drm_legacy_ctxbitmap_next(dev); in drm_legacy_addctx()
391 mutex_lock(&dev->ctxlist_mutex); in drm_legacy_addctx()
392 list_add(&ctx_entry->head, &dev->ctxlist); in drm_legacy_addctx()
393 mutex_unlock(&dev->ctxlist_mutex); in drm_legacy_addctx()
407 int drm_legacy_getctx(struct drm_device *dev, void *data, in drm_legacy_getctx() argument
412 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_getctx()
413 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_getctx()
433 int drm_legacy_switchctx(struct drm_device *dev, void *data, in drm_legacy_switchctx() argument
438 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_switchctx()
439 drm_core_check_feature(dev, DRIVER_MODESET)) 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_KMS_LEGACY_CONTEXT) && in drm_legacy_newctx()
463 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_newctx()
467 drm_context_switch_complete(dev, file_priv, ctx->handle); in drm_legacy_newctx()
483 int drm_legacy_rmctx(struct drm_device *dev, void *data, in drm_legacy_rmctx() argument
488 if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && in drm_legacy_rmctx()
489 drm_core_check_feature(dev, DRIVER_MODESET)) in drm_legacy_rmctx()
494 if (dev->driver->context_dtor) in drm_legacy_rmctx()
495 dev->driver->context_dtor(dev, ctx->handle); in drm_legacy_rmctx()
496 drm_legacy_ctxbitmap_free(dev, ctx->handle); in drm_legacy_rmctx()
499 mutex_lock(&dev->ctxlist_mutex); in drm_legacy_rmctx()
500 if (!list_empty(&dev->ctxlist)) { in drm_legacy_rmctx()
503 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { in drm_legacy_rmctx()
510 mutex_unlock(&dev->ctxlist_mutex); in drm_legacy_rmctx()