diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/gpu/drm/drm_context.c | 73 | ||||
| -rw-r--r-- | drivers/gpu/drm/drm_fops.c | 21 | ||||
| -rw-r--r-- | drivers/gpu/drm/drm_stub.c | 10 |
3 files changed, 36 insertions, 68 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 | */ |
| 55 | static void drm_ctxbitmap_free(struct drm_device * dev, int ctx_handle) | 59 | void 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 | |||
| 69 | void 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 | */ |
| 124 | void drm_legacy_ctxbitmap_init(struct drm_device * dev) | 93 | int 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 | */ |
| 140 | void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev) | 107 | void 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) |
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 4be8e09a32ef..3f84277d7036 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c | |||
| @@ -439,7 +439,26 @@ int drm_release(struct inode *inode, struct file *filp) | |||
| 439 | if (dev->driver->driver_features & DRIVER_GEM) | 439 | if (dev->driver->driver_features & DRIVER_GEM) |
| 440 | drm_gem_release(dev, file_priv); | 440 | drm_gem_release(dev, file_priv); |
| 441 | 441 | ||
| 442 | drm_legacy_ctxbitmap_release(dev, file_priv); | 442 | mutex_lock(&dev->ctxlist_mutex); |
| 443 | if (!list_empty(&dev->ctxlist)) { | ||
| 444 | struct drm_ctx_list *pos, *n; | ||
| 445 | |||
| 446 | list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { | ||
| 447 | if (pos->tag == file_priv && | ||
| 448 | pos->handle != DRM_KERNEL_CONTEXT) { | ||
| 449 | if (dev->driver->context_dtor) | ||
| 450 | dev->driver->context_dtor(dev, | ||
| 451 | pos->handle); | ||
| 452 | |||
| 453 | drm_ctxbitmap_free(dev, pos->handle); | ||
| 454 | |||
| 455 | list_del(&pos->head); | ||
| 456 | kfree(pos); | ||
| 457 | --dev->ctx_count; | ||
| 458 | } | ||
| 459 | } | ||
| 460 | } | ||
| 461 | mutex_unlock(&dev->ctxlist_mutex); | ||
| 443 | 462 | ||
| 444 | mutex_lock(&dev->struct_mutex); | 463 | mutex_lock(&dev->struct_mutex); |
| 445 | 464 | ||
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index e7eb0276f7f1..39d864576be4 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
| @@ -292,7 +292,13 @@ int drm_fill_in_dev(struct drm_device *dev, | |||
| 292 | goto error_out_unreg; | 292 | goto error_out_unreg; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | drm_legacy_ctxbitmap_init(dev); | 295 | |
| 296 | |||
| 297 | retcode = drm_ctxbitmap_init(dev); | ||
| 298 | if (retcode) { | ||
| 299 | DRM_ERROR("Cannot allocate memory for context bitmap.\n"); | ||
| 300 | goto error_out_unreg; | ||
| 301 | } | ||
| 296 | 302 | ||
| 297 | if (driver->driver_features & DRIVER_GEM) { | 303 | if (driver->driver_features & DRIVER_GEM) { |
| 298 | retcode = drm_gem_init(dev); | 304 | retcode = drm_gem_init(dev); |
| @@ -446,7 +452,7 @@ void drm_put_dev(struct drm_device *dev) | |||
| 446 | drm_rmmap(dev, r_list->map); | 452 | drm_rmmap(dev, r_list->map); |
| 447 | drm_ht_remove(&dev->map_hash); | 453 | drm_ht_remove(&dev->map_hash); |
| 448 | 454 | ||
| 449 | drm_legacy_ctxbitmap_cleanup(dev); | 455 | drm_ctxbitmap_cleanup(dev); |
| 450 | 456 | ||
| 451 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | 457 | if (drm_core_check_feature(dev, DRIVER_MODESET)) |
| 452 | drm_put_minor(&dev->control); | 458 | drm_put_minor(&dev->control); |
