Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/nouveau: Remove support for legacy contexts/buffers

Remove nouveau's support for legacy contexts and buffers. It was
required by libdrm earlier than 2.4.33, released in March 2012. A
previous attempt in 2013 to remove the functionality [1] had to be
reverted [2] as there were still users left. Libdrm 2.4.33 is now
almost 11 years old and it is time for userspace to move on.

With the nouveau code gone, we can also remove the driver-feature
bit DRIVER_KMS_LEGACY_CONTEXT.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c510133d93dd6f15ca040733ba7b2891ed61fd1 # 1
Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c21eb21cb50d58e7cbdcb8b9e7ff68b85cfa5095 # 2
Link: https://patchwork.freedesktop.org/patch/msgid/20230112133858.17087-1-tzimmermann@suse.de

+19 -58
+4 -8
drivers/gpu/drm/drm_bufs.c
··· 423 423 if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM)) 424 424 return -EPERM; 425 425 426 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 427 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 426 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 428 427 return -EOPNOTSUPP; 429 428 430 429 err = drm_addmap_core(dev, map->offset, map->size, map->type, ··· 468 469 int idx; 469 470 int i; 470 471 471 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 472 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 472 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 473 473 return -EOPNOTSUPP; 474 474 475 475 idx = map->offset; ··· 568 570 569 571 void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map) 570 572 { 571 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 572 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 573 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 573 574 return; 574 575 575 576 mutex_lock(&dev->struct_mutex); ··· 625 628 struct drm_map_list *r_list; 626 629 int ret; 627 630 628 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 629 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 631 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 630 632 return -EOPNOTSUPP; 631 633 632 634 mutex_lock(&dev->struct_mutex);
+12 -24
drivers/gpu/drm/drm_context.c
··· 59 59 */ 60 60 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle) 61 61 { 62 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 63 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 62 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 64 63 return; 65 64 66 65 mutex_lock(&dev->struct_mutex); ··· 96 97 */ 97 98 void drm_legacy_ctxbitmap_init(struct drm_device * dev) 98 99 { 99 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 100 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 100 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 101 101 return; 102 102 103 103 idr_init(&dev->ctx_idr); ··· 112 114 */ 113 115 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev) 114 116 { 115 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 116 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 117 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 117 118 return; 118 119 119 120 mutex_lock(&dev->struct_mutex); ··· 133 136 { 134 137 struct drm_ctx_list *pos, *tmp; 135 138 136 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 137 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 139 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 138 140 return; 139 141 140 142 mutex_lock(&dev->ctxlist_mutex); ··· 178 182 struct drm_local_map *map; 179 183 struct drm_map_list *_entry; 180 184 181 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 182 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 185 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 183 186 return -EOPNOTSUPP; 184 187 185 188 mutex_lock(&dev->struct_mutex); ··· 225 230 struct drm_local_map *map = NULL; 226 231 struct drm_map_list *r_list = NULL; 227 232 228 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 229 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 233 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 230 234 return -EOPNOTSUPP; 231 235 232 236 mutex_lock(&dev->struct_mutex); ··· 329 335 struct drm_ctx ctx; 330 336 int i; 331 337 332 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 333 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 338 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 334 339 return -EOPNOTSUPP; 335 340 336 341 if (res->count >= DRM_RESERVED_CONTEXTS) { ··· 363 370 struct drm_ctx *ctx = data; 364 371 int tmp_handle; 365 372 366 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 367 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 373 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 368 374 return -EOPNOTSUPP; 369 375 370 376 tmp_handle = drm_legacy_ctxbitmap_next(dev); ··· 411 419 { 412 420 struct drm_ctx *ctx = data; 413 421 414 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 415 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 422 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 416 423 return -EOPNOTSUPP; 417 424 418 425 /* This is 0, because we don't handle any context flags */ ··· 436 445 { 437 446 struct drm_ctx *ctx = data; 438 447 439 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 440 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 448 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 441 449 return -EOPNOTSUPP; 442 450 443 451 DRM_DEBUG("%d\n", ctx->handle); ··· 459 469 { 460 470 struct drm_ctx *ctx = data; 461 471 462 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 463 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 472 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 464 473 return -EOPNOTSUPP; 465 474 466 475 DRM_DEBUG("%d\n", ctx->handle); ··· 484 495 { 485 496 struct drm_ctx *ctx = data; 486 497 487 - if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && 488 - !drm_core_check_feature(dev, DRIVER_LEGACY)) 498 + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) 489 499 return -EOPNOTSUPP; 490 500 491 501 DRM_DEBUG("%d\n", ctx->handle);
-12
drivers/gpu/drm/nouveau/Kconfig
··· 26 26 help 27 27 Choose this option for open-source NVIDIA support. 28 28 29 - config NOUVEAU_LEGACY_CTX_SUPPORT 30 - bool "Nouveau legacy context support" 31 - depends on DRM_NOUVEAU 32 - select DRM_LEGACY 33 - default y 34 - help 35 - There was a version of the nouveau DDX that relied on legacy 36 - ctx ioctls not erroring out. But that was back in time a long 37 - ways, so offer a way to disable it now. For uapi compat with 38 - old nouveau ddx this should be on by default, but modern distros 39 - should consider turning it off. 40 - 41 29 config NOUVEAU_PLATFORM_DRIVER 42 30 bool "Nouveau (NVIDIA) SoC GPUs" 43 31 depends on DRM_NOUVEAU && ARCH_TEGRA
+3 -7
drivers/gpu/drm/nouveau/nouveau_drm.c
··· 1221 1221 1222 1222 static struct drm_driver 1223 1223 driver_stub = { 1224 - .driver_features = 1225 - DRIVER_GEM | DRIVER_MODESET | DRIVER_RENDER 1226 - #if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT) 1227 - | DRIVER_KMS_LEGACY_CONTEXT 1228 - #endif 1229 - , 1230 - 1224 + .driver_features = DRIVER_GEM | 1225 + DRIVER_MODESET | 1226 + DRIVER_RENDER, 1231 1227 .open = nouveau_drm_open, 1232 1228 .postclose = nouveau_drm_postclose, 1233 1229 .lastclose = nouveau_vga_lastclose,
-7
include/drm/drm_drv.h
··· 141 141 * Legacy irq support. Only for legacy drivers. Do not use. 142 142 */ 143 143 DRIVER_HAVE_IRQ = BIT(30), 144 - /** 145 - * @DRIVER_KMS_LEGACY_CONTEXT: 146 - * 147 - * Used only by nouveau for backwards compatibility with existing 148 - * userspace. Do not use. 149 - */ 150 - DRIVER_KMS_LEGACY_CONTEXT = BIT(31), 151 144 }; 152 145 153 146 /**