aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_context.c')
-rw-r--r--drivers/gpu/drm/drm_context.c73
1 files changed, 8 insertions, 65 deletions
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index b4fb86d89850..224ff965bcf7 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -42,6 +42,10 @@
42 42
43#include <drm/drmP.h> 43#include <drm/drmP.h>
44 44
45/******************************************************************/
46/** \name Context bitmap support */
47/*@{*/
48
45/** 49/**
46 * Free a handle from the context bitmap. 50 * Free a handle from the context bitmap.
47 * 51 *
@@ -52,48 +56,13 @@
52 * in drm_device::ctx_idr, while holding the drm_device::struct_mutex 56 * in drm_device::ctx_idr, while holding the drm_device::struct_mutex
53 * lock. 57 * lock.
54 */ 58 */
55static void drm_ctxbitmap_free(struct drm_device * dev, int ctx_handle) 59void drm_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
56{ 60{
57 if (drm_core_check_feature(dev, DRIVER_MODESET))
58 return;
59
60 mutex_lock(&dev->struct_mutex); 61 mutex_lock(&dev->struct_mutex);
61 idr_remove(&dev->ctx_idr, ctx_handle); 62 idr_remove(&dev->ctx_idr, ctx_handle);
62 mutex_unlock(&dev->struct_mutex); 63 mutex_unlock(&dev->struct_mutex);
63} 64}
64 65
65/******************************************************************/
66/** \name Context bitmap support */
67/*@{*/
68
69void drm_legacy_ctxbitmap_release(struct drm_device *dev,
70 struct drm_file *file_priv)
71{
72 if (drm_core_check_feature(dev, DRIVER_MODESET))
73 return;
74
75 mutex_lock(&dev->ctxlist_mutex);
76 if (!list_empty(&dev->ctxlist)) {
77 struct drm_ctx_list *pos, *n;
78
79 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
80 if (pos->tag == file_priv &&
81 pos->handle != DRM_KERNEL_CONTEXT) {
82 if (dev->driver->context_dtor)
83 dev->driver->context_dtor(dev,
84 pos->handle);
85
86 drm_ctxbitmap_free(dev, pos->handle);
87
88 list_del(&pos->head);
89 kfree(pos);
90 --dev->ctx_count;
91 }
92 }
93 }
94 mutex_unlock(&dev->ctxlist_mutex);
95}
96
97/** 66/**
98 * Context bitmap allocation. 67 * Context bitmap allocation.
99 * 68 *
@@ -121,12 +90,10 @@ static int drm_ctxbitmap_next(struct drm_device * dev)
121 * 90 *
122 * Initialise the drm_device::ctx_idr 91 * Initialise the drm_device::ctx_idr
123 */ 92 */
124void drm_legacy_ctxbitmap_init(struct drm_device * dev) 93int drm_ctxbitmap_init(struct drm_device * dev)
125{ 94{
126 if (drm_core_check_feature(dev, DRIVER_MODESET))
127 return;
128
129 idr_init(&dev->ctx_idr); 95 idr_init(&dev->ctx_idr);
96 return 0;
130} 97}
131 98
132/** 99/**
@@ -137,7 +104,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
137 * Free all idr members using drm_ctx_sarea_free helper function 104 * Free all idr members using drm_ctx_sarea_free helper function
138 * while holding the drm_device::struct_mutex lock. 105 * while holding the drm_device::struct_mutex lock.
139 */ 106 */
140void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev) 107void drm_ctxbitmap_cleanup(struct drm_device * dev)
141{ 108{
142 mutex_lock(&dev->struct_mutex); 109 mutex_lock(&dev->struct_mutex);
143 idr_destroy(&dev->ctx_idr); 110 idr_destroy(&dev->ctx_idr);
@@ -169,9 +136,6 @@ int drm_getsareactx(struct drm_device *dev, void *data,
169 struct drm_local_map *map; 136 struct drm_local_map *map;
170 struct drm_map_list *_entry; 137 struct drm_map_list *_entry;
171 138
172 if (drm_core_check_feature(dev, DRIVER_MODESET))
173 return -EINVAL;
174
175 mutex_lock(&dev->struct_mutex); 139 mutex_lock(&dev->struct_mutex);
176 140
177 map = idr_find(&dev->ctx_idr, request->ctx_id); 141 map = idr_find(&dev->ctx_idr, request->ctx_id);
@@ -216,9 +180,6 @@ int drm_setsareactx(struct drm_device *dev, void *data,
216 struct drm_local_map *map = NULL; 180 struct drm_local_map *map = NULL;
217 struct drm_map_list *r_list = NULL; 181 struct drm_map_list *r_list = NULL;
218 182
219 if (drm_core_check_feature(dev, DRIVER_MODESET))
220 return -EINVAL;
221
222 mutex_lock(&dev->struct_mutex); 183 mutex_lock(&dev->struct_mutex);
223 list_for_each_entry(r_list, &dev->maplist, head) { 184 list_for_each_entry(r_list, &dev->maplist, head) {
224 if (r_list->map 185 if (r_list->map
@@ -319,9 +280,6 @@ int drm_resctx(struct drm_device *dev, void *data,
319 struct drm_ctx ctx; 280 struct drm_ctx ctx;
320 int i; 281 int i;
321 282
322 if (drm_core_check_feature(dev, DRIVER_MODESET))
323 return -EINVAL;
324
325 if (res->count >= DRM_RESERVED_CONTEXTS) { 283 if (res->count >= DRM_RESERVED_CONTEXTS) {
326 memset(&ctx, 0, sizeof(ctx)); 284 memset(&ctx, 0, sizeof(ctx));
327 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { 285 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
@@ -352,9 +310,6 @@ int drm_addctx(struct drm_device *dev, void *data,
352 struct drm_ctx_list *ctx_entry; 310 struct drm_ctx_list *ctx_entry;
353 struct drm_ctx *ctx = data; 311 struct drm_ctx *ctx = data;
354 312
355 if (drm_core_check_feature(dev, DRIVER_MODESET))
356 return -EINVAL;
357
358 ctx->handle = drm_ctxbitmap_next(dev); 313 ctx->handle = drm_ctxbitmap_next(dev);
359 if (ctx->handle == DRM_KERNEL_CONTEXT) { 314 if (ctx->handle == DRM_KERNEL_CONTEXT) {
360 /* Skip kernel's context and get a new one. */ 315 /* Skip kernel's context and get a new one. */
@@ -398,9 +353,6 @@ int drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
398{ 353{
399 struct drm_ctx *ctx = data; 354 struct drm_ctx *ctx = data;
400 355
401 if (drm_core_check_feature(dev, DRIVER_MODESET))
402 return -EINVAL;
403
404 /* This is 0, because we don't handle any context flags */ 356 /* This is 0, because we don't handle any context flags */
405 ctx->flags = 0; 357 ctx->flags = 0;
406 358
@@ -423,9 +375,6 @@ int drm_switchctx(struct drm_device *dev, void *data,
423{ 375{
424 struct drm_ctx *ctx = data; 376 struct drm_ctx *ctx = data;
425 377
426 if (drm_core_check_feature(dev, DRIVER_MODESET))
427 return -EINVAL;
428
429 DRM_DEBUG("%d\n", ctx->handle); 378 DRM_DEBUG("%d\n", ctx->handle);
430 return drm_context_switch(dev, dev->last_context, ctx->handle); 379 return drm_context_switch(dev, dev->last_context, ctx->handle);
431} 380}
@@ -446,9 +395,6 @@ int drm_newctx(struct drm_device *dev, void *data,
446{ 395{
447 struct drm_ctx *ctx = data; 396 struct drm_ctx *ctx = data;
448 397
449 if (drm_core_check_feature(dev, DRIVER_MODESET))
450 return -EINVAL;
451
452 DRM_DEBUG("%d\n", ctx->handle); 398 DRM_DEBUG("%d\n", ctx->handle);
453 drm_context_switch_complete(dev, file_priv, ctx->handle); 399 drm_context_switch_complete(dev, file_priv, ctx->handle);
454 400
@@ -471,9 +417,6 @@ int drm_rmctx(struct drm_device *dev, void *data,
471{ 417{
472 struct drm_ctx *ctx = data; 418 struct drm_ctx *ctx = data;
473 419
474 if (drm_core_check_feature(dev, DRIVER_MODESET))
475 return -EINVAL;
476
477 DRM_DEBUG("%d\n", ctx->handle); 420 DRM_DEBUG("%d\n", ctx->handle);
478 if (ctx->handle != DRM_KERNEL_CONTEXT) { 421 if (ctx->handle != DRM_KERNEL_CONTEXT) {
479 if (dev->driver->context_dtor) 422 if (dev->driver->context_dtor)