All of lore.kernel.org
 help / color / mirror / Atom feed
* [Nouveau] [PATCH] drm/nouveau: Remove support for legacy contexts/buffers
@ 2023-01-12 13:38 ` Thomas Zimmermann
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Zimmermann @ 2023-01-12 13:38 UTC (permalink / raw)
  To: kherbst, bskeggs, lyude, daniel, airlied, mripard, maarten.lankhorst
  Cc: nouveau, dri-devel

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>
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
---
 drivers/gpu/drm/drm_bufs.c            | 12 +++------
 drivers/gpu/drm/drm_context.c         | 36 +++++++++------------------
 drivers/gpu/drm/nouveau/Kconfig       | 12 ---------
 drivers/gpu/drm/nouveau/nouveau_drm.c | 10 +++-----
 include/drm/drm_drv.h                 |  7 ------
 5 files changed, 19 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index fcca21e8efac..86700560fea2 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -423,8 +423,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
 	if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
 		return -EPERM;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	err = drm_addmap_core(dev, map->offset, map->size, map->type,
@@ -469,8 +468,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
 	int idx;
 	int i;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	idx = map->offset;
@@ -570,8 +568,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
 
 void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
 {
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -628,8 +625,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
 	struct drm_map_list *r_list;
 	int ret;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	mutex_lock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index c6e6a3e7219a..a0fc779e5e1e 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -59,8 +59,7 @@ struct drm_ctx_list {
  */
 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
 {
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -97,8 +96,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
  */
 void drm_legacy_ctxbitmap_init(struct drm_device * dev)
 {
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	idr_init(&dev->ctx_idr);
@@ -114,8 +112,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
  */
 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
 {
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -136,8 +133,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
 {
 	struct drm_ctx_list *pos, *tmp;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->ctxlist_mutex);
@@ -182,8 +178,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
 	struct drm_local_map *map;
 	struct drm_map_list *_entry;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	mutex_lock(&dev->struct_mutex);
@@ -230,8 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
 	struct drm_local_map *map = NULL;
 	struct drm_map_list *r_list = NULL;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	mutex_lock(&dev->struct_mutex);
@@ -335,8 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
 	struct drm_ctx ctx;
 	int i;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	if (res->count >= DRM_RESERVED_CONTEXTS) {
@@ -370,8 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
 	struct drm_ctx *ctx = data;
 	int tmp_handle;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	tmp_handle = drm_legacy_ctxbitmap_next(dev);
@@ -419,8 +411,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	/* This is 0, because we don't handle any context flags */
@@ -445,8 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	DRM_DEBUG("%d\n", ctx->handle);
@@ -469,8 +459,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	DRM_DEBUG("%d\n", ctx->handle);
@@ -495,8 +484,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	DRM_DEBUG("%d\n", ctx->handle);
diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
index 03d12caf9e26..ee92890d3266 100644
--- a/drivers/gpu/drm/nouveau/Kconfig
+++ b/drivers/gpu/drm/nouveau/Kconfig
@@ -24,18 +24,6 @@ config DRM_NOUVEAU
 	help
 	  Choose this option for open-source NVIDIA support.
 
-config NOUVEAU_LEGACY_CTX_SUPPORT
-	bool "Nouveau legacy context support"
-	depends on DRM_NOUVEAU
-	select DRM_LEGACY
-	default y
-	help
-	  There was a version of the nouveau DDX that relied on legacy
-	  ctx ioctls not erroring out. But that was back in time a long
-	  ways, so offer a way to disable it now. For uapi compat with
-	  old nouveau ddx this should be on by default, but modern distros
-	  should consider turning it off.
-
 config NOUVEAU_PLATFORM_DRIVER
 	bool "Nouveau (NVIDIA) SoC GPUs"
 	depends on DRM_NOUVEAU && ARCH_TEGRA
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 80f154b6adab..80562177b581 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1221,13 +1221,9 @@ nouveau_driver_fops = {
 
 static struct drm_driver
 driver_stub = {
-	.driver_features =
-		DRIVER_GEM | DRIVER_MODESET | DRIVER_RENDER
-#if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT)
-		| DRIVER_KMS_LEGACY_CONTEXT
-#endif
-		,
-
+	.driver_features = DRIVER_GEM |
+			   DRIVER_MODESET |
+			   DRIVER_RENDER,
 	.open = nouveau_drm_open,
 	.postclose = nouveau_drm_postclose,
 	.lastclose = nouveau_vga_lastclose,
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index d7c521e8860f..1d76d0686b03 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -149,13 +149,6 @@ enum drm_driver_feature {
 	 * Legacy irq support. Only for legacy drivers. Do not use.
 	 */
 	DRIVER_HAVE_IRQ			= BIT(30),
-	/**
-	 * @DRIVER_KMS_LEGACY_CONTEXT:
-	 *
-	 * Used only by nouveau for backwards compatibility with existing
-	 * userspace.  Do not use.
-	 */
-	DRIVER_KMS_LEGACY_CONTEXT	= BIT(31),
 };
 
 /**
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] drm/nouveau: Remove support for legacy contexts/buffers
@ 2023-01-12 13:38 ` Thomas Zimmermann
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Zimmermann @ 2023-01-12 13:38 UTC (permalink / raw)
  To: kherbst, bskeggs, lyude, daniel, airlied, mripard, maarten.lankhorst
  Cc: nouveau, Thomas Zimmermann, dri-devel

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>
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
---
 drivers/gpu/drm/drm_bufs.c            | 12 +++------
 drivers/gpu/drm/drm_context.c         | 36 +++++++++------------------
 drivers/gpu/drm/nouveau/Kconfig       | 12 ---------
 drivers/gpu/drm/nouveau/nouveau_drm.c | 10 +++-----
 include/drm/drm_drv.h                 |  7 ------
 5 files changed, 19 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index fcca21e8efac..86700560fea2 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -423,8 +423,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
 	if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
 		return -EPERM;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	err = drm_addmap_core(dev, map->offset, map->size, map->type,
@@ -469,8 +468,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
 	int idx;
 	int i;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	idx = map->offset;
@@ -570,8 +568,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
 
 void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
 {
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -628,8 +625,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
 	struct drm_map_list *r_list;
 	int ret;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	mutex_lock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index c6e6a3e7219a..a0fc779e5e1e 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -59,8 +59,7 @@ struct drm_ctx_list {
  */
 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
 {
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -97,8 +96,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
  */
 void drm_legacy_ctxbitmap_init(struct drm_device * dev)
 {
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	idr_init(&dev->ctx_idr);
@@ -114,8 +112,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
  */
 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
 {
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -136,8 +133,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
 {
 	struct drm_ctx_list *pos, *tmp;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->ctxlist_mutex);
@@ -182,8 +178,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
 	struct drm_local_map *map;
 	struct drm_map_list *_entry;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	mutex_lock(&dev->struct_mutex);
@@ -230,8 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
 	struct drm_local_map *map = NULL;
 	struct drm_map_list *r_list = NULL;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	mutex_lock(&dev->struct_mutex);
@@ -335,8 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
 	struct drm_ctx ctx;
 	int i;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	if (res->count >= DRM_RESERVED_CONTEXTS) {
@@ -370,8 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
 	struct drm_ctx *ctx = data;
 	int tmp_handle;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	tmp_handle = drm_legacy_ctxbitmap_next(dev);
@@ -419,8 +411,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	/* This is 0, because we don't handle any context flags */
@@ -445,8 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	DRM_DEBUG("%d\n", ctx->handle);
@@ -469,8 +459,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	DRM_DEBUG("%d\n", ctx->handle);
@@ -495,8 +484,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
-	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    !drm_core_check_feature(dev, DRIVER_LEGACY))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EOPNOTSUPP;
 
 	DRM_DEBUG("%d\n", ctx->handle);
diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
index 03d12caf9e26..ee92890d3266 100644
--- a/drivers/gpu/drm/nouveau/Kconfig
+++ b/drivers/gpu/drm/nouveau/Kconfig
@@ -24,18 +24,6 @@ config DRM_NOUVEAU
 	help
 	  Choose this option for open-source NVIDIA support.
 
-config NOUVEAU_LEGACY_CTX_SUPPORT
-	bool "Nouveau legacy context support"
-	depends on DRM_NOUVEAU
-	select DRM_LEGACY
-	default y
-	help
-	  There was a version of the nouveau DDX that relied on legacy
-	  ctx ioctls not erroring out. But that was back in time a long
-	  ways, so offer a way to disable it now. For uapi compat with
-	  old nouveau ddx this should be on by default, but modern distros
-	  should consider turning it off.
-
 config NOUVEAU_PLATFORM_DRIVER
 	bool "Nouveau (NVIDIA) SoC GPUs"
 	depends on DRM_NOUVEAU && ARCH_TEGRA
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 80f154b6adab..80562177b581 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1221,13 +1221,9 @@ nouveau_driver_fops = {
 
 static struct drm_driver
 driver_stub = {
-	.driver_features =
-		DRIVER_GEM | DRIVER_MODESET | DRIVER_RENDER
-#if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT)
-		| DRIVER_KMS_LEGACY_CONTEXT
-#endif
-		,
-
+	.driver_features = DRIVER_GEM |
+			   DRIVER_MODESET |
+			   DRIVER_RENDER,
 	.open = nouveau_drm_open,
 	.postclose = nouveau_drm_postclose,
 	.lastclose = nouveau_vga_lastclose,
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index d7c521e8860f..1d76d0686b03 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -149,13 +149,6 @@ enum drm_driver_feature {
 	 * Legacy irq support. Only for legacy drivers. Do not use.
 	 */
 	DRIVER_HAVE_IRQ			= BIT(30),
-	/**
-	 * @DRIVER_KMS_LEGACY_CONTEXT:
-	 *
-	 * Used only by nouveau for backwards compatibility with existing
-	 * userspace.  Do not use.
-	 */
-	DRIVER_KMS_LEGACY_CONTEXT	= BIT(31),
 };
 
 /**
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Nouveau] [PATCH] drm/nouveau: Remove support for legacy contexts/buffers
  2023-01-12 13:38 ` Thomas Zimmermann
@ 2023-01-12 13:40   ` Thomas Zimmermann
  -1 siblings, 0 replies; 8+ messages in thread
From: Thomas Zimmermann @ 2023-01-12 13:40 UTC (permalink / raw)
  To: kherbst, bskeggs, lyude, daniel, airlied, mripard, maarten.lankhorst
  Cc: nouveau, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 10392 bytes --]

If this patch gets accepted, I'd like to merge it via drm-misc-next 
together with the legacy-driver removal patches.

Am 12.01.23 um 14:38 schrieb Thomas Zimmermann:
> 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>
> 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
> ---
>   drivers/gpu/drm/drm_bufs.c            | 12 +++------
>   drivers/gpu/drm/drm_context.c         | 36 +++++++++------------------
>   drivers/gpu/drm/nouveau/Kconfig       | 12 ---------
>   drivers/gpu/drm/nouveau/nouveau_drm.c | 10 +++-----
>   include/drm/drm_drv.h                 |  7 ------
>   5 files changed, 19 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index fcca21e8efac..86700560fea2 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -423,8 +423,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>   	if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
>   		return -EPERM;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	err = drm_addmap_core(dev, map->offset, map->size, map->type,
> @@ -469,8 +468,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>   	int idx;
>   	int i;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	idx = map->offset;
> @@ -570,8 +568,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>   
>   void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>   {
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -628,8 +625,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>   	struct drm_map_list *r_list;
>   	int ret;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	mutex_lock(&dev->struct_mutex);
> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> index c6e6a3e7219a..a0fc779e5e1e 100644
> --- a/drivers/gpu/drm/drm_context.c
> +++ b/drivers/gpu/drm/drm_context.c
> @@ -59,8 +59,7 @@ struct drm_ctx_list {
>    */
>   void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>   {
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -97,8 +96,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
>    */
>   void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>   {
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	idr_init(&dev->ctx_idr);
> @@ -114,8 +112,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>    */
>   void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>   {
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -136,8 +133,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
>   {
>   	struct drm_ctx_list *pos, *tmp;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->ctxlist_mutex);
> @@ -182,8 +178,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
>   	struct drm_local_map *map;
>   	struct drm_map_list *_entry;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -230,8 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
>   	struct drm_local_map *map = NULL;
>   	struct drm_map_list *r_list = NULL;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -335,8 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>   	struct drm_ctx ctx;
>   	int i;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	if (res->count >= DRM_RESERVED_CONTEXTS) {
> @@ -370,8 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>   	struct drm_ctx *ctx = data;
>   	int tmp_handle;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	tmp_handle = drm_legacy_ctxbitmap_next(dev);
> @@ -419,8 +411,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>   {
>   	struct drm_ctx *ctx = data;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	/* This is 0, because we don't handle any context flags */
> @@ -445,8 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
>   {
>   	struct drm_ctx *ctx = data;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	DRM_DEBUG("%d\n", ctx->handle);
> @@ -469,8 +459,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
>   {
>   	struct drm_ctx *ctx = data;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	DRM_DEBUG("%d\n", ctx->handle);
> @@ -495,8 +484,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
>   {
>   	struct drm_ctx *ctx = data;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	DRM_DEBUG("%d\n", ctx->handle);
> diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
> index 03d12caf9e26..ee92890d3266 100644
> --- a/drivers/gpu/drm/nouveau/Kconfig
> +++ b/drivers/gpu/drm/nouveau/Kconfig
> @@ -24,18 +24,6 @@ config DRM_NOUVEAU
>   	help
>   	  Choose this option for open-source NVIDIA support.
>   
> -config NOUVEAU_LEGACY_CTX_SUPPORT
> -	bool "Nouveau legacy context support"
> -	depends on DRM_NOUVEAU
> -	select DRM_LEGACY
> -	default y
> -	help
> -	  There was a version of the nouveau DDX that relied on legacy
> -	  ctx ioctls not erroring out. But that was back in time a long
> -	  ways, so offer a way to disable it now. For uapi compat with
> -	  old nouveau ddx this should be on by default, but modern distros
> -	  should consider turning it off.
> -
>   config NOUVEAU_PLATFORM_DRIVER
>   	bool "Nouveau (NVIDIA) SoC GPUs"
>   	depends on DRM_NOUVEAU && ARCH_TEGRA
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 80f154b6adab..80562177b581 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -1221,13 +1221,9 @@ nouveau_driver_fops = {
>   
>   static struct drm_driver
>   driver_stub = {
> -	.driver_features =
> -		DRIVER_GEM | DRIVER_MODESET | DRIVER_RENDER
> -#if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT)
> -		| DRIVER_KMS_LEGACY_CONTEXT
> -#endif
> -		,
> -
> +	.driver_features = DRIVER_GEM |
> +			   DRIVER_MODESET |
> +			   DRIVER_RENDER,
>   	.open = nouveau_drm_open,
>   	.postclose = nouveau_drm_postclose,
>   	.lastclose = nouveau_vga_lastclose,
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index d7c521e8860f..1d76d0686b03 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -149,13 +149,6 @@ enum drm_driver_feature {
>   	 * Legacy irq support. Only for legacy drivers. Do not use.
>   	 */
>   	DRIVER_HAVE_IRQ			= BIT(30),
> -	/**
> -	 * @DRIVER_KMS_LEGACY_CONTEXT:
> -	 *
> -	 * Used only by nouveau for backwards compatibility with existing
> -	 * userspace.  Do not use.
> -	 */
> -	DRIVER_KMS_LEGACY_CONTEXT	= BIT(31),
>   };
>   
>   /**

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/nouveau: Remove support for legacy contexts/buffers
@ 2023-01-12 13:40   ` Thomas Zimmermann
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Zimmermann @ 2023-01-12 13:40 UTC (permalink / raw)
  To: kherbst, bskeggs, lyude, daniel, airlied, mripard, maarten.lankhorst
  Cc: nouveau, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 10392 bytes --]

If this patch gets accepted, I'd like to merge it via drm-misc-next 
together with the legacy-driver removal patches.

Am 12.01.23 um 14:38 schrieb Thomas Zimmermann:
> 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>
> 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
> ---
>   drivers/gpu/drm/drm_bufs.c            | 12 +++------
>   drivers/gpu/drm/drm_context.c         | 36 +++++++++------------------
>   drivers/gpu/drm/nouveau/Kconfig       | 12 ---------
>   drivers/gpu/drm/nouveau/nouveau_drm.c | 10 +++-----
>   include/drm/drm_drv.h                 |  7 ------
>   5 files changed, 19 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index fcca21e8efac..86700560fea2 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -423,8 +423,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>   	if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
>   		return -EPERM;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	err = drm_addmap_core(dev, map->offset, map->size, map->type,
> @@ -469,8 +468,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>   	int idx;
>   	int i;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	idx = map->offset;
> @@ -570,8 +568,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>   
>   void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>   {
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -628,8 +625,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>   	struct drm_map_list *r_list;
>   	int ret;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	mutex_lock(&dev->struct_mutex);
> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> index c6e6a3e7219a..a0fc779e5e1e 100644
> --- a/drivers/gpu/drm/drm_context.c
> +++ b/drivers/gpu/drm/drm_context.c
> @@ -59,8 +59,7 @@ struct drm_ctx_list {
>    */
>   void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>   {
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -97,8 +96,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
>    */
>   void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>   {
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	idr_init(&dev->ctx_idr);
> @@ -114,8 +112,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>    */
>   void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>   {
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -136,8 +133,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
>   {
>   	struct drm_ctx_list *pos, *tmp;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->ctxlist_mutex);
> @@ -182,8 +178,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
>   	struct drm_local_map *map;
>   	struct drm_map_list *_entry;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -230,8 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
>   	struct drm_local_map *map = NULL;
>   	struct drm_map_list *r_list = NULL;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -335,8 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>   	struct drm_ctx ctx;
>   	int i;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	if (res->count >= DRM_RESERVED_CONTEXTS) {
> @@ -370,8 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>   	struct drm_ctx *ctx = data;
>   	int tmp_handle;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	tmp_handle = drm_legacy_ctxbitmap_next(dev);
> @@ -419,8 +411,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>   {
>   	struct drm_ctx *ctx = data;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	/* This is 0, because we don't handle any context flags */
> @@ -445,8 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
>   {
>   	struct drm_ctx *ctx = data;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	DRM_DEBUG("%d\n", ctx->handle);
> @@ -469,8 +459,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
>   {
>   	struct drm_ctx *ctx = data;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	DRM_DEBUG("%d\n", ctx->handle);
> @@ -495,8 +484,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
>   {
>   	struct drm_ctx *ctx = data;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EOPNOTSUPP;
>   
>   	DRM_DEBUG("%d\n", ctx->handle);
> diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
> index 03d12caf9e26..ee92890d3266 100644
> --- a/drivers/gpu/drm/nouveau/Kconfig
> +++ b/drivers/gpu/drm/nouveau/Kconfig
> @@ -24,18 +24,6 @@ config DRM_NOUVEAU
>   	help
>   	  Choose this option for open-source NVIDIA support.
>   
> -config NOUVEAU_LEGACY_CTX_SUPPORT
> -	bool "Nouveau legacy context support"
> -	depends on DRM_NOUVEAU
> -	select DRM_LEGACY
> -	default y
> -	help
> -	  There was a version of the nouveau DDX that relied on legacy
> -	  ctx ioctls not erroring out. But that was back in time a long
> -	  ways, so offer a way to disable it now. For uapi compat with
> -	  old nouveau ddx this should be on by default, but modern distros
> -	  should consider turning it off.
> -
>   config NOUVEAU_PLATFORM_DRIVER
>   	bool "Nouveau (NVIDIA) SoC GPUs"
>   	depends on DRM_NOUVEAU && ARCH_TEGRA
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 80f154b6adab..80562177b581 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -1221,13 +1221,9 @@ nouveau_driver_fops = {
>   
>   static struct drm_driver
>   driver_stub = {
> -	.driver_features =
> -		DRIVER_GEM | DRIVER_MODESET | DRIVER_RENDER
> -#if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT)
> -		| DRIVER_KMS_LEGACY_CONTEXT
> -#endif
> -		,
> -
> +	.driver_features = DRIVER_GEM |
> +			   DRIVER_MODESET |
> +			   DRIVER_RENDER,
>   	.open = nouveau_drm_open,
>   	.postclose = nouveau_drm_postclose,
>   	.lastclose = nouveau_vga_lastclose,
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index d7c521e8860f..1d76d0686b03 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -149,13 +149,6 @@ enum drm_driver_feature {
>   	 * Legacy irq support. Only for legacy drivers. Do not use.
>   	 */
>   	DRIVER_HAVE_IRQ			= BIT(30),
> -	/**
> -	 * @DRIVER_KMS_LEGACY_CONTEXT:
> -	 *
> -	 * Used only by nouveau for backwards compatibility with existing
> -	 * userspace.  Do not use.
> -	 */
> -	DRIVER_KMS_LEGACY_CONTEXT	= BIT(31),
>   };
>   
>   /**

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/nouveau: Remove support for legacy contexts/buffers
  2023-01-12 13:38 ` Thomas Zimmermann
@ 2023-01-13  0:07   ` Karol Herbst
  -1 siblings, 0 replies; 8+ messages in thread
From: Karol Herbst @ 2023-01-13  0:07 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: nouveau, dri-devel, bskeggs

On Thu, Jan 12, 2023 at 2:39 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> 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>
> 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

Reviewed-by: Karol Herbst <kherbst@redhat.com>

let's hope there are no users left :)


> ---
>  drivers/gpu/drm/drm_bufs.c            | 12 +++------
>  drivers/gpu/drm/drm_context.c         | 36 +++++++++------------------
>  drivers/gpu/drm/nouveau/Kconfig       | 12 ---------
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 10 +++-----
>  include/drm/drm_drv.h                 |  7 ------
>  5 files changed, 19 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index fcca21e8efac..86700560fea2 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -423,8 +423,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>         if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
>                 return -EPERM;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         err = drm_addmap_core(dev, map->offset, map->size, map->type,
> @@ -469,8 +468,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>         int idx;
>         int i;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         idx = map->offset;
> @@ -570,8 +568,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>
>  void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>  {
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -628,8 +625,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>         struct drm_map_list *r_list;
>         int ret;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         mutex_lock(&dev->struct_mutex);
> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> index c6e6a3e7219a..a0fc779e5e1e 100644
> --- a/drivers/gpu/drm/drm_context.c
> +++ b/drivers/gpu/drm/drm_context.c
> @@ -59,8 +59,7 @@ struct drm_ctx_list {
>   */
>  void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>  {
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -97,8 +96,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
>   */
>  void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>  {
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         idr_init(&dev->ctx_idr);
> @@ -114,8 +112,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>   */
>  void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>  {
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -136,8 +133,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
>  {
>         struct drm_ctx_list *pos, *tmp;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->ctxlist_mutex);
> @@ -182,8 +178,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
>         struct drm_local_map *map;
>         struct drm_map_list *_entry;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -230,8 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
>         struct drm_local_map *map = NULL;
>         struct drm_map_list *r_list = NULL;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -335,8 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>         struct drm_ctx ctx;
>         int i;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         if (res->count >= DRM_RESERVED_CONTEXTS) {
> @@ -370,8 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>         struct drm_ctx *ctx = data;
>         int tmp_handle;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         tmp_handle = drm_legacy_ctxbitmap_next(dev);
> @@ -419,8 +411,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>  {
>         struct drm_ctx *ctx = data;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         /* This is 0, because we don't handle any context flags */
> @@ -445,8 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
>  {
>         struct drm_ctx *ctx = data;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         DRM_DEBUG("%d\n", ctx->handle);
> @@ -469,8 +459,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
>  {
>         struct drm_ctx *ctx = data;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         DRM_DEBUG("%d\n", ctx->handle);
> @@ -495,8 +484,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
>  {
>         struct drm_ctx *ctx = data;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         DRM_DEBUG("%d\n", ctx->handle);
> diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
> index 03d12caf9e26..ee92890d3266 100644
> --- a/drivers/gpu/drm/nouveau/Kconfig
> +++ b/drivers/gpu/drm/nouveau/Kconfig
> @@ -24,18 +24,6 @@ config DRM_NOUVEAU
>         help
>           Choose this option for open-source NVIDIA support.
>
> -config NOUVEAU_LEGACY_CTX_SUPPORT
> -       bool "Nouveau legacy context support"
> -       depends on DRM_NOUVEAU
> -       select DRM_LEGACY
> -       default y
> -       help
> -         There was a version of the nouveau DDX that relied on legacy
> -         ctx ioctls not erroring out. But that was back in time a long
> -         ways, so offer a way to disable it now. For uapi compat with
> -         old nouveau ddx this should be on by default, but modern distros
> -         should consider turning it off.
> -
>  config NOUVEAU_PLATFORM_DRIVER
>         bool "Nouveau (NVIDIA) SoC GPUs"
>         depends on DRM_NOUVEAU && ARCH_TEGRA
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 80f154b6adab..80562177b581 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -1221,13 +1221,9 @@ nouveau_driver_fops = {
>
>  static struct drm_driver
>  driver_stub = {
> -       .driver_features =
> -               DRIVER_GEM | DRIVER_MODESET | DRIVER_RENDER
> -#if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT)
> -               | DRIVER_KMS_LEGACY_CONTEXT
> -#endif
> -               ,
> -
> +       .driver_features = DRIVER_GEM |
> +                          DRIVER_MODESET |
> +                          DRIVER_RENDER,
>         .open = nouveau_drm_open,
>         .postclose = nouveau_drm_postclose,
>         .lastclose = nouveau_vga_lastclose,
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index d7c521e8860f..1d76d0686b03 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -149,13 +149,6 @@ enum drm_driver_feature {
>          * Legacy irq support. Only for legacy drivers. Do not use.
>          */
>         DRIVER_HAVE_IRQ                 = BIT(30),
> -       /**
> -        * @DRIVER_KMS_LEGACY_CONTEXT:
> -        *
> -        * Used only by nouveau for backwards compatibility with existing
> -        * userspace.  Do not use.
> -        */
> -       DRIVER_KMS_LEGACY_CONTEXT       = BIT(31),
>  };
>
>  /**
> --
> 2.39.0
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Nouveau] [PATCH] drm/nouveau: Remove support for legacy contexts/buffers
@ 2023-01-13  0:07   ` Karol Herbst
  0 siblings, 0 replies; 8+ messages in thread
From: Karol Herbst @ 2023-01-13  0:07 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: nouveau, dri-devel, maarten.lankhorst, mripard, bskeggs, daniel

On Thu, Jan 12, 2023 at 2:39 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> 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>
> 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

Reviewed-by: Karol Herbst <kherbst@redhat.com>

let's hope there are no users left :)


> ---
>  drivers/gpu/drm/drm_bufs.c            | 12 +++------
>  drivers/gpu/drm/drm_context.c         | 36 +++++++++------------------
>  drivers/gpu/drm/nouveau/Kconfig       | 12 ---------
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 10 +++-----
>  include/drm/drm_drv.h                 |  7 ------
>  5 files changed, 19 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index fcca21e8efac..86700560fea2 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -423,8 +423,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>         if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
>                 return -EPERM;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         err = drm_addmap_core(dev, map->offset, map->size, map->type,
> @@ -469,8 +468,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>         int idx;
>         int i;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         idx = map->offset;
> @@ -570,8 +568,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>
>  void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>  {
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -628,8 +625,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>         struct drm_map_list *r_list;
>         int ret;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         mutex_lock(&dev->struct_mutex);
> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> index c6e6a3e7219a..a0fc779e5e1e 100644
> --- a/drivers/gpu/drm/drm_context.c
> +++ b/drivers/gpu/drm/drm_context.c
> @@ -59,8 +59,7 @@ struct drm_ctx_list {
>   */
>  void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>  {
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -97,8 +96,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
>   */
>  void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>  {
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         idr_init(&dev->ctx_idr);
> @@ -114,8 +112,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>   */
>  void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>  {
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -136,8 +133,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
>  {
>         struct drm_ctx_list *pos, *tmp;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->ctxlist_mutex);
> @@ -182,8 +178,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
>         struct drm_local_map *map;
>         struct drm_map_list *_entry;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -230,8 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
>         struct drm_local_map *map = NULL;
>         struct drm_map_list *r_list = NULL;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -335,8 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>         struct drm_ctx ctx;
>         int i;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         if (res->count >= DRM_RESERVED_CONTEXTS) {
> @@ -370,8 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>         struct drm_ctx *ctx = data;
>         int tmp_handle;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         tmp_handle = drm_legacy_ctxbitmap_next(dev);
> @@ -419,8 +411,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>  {
>         struct drm_ctx *ctx = data;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         /* This is 0, because we don't handle any context flags */
> @@ -445,8 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
>  {
>         struct drm_ctx *ctx = data;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         DRM_DEBUG("%d\n", ctx->handle);
> @@ -469,8 +459,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
>  {
>         struct drm_ctx *ctx = data;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         DRM_DEBUG("%d\n", ctx->handle);
> @@ -495,8 +484,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
>  {
>         struct drm_ctx *ctx = data;
>
> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EOPNOTSUPP;
>
>         DRM_DEBUG("%d\n", ctx->handle);
> diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
> index 03d12caf9e26..ee92890d3266 100644
> --- a/drivers/gpu/drm/nouveau/Kconfig
> +++ b/drivers/gpu/drm/nouveau/Kconfig
> @@ -24,18 +24,6 @@ config DRM_NOUVEAU
>         help
>           Choose this option for open-source NVIDIA support.
>
> -config NOUVEAU_LEGACY_CTX_SUPPORT
> -       bool "Nouveau legacy context support"
> -       depends on DRM_NOUVEAU
> -       select DRM_LEGACY
> -       default y
> -       help
> -         There was a version of the nouveau DDX that relied on legacy
> -         ctx ioctls not erroring out. But that was back in time a long
> -         ways, so offer a way to disable it now. For uapi compat with
> -         old nouveau ddx this should be on by default, but modern distros
> -         should consider turning it off.
> -
>  config NOUVEAU_PLATFORM_DRIVER
>         bool "Nouveau (NVIDIA) SoC GPUs"
>         depends on DRM_NOUVEAU && ARCH_TEGRA
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 80f154b6adab..80562177b581 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -1221,13 +1221,9 @@ nouveau_driver_fops = {
>
>  static struct drm_driver
>  driver_stub = {
> -       .driver_features =
> -               DRIVER_GEM | DRIVER_MODESET | DRIVER_RENDER
> -#if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT)
> -               | DRIVER_KMS_LEGACY_CONTEXT
> -#endif
> -               ,
> -
> +       .driver_features = DRIVER_GEM |
> +                          DRIVER_MODESET |
> +                          DRIVER_RENDER,
>         .open = nouveau_drm_open,
>         .postclose = nouveau_drm_postclose,
>         .lastclose = nouveau_vga_lastclose,
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index d7c521e8860f..1d76d0686b03 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -149,13 +149,6 @@ enum drm_driver_feature {
>          * Legacy irq support. Only for legacy drivers. Do not use.
>          */
>         DRIVER_HAVE_IRQ                 = BIT(30),
> -       /**
> -        * @DRIVER_KMS_LEGACY_CONTEXT:
> -        *
> -        * Used only by nouveau for backwards compatibility with existing
> -        * userspace.  Do not use.
> -        */
> -       DRIVER_KMS_LEGACY_CONTEXT       = BIT(31),
>  };
>
>  /**
> --
> 2.39.0
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Nouveau] [PATCH] drm/nouveau: Remove support for legacy contexts/buffers
  2023-01-13  0:07   ` [Nouveau] " Karol Herbst
@ 2023-01-13  9:30     ` Thomas Zimmermann
  -1 siblings, 0 replies; 8+ messages in thread
From: Thomas Zimmermann @ 2023-01-13  9:30 UTC (permalink / raw)
  To: Karol Herbst; +Cc: nouveau, bskeggs, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 11665 bytes --]



Am 13.01.23 um 01:07 schrieb Karol Herbst:
> On Thu, Jan 12, 2023 at 2:39 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>> 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>
>> 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
> 
> Reviewed-by: Karol Herbst <kherbst@redhat.com>
> 
> let's hope there are no users left :)

Merged into drm-misc-next. Thanks!

> 
> 
>> ---
>>   drivers/gpu/drm/drm_bufs.c            | 12 +++------
>>   drivers/gpu/drm/drm_context.c         | 36 +++++++++------------------
>>   drivers/gpu/drm/nouveau/Kconfig       | 12 ---------
>>   drivers/gpu/drm/nouveau/nouveau_drm.c | 10 +++-----
>>   include/drm/drm_drv.h                 |  7 ------
>>   5 files changed, 19 insertions(+), 58 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
>> index fcca21e8efac..86700560fea2 100644
>> --- a/drivers/gpu/drm/drm_bufs.c
>> +++ b/drivers/gpu/drm/drm_bufs.c
>> @@ -423,8 +423,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>>          if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
>>                  return -EPERM;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          err = drm_addmap_core(dev, map->offset, map->size, map->type,
>> @@ -469,8 +468,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>>          int idx;
>>          int i;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          idx = map->offset;
>> @@ -570,8 +568,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>>
>>   void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>>   {
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -628,8 +625,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>>          struct drm_map_list *r_list;
>>          int ret;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          mutex_lock(&dev->struct_mutex);
>> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
>> index c6e6a3e7219a..a0fc779e5e1e 100644
>> --- a/drivers/gpu/drm/drm_context.c
>> +++ b/drivers/gpu/drm/drm_context.c
>> @@ -59,8 +59,7 @@ struct drm_ctx_list {
>>    */
>>   void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>>   {
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -97,8 +96,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
>>    */
>>   void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>>   {
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          idr_init(&dev->ctx_idr);
>> @@ -114,8 +112,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>>    */
>>   void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>>   {
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -136,8 +133,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
>>   {
>>          struct drm_ctx_list *pos, *tmp;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          mutex_lock(&dev->ctxlist_mutex);
>> @@ -182,8 +178,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
>>          struct drm_local_map *map;
>>          struct drm_map_list *_entry;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -230,8 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
>>          struct drm_local_map *map = NULL;
>>          struct drm_map_list *r_list = NULL;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -335,8 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>>          struct drm_ctx ctx;
>>          int i;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          if (res->count >= DRM_RESERVED_CONTEXTS) {
>> @@ -370,8 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>>          struct drm_ctx *ctx = data;
>>          int tmp_handle;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          tmp_handle = drm_legacy_ctxbitmap_next(dev);
>> @@ -419,8 +411,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>>   {
>>          struct drm_ctx *ctx = data;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          /* This is 0, because we don't handle any context flags */
>> @@ -445,8 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
>>   {
>>          struct drm_ctx *ctx = data;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          DRM_DEBUG("%d\n", ctx->handle);
>> @@ -469,8 +459,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
>>   {
>>          struct drm_ctx *ctx = data;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          DRM_DEBUG("%d\n", ctx->handle);
>> @@ -495,8 +484,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
>>   {
>>          struct drm_ctx *ctx = data;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          DRM_DEBUG("%d\n", ctx->handle);
>> diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
>> index 03d12caf9e26..ee92890d3266 100644
>> --- a/drivers/gpu/drm/nouveau/Kconfig
>> +++ b/drivers/gpu/drm/nouveau/Kconfig
>> @@ -24,18 +24,6 @@ config DRM_NOUVEAU
>>          help
>>            Choose this option for open-source NVIDIA support.
>>
>> -config NOUVEAU_LEGACY_CTX_SUPPORT
>> -       bool "Nouveau legacy context support"
>> -       depends on DRM_NOUVEAU
>> -       select DRM_LEGACY
>> -       default y
>> -       help
>> -         There was a version of the nouveau DDX that relied on legacy
>> -         ctx ioctls not erroring out. But that was back in time a long
>> -         ways, so offer a way to disable it now. For uapi compat with
>> -         old nouveau ddx this should be on by default, but modern distros
>> -         should consider turning it off.
>> -
>>   config NOUVEAU_PLATFORM_DRIVER
>>          bool "Nouveau (NVIDIA) SoC GPUs"
>>          depends on DRM_NOUVEAU && ARCH_TEGRA
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
>> index 80f154b6adab..80562177b581 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
>> @@ -1221,13 +1221,9 @@ nouveau_driver_fops = {
>>
>>   static struct drm_driver
>>   driver_stub = {
>> -       .driver_features =
>> -               DRIVER_GEM | DRIVER_MODESET | DRIVER_RENDER
>> -#if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT)
>> -               | DRIVER_KMS_LEGACY_CONTEXT
>> -#endif
>> -               ,
>> -
>> +       .driver_features = DRIVER_GEM |
>> +                          DRIVER_MODESET |
>> +                          DRIVER_RENDER,
>>          .open = nouveau_drm_open,
>>          .postclose = nouveau_drm_postclose,
>>          .lastclose = nouveau_vga_lastclose,
>> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
>> index d7c521e8860f..1d76d0686b03 100644
>> --- a/include/drm/drm_drv.h
>> +++ b/include/drm/drm_drv.h
>> @@ -149,13 +149,6 @@ enum drm_driver_feature {
>>           * Legacy irq support. Only for legacy drivers. Do not use.
>>           */
>>          DRIVER_HAVE_IRQ                 = BIT(30),
>> -       /**
>> -        * @DRIVER_KMS_LEGACY_CONTEXT:
>> -        *
>> -        * Used only by nouveau for backwards compatibility with existing
>> -        * userspace.  Do not use.
>> -        */
>> -       DRIVER_KMS_LEGACY_CONTEXT       = BIT(31),
>>   };
>>
>>   /**
>> --
>> 2.39.0
>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/nouveau: Remove support for legacy contexts/buffers
@ 2023-01-13  9:30     ` Thomas Zimmermann
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Zimmermann @ 2023-01-13  9:30 UTC (permalink / raw)
  To: Karol Herbst; +Cc: nouveau, bskeggs, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 11665 bytes --]



Am 13.01.23 um 01:07 schrieb Karol Herbst:
> On Thu, Jan 12, 2023 at 2:39 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>> 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>
>> 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
> 
> Reviewed-by: Karol Herbst <kherbst@redhat.com>
> 
> let's hope there are no users left :)

Merged into drm-misc-next. Thanks!

> 
> 
>> ---
>>   drivers/gpu/drm/drm_bufs.c            | 12 +++------
>>   drivers/gpu/drm/drm_context.c         | 36 +++++++++------------------
>>   drivers/gpu/drm/nouveau/Kconfig       | 12 ---------
>>   drivers/gpu/drm/nouveau/nouveau_drm.c | 10 +++-----
>>   include/drm/drm_drv.h                 |  7 ------
>>   5 files changed, 19 insertions(+), 58 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
>> index fcca21e8efac..86700560fea2 100644
>> --- a/drivers/gpu/drm/drm_bufs.c
>> +++ b/drivers/gpu/drm/drm_bufs.c
>> @@ -423,8 +423,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>>          if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
>>                  return -EPERM;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          err = drm_addmap_core(dev, map->offset, map->size, map->type,
>> @@ -469,8 +468,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>>          int idx;
>>          int i;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          idx = map->offset;
>> @@ -570,8 +568,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>>
>>   void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>>   {
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -628,8 +625,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>>          struct drm_map_list *r_list;
>>          int ret;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          mutex_lock(&dev->struct_mutex);
>> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
>> index c6e6a3e7219a..a0fc779e5e1e 100644
>> --- a/drivers/gpu/drm/drm_context.c
>> +++ b/drivers/gpu/drm/drm_context.c
>> @@ -59,8 +59,7 @@ struct drm_ctx_list {
>>    */
>>   void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>>   {
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -97,8 +96,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
>>    */
>>   void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>>   {
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          idr_init(&dev->ctx_idr);
>> @@ -114,8 +112,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>>    */
>>   void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>>   {
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -136,8 +133,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
>>   {
>>          struct drm_ctx_list *pos, *tmp;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return;
>>
>>          mutex_lock(&dev->ctxlist_mutex);
>> @@ -182,8 +178,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
>>          struct drm_local_map *map;
>>          struct drm_map_list *_entry;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -230,8 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
>>          struct drm_local_map *map = NULL;
>>          struct drm_map_list *r_list = NULL;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          mutex_lock(&dev->struct_mutex);
>> @@ -335,8 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>>          struct drm_ctx ctx;
>>          int i;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          if (res->count >= DRM_RESERVED_CONTEXTS) {
>> @@ -370,8 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>>          struct drm_ctx *ctx = data;
>>          int tmp_handle;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          tmp_handle = drm_legacy_ctxbitmap_next(dev);
>> @@ -419,8 +411,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>>   {
>>          struct drm_ctx *ctx = data;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          /* This is 0, because we don't handle any context flags */
>> @@ -445,8 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
>>   {
>>          struct drm_ctx *ctx = data;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          DRM_DEBUG("%d\n", ctx->handle);
>> @@ -469,8 +459,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
>>   {
>>          struct drm_ctx *ctx = data;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          DRM_DEBUG("%d\n", ctx->handle);
>> @@ -495,8 +484,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
>>   {
>>          struct drm_ctx *ctx = data;
>>
>> -       if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>> -           !drm_core_check_feature(dev, DRIVER_LEGACY))
>> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>                  return -EOPNOTSUPP;
>>
>>          DRM_DEBUG("%d\n", ctx->handle);
>> diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
>> index 03d12caf9e26..ee92890d3266 100644
>> --- a/drivers/gpu/drm/nouveau/Kconfig
>> +++ b/drivers/gpu/drm/nouveau/Kconfig
>> @@ -24,18 +24,6 @@ config DRM_NOUVEAU
>>          help
>>            Choose this option for open-source NVIDIA support.
>>
>> -config NOUVEAU_LEGACY_CTX_SUPPORT
>> -       bool "Nouveau legacy context support"
>> -       depends on DRM_NOUVEAU
>> -       select DRM_LEGACY
>> -       default y
>> -       help
>> -         There was a version of the nouveau DDX that relied on legacy
>> -         ctx ioctls not erroring out. But that was back in time a long
>> -         ways, so offer a way to disable it now. For uapi compat with
>> -         old nouveau ddx this should be on by default, but modern distros
>> -         should consider turning it off.
>> -
>>   config NOUVEAU_PLATFORM_DRIVER
>>          bool "Nouveau (NVIDIA) SoC GPUs"
>>          depends on DRM_NOUVEAU && ARCH_TEGRA
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
>> index 80f154b6adab..80562177b581 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
>> @@ -1221,13 +1221,9 @@ nouveau_driver_fops = {
>>
>>   static struct drm_driver
>>   driver_stub = {
>> -       .driver_features =
>> -               DRIVER_GEM | DRIVER_MODESET | DRIVER_RENDER
>> -#if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT)
>> -               | DRIVER_KMS_LEGACY_CONTEXT
>> -#endif
>> -               ,
>> -
>> +       .driver_features = DRIVER_GEM |
>> +                          DRIVER_MODESET |
>> +                          DRIVER_RENDER,
>>          .open = nouveau_drm_open,
>>          .postclose = nouveau_drm_postclose,
>>          .lastclose = nouveau_vga_lastclose,
>> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
>> index d7c521e8860f..1d76d0686b03 100644
>> --- a/include/drm/drm_drv.h
>> +++ b/include/drm/drm_drv.h
>> @@ -149,13 +149,6 @@ enum drm_driver_feature {
>>           * Legacy irq support. Only for legacy drivers. Do not use.
>>           */
>>          DRIVER_HAVE_IRQ                 = BIT(30),
>> -       /**
>> -        * @DRIVER_KMS_LEGACY_CONTEXT:
>> -        *
>> -        * Used only by nouveau for backwards compatibility with existing
>> -        * userspace.  Do not use.
>> -        */
>> -       DRIVER_KMS_LEGACY_CONTEXT       = BIT(31),
>>   };
>>
>>   /**
>> --
>> 2.39.0
>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-01-13  9:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-12 13:38 [Nouveau] [PATCH] drm/nouveau: Remove support for legacy contexts/buffers Thomas Zimmermann
2023-01-12 13:38 ` Thomas Zimmermann
2023-01-12 13:40 ` [Nouveau] " Thomas Zimmermann
2023-01-12 13:40   ` Thomas Zimmermann
2023-01-13  0:07 ` Karol Herbst
2023-01-13  0:07   ` [Nouveau] " Karol Herbst
2023-01-13  9:30   ` Thomas Zimmermann
2023-01-13  9:30     ` Thomas Zimmermann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.