Skip to contentSkip to conversation

drm: make legacy support code optional

PATCH In review Dave Airlie 4 participants 27 messages Apr 23, 2019

Subsystems (4)
lore
Share & tools
lore

Dave Airlie

author maintainer
#0 lore raw

This series attempts to make the legacy support core code removalable at build time, if no drivers require it.

It reduces code size of the core drm.ko by ~10%.

It's also available in
https://cgit.freedesktop.org/~airlied/linux/log/?h=drm-legacy-cleanup

The first patch has Daniels r-b on it, but I've moved DRM_VM selection in the v2. The rest just move code around first, then the last 3 actually make the legacy code removable.

Dave.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#1 lore raw

PATCH 1/12 drm/nouveau: add kconfig option to turn off nouveau legacy contexts. (v2)

From: Dave Airlie <[email protected]>

There was a nouveau DDX that relied on legacy context ioctls to work, but we fixed it years ago, give distros that have a modern DDX the option to break the uAPI and close the mess of holes that legacy context support is.

Full context of the story:

commit 0e975980d435d58df2d430d688b8c18778b42218

Author: Peter Antoine <[email protected]>
Date:   Tue Jun 23 08:18:49 2015 +0100

drm: Turn off Legacy Context Functions

The context functions are not used by the i915 driver and should not be used by modeset drivers. These driver functions contain several bugs and security holes. This change makes these functions optional can be turned on by a setting, they are turned off by default for modeset driver with the exception of the nouvea driver that may require them with an old version of libdrm.

The previous attempt was

commit 7c510133d93dd6f15ca040733ba7b2891ed61fd1
Author: Daniel Vetter <[email protected]>
Date: Thu Aug 8 15:41:21 2013 +0200

drm: mark context support as a legacy subsystem

but this had to be reverted

commit c21eb21cb50d58e7cbdcb8b9e7ff68b85cfa5095
Author: Dave Airlie <[email protected]>
Date: Fri Sep 20 08:32:59 2013 +1000

Revert "drm: mark context support as a legacy subsystem"

v2: remove returns from void function, and formatting (Daniel Vetter)

v3:
- s/Nova/nouveau/ in the commit message, and add references to the previous attempts
- drop the part touching the drm hw lock, that should be a separate patch.

v2: move DRM_VM dependency into legacy config.

---
 drivers/gpu/drm/nouveau/Kconfig       | 12 +++++++++++-
 drivers/gpu/drm/nouveau/nouveau_drm.c |  7 +++++--
 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/Kconfig +11 -1
index 00cd9ab8948d..3ae7a4cfc6bb 100644
@@ -17,10 +17,20 @@ config DRM_NOUVEAU
 	select INPUT if ACPI && X86
 	select THERMAL if ACPI && X86
 	select ACPI_VIDEO if ACPI && X86
-	select DRM_VM
 	help
 	  Choose this option for open-source NVIDIA support.
 
+config NOUVEAU_LEGACY_CTX_SUPPORT
+	bool "Nouveau legacy context support"
+	select DRM_VM
+	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
drivers/gpu/drm/nouveau/nouveau_drm.c +5 -2
index 5020265bfbd9..6ab9033f49da 100644
@@ -1094,8 +1094,11 @@ nouveau_driver_fops = {
 static struct drm_driver
 driver_stub = {
 	.driver_features =
-		DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
-		DRIVER_KMS_LEGACY_CONTEXT,
+		DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER
+#if defined(CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT)
+		| DRIVER_KMS_LEGACY_CONTEXT
+#endif
+		,
 
 	.open = nouveau_drm_open,
 	.postclose = nouveau_drm_postclose,
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#2 lore raw

PATCH 2/12 drm/legacy: move drm_legacy_master_rmmaps to non-driver legacy header.

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This isn't used by drivers, and won't be in the future.

---
 drivers/gpu/drm/drm_legacy.h | 3 +++
 include/drm/drm_legacy.h     | 2 --
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_legacy.h +3 -0
index 280fbeb846ff..e6bf1a94374b 100644
@@ -81,6 +81,9 @@ int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
 			  int (*)(void *, int, unsigned long, struct drm_buf *),
 			  struct drm_file *);
 
+void drm_legacy_master_rmmaps(struct drm_device *dev,
+			      struct drm_master *master);
+
 #ifdef CONFIG_DRM_VM
 void drm_legacy_vma_flush(struct drm_device *d);
 #else
include/drm/drm_legacy.h +0 -2
index 3e99ab69c122..2182a56ac421 100644
@@ -162,8 +162,6 @@ int drm_legacy_addmap(struct drm_device *d, resource_size_t offset,
 struct drm_local_map *drm_legacy_findmap(struct drm_device *dev, unsigned int token);
 void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
 int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map);
-void drm_legacy_master_rmmaps(struct drm_device *dev,
-			      struct drm_master *master);
 struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
 int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
 
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#3 lore raw

PATCH 3/12 drm/legacy: move map cleanups into drm_bufs.c

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This makes it easier to clean this up later.

---
 drivers/gpu/drm/drm_bufs.c   | 8 ++++++++
 drivers/gpu/drm/drm_drv.c    | 5 +----
 drivers/gpu/drm/drm_legacy.h | 1 +
 3 files changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_bufs.c +8 -0
index e407adb033e7..bfc419ed9d6c 100644
@@ -584,6 +584,14 @@ void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
 	mutex_unlock(&dev->struct_mutex);
 }
 
+void drm_legacy_rmmaps(struct drm_device *dev)
+{
+	struct drm_map_list *r_list, *list_temp;
+
+	list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
+		drm_legacy_rmmap(dev, r_list->map);
+}
+
 /* The rmmap ioctl appears to be unnecessary.  All mappings are torn down on
  * the last close of the device, and this is necessary for cleanup when things
  * exit uncleanly.  Therefore, having userland manually remove mappings seems
drivers/gpu/drm/drm_drv.c +1 -4
index 50d849d1bc6e..15b0fd5adaaf 100644
@@ -1038,8 +1038,6 @@ EXPORT_SYMBOL(drm_dev_register);
  */
 void drm_dev_unregister(struct drm_device *dev)
 {
-	struct drm_map_list *r_list, *list_temp;
-
 	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		drm_lastclose(dev);
 
@@ -1056,8 +1054,7 @@ void drm_dev_unregister(struct drm_device *dev)
 	if (dev->agp)
 		drm_pci_agp_destroy(dev);
 
-	list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
-		drm_legacy_rmmap(dev, r_list->map);
+	drm_legacy_rmmaps(dev);
 
 	remove_compat_control_link(dev);
 	drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
drivers/gpu/drm/drm_legacy.h +1 -0
index e6bf1a94374b..3dc626090fcb 100644
@@ -83,6 +83,7 @@ int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
 
 void drm_legacy_master_rmmaps(struct drm_device *dev,
 			      struct drm_master *master);
+void drm_legacy_rmmaps(struct drm_device *dev);
 
 #ifdef CONFIG_DRM_VM
 void drm_legacy_vma_flush(struct drm_device *d);
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#4 lore raw

PATCH 4/12 drm/radeon: drop unused ati pcigart include.

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

---
 drivers/gpu/drm/radeon/radeon_drv.h | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/radeon/radeon_drv.h +0 -1
index afef2d9fccd8..173deb463414 100644
@@ -35,7 +35,6 @@
 #include <linux/platform_device.h>
 #include <drm/drm_legacy.h>
 
-#include <drm/ati_pcigart.h>
 #include "radeon_family.h"
 
 /* General customization:
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#6 lore raw

PATCH 5/12 drm/legacy: move lock cleanup for master into lock file

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This makes it easier to remove legacy code later.

---
 drivers/gpu/drm/drm_auth.c   | 14 +-------------
 drivers/gpu/drm/drm_legacy.h |  1 +
 drivers/gpu/drm/drm_lock.c   | 16 ++++++++++++++++
 3 files changed, 18 insertions(+), 13 deletions(-)
drivers/gpu/drm/drm_auth.c +1 -13
index 1669c42c40ed..ef8c4353829b 100644
@@ -275,19 +275,7 @@ void drm_master_release(struct drm_file *file_priv)
 		goto out;
 
 	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
-		/*
-		 * Since the master is disappearing, so is the
-		 * possibility to lock.
-		 */
-		mutex_lock(&dev->struct_mutex);
-		if (master->lock.hw_lock) {
-			if (dev->sigdata.lock == master->lock.hw_lock)
-				dev->sigdata.lock = NULL;
-			master->lock.hw_lock = NULL;
-			master->lock.file_priv = NULL;
-			wake_up_interruptible_all(&master->lock.lock_queue);
-		}
-		mutex_unlock(&dev->struct_mutex);
+		drm_legacy_lock_master_cleanup(dev, master);
 	}
 
 	if (dev->master == file_priv->master)
drivers/gpu/drm/drm_legacy.h +1 -0
index 3dc626090fcb..974c2be6bcd5 100644
@@ -126,4 +126,5 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 int drm_legacy_sg_free(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 
+void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
 #endif /* __DRM_LEGACY_H__ */
drivers/gpu/drm/drm_lock.c +16 -0
index 67a1a2ca7174..b37874a15e23 100644
@@ -347,3 +347,19 @@ void drm_legacy_lock_release(struct drm_device *dev, struct file *filp)
 				     _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
 	}
 }
+
+void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master)
+{
+	/*
+	 * Since the master is disappearing, so is the
+	 * possibility to lock.
+	 */	mutex_lock(&dev->struct_mutex);
+	if (master->lock.hw_lock) {
+		if (dev->sigdata.lock == master->lock.hw_lock)
+			dev->sigdata.lock = NULL;
+		master->lock.hw_lock = NULL;
+		master->lock.file_priv = NULL;
+		wake_up_interruptible_all(&master->lock.lock_queue);
+	}
+	mutex_unlock(&dev->struct_mutex);
+}
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#8 lore raw

PATCH 6/12 drm/legacy: move map_hash create/destroy into inlines

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This allows them to be removed later.

---
 drivers/gpu/drm/drm_drv.c    |  7 +++----
 drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_drv.c +3 -4
index 15b0fd5adaaf..18f45f9a955c 100644
@@ -692,10 +692,9 @@ int drm_dev_init(struct drm_device *dev,
 	if (ret)
 		goto err_minors;
 
-	ret = drm_ht_create(&dev->map_hash, 12);
+	ret = drm_legacy_create_map_hash(dev);
 	if (ret)
 		goto err_minors;
-
 	drm_legacy_ctxbitmap_init(dev);
 
 	if (drm_core_check_feature(dev, DRIVER_GEM)) {
@@ -717,7 +716,7 @@ int drm_dev_init(struct drm_device *dev,
 		drm_gem_destroy(dev);
 err_ctxbitmap:
 	drm_legacy_ctxbitmap_cleanup(dev);
-	drm_ht_remove(&dev->map_hash);
+	drm_legacy_remove_map_hash(dev);
 err_minors:
 	drm_minor_free(dev, DRM_MINOR_PRIMARY);
 	drm_minor_free(dev, DRM_MINOR_RENDER);
@@ -792,7 +791,7 @@ void drm_dev_fini(struct drm_device *dev)
 		drm_gem_destroy(dev);
 
 	drm_legacy_ctxbitmap_cleanup(dev);
-	drm_ht_remove(&dev->map_hash);
+	drm_legacy_remove_map_hash(dev);
 	drm_fs_inode_free(dev->anon_inode);
 
 	drm_minor_free(dev, DRM_MINOR_PRIMARY);
drivers/gpu/drm/drm_legacy.h +10 -0
index 974c2be6bcd5..ef419d500e51 100644
@@ -63,6 +63,16 @@ int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
 
 #define DRM_MAP_HASH_OFFSET 0x10000000
 
+static inline int drm_legacy_create_map_hash(struct drm_device *dev)
+{
+	return drm_ht_create(&dev->map_hash, 12);
+}
+
+static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
+{
+	drm_ht_remove(&dev->map_hash);
+}
+
 int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
 			    struct drm_file *file_priv);
 int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#12 lore raw

PATCH 7/12 drm/legacy: move init/destroy of struct members into inlines

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This will allow easier removal later.

---
 drivers/gpu/drm/drm_drv.c    | 10 +++-------
 drivers/gpu/drm/drm_legacy.h | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_drv.c +3 -7
index 18f45f9a955c..e4f36c5ccfcd 100644
@@ -659,20 +659,16 @@ int drm_dev_init(struct drm_device *dev,
 	/* no per-device feature limits by default */
 	dev->driver_features = ~0u;
 
+	drm_legacy_init_members(dev);
 	INIT_LIST_HEAD(&dev->filelist);
 	INIT_LIST_HEAD(&dev->filelist_internal);
 	INIT_LIST_HEAD(&dev->clientlist);
-	INIT_LIST_HEAD(&dev->ctxlist);
-	INIT_LIST_HEAD(&dev->vmalist);
-	INIT_LIST_HEAD(&dev->maplist);
 	INIT_LIST_HEAD(&dev->vblank_event_list);
 
-	spin_lock_init(&dev->buf_lock);
 	spin_lock_init(&dev->event_lock);
 	mutex_init(&dev->struct_mutex);
 	mutex_init(&dev->filelist_mutex);
 	mutex_init(&dev->clientlist_mutex);
-	mutex_init(&dev->ctxlist_mutex);
 	mutex_init(&dev->master_mutex);
 
 	dev->anon_inode = drm_fs_inode_new();
@@ -724,7 +720,7 @@ int drm_dev_init(struct drm_device *dev,
 err_free:
 	put_device(dev->dev);
 	mutex_destroy(&dev->master_mutex);
-	mutex_destroy(&dev->ctxlist_mutex);
+	drm_legacy_destroy_members(dev);
 	mutex_destroy(&dev->clientlist_mutex);
 	mutex_destroy(&dev->filelist_mutex);
 	mutex_destroy(&dev->struct_mutex);
@@ -800,7 +796,7 @@ void drm_dev_fini(struct drm_device *dev)
 	put_device(dev->dev);
 
 	mutex_destroy(&dev->master_mutex);
-	mutex_destroy(&dev->ctxlist_mutex);
+	drm_legacy_destroy_members(dev);
 	mutex_destroy(&dev->clientlist_mutex);
 	mutex_destroy(&dev->filelist_mutex);
 	mutex_destroy(&dev->struct_mutex);
drivers/gpu/drm/drm_legacy.h +14 -0
index ef419d500e51..20c4befc476b 100644
@@ -136,5 +136,19 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 int drm_legacy_sg_free(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 
+static inline void drm_legacy_init_members(struct drm_device *dev)
+{
+	INIT_LIST_HEAD(&dev->ctxlist);
+	INIT_LIST_HEAD(&dev->vmalist);
+	INIT_LIST_HEAD(&dev->maplist);
+	spin_lock_init(&dev->buf_lock);
+	mutex_init(&dev->ctxlist_mutex);
+}
+
+static inline void drm_legacy_destroy_members(struct drm_device *dev)
+{
+	mutex_destroy(&dev->ctxlist_mutex);
+}
+
 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
 #endif /* __DRM_LEGACY_H__ */
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#15 lore raw

PATCH 8/12 drm/legacy: move legacy dev reinit into an inline

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This moves the legacy dev reinit into a legacy inline, also removes some unneeded inlines now.

---
 drivers/gpu/drm/drm_file.c   | 24 ------------------------
 drivers/gpu/drm/drm_legacy.h | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 24 deletions(-)
drivers/gpu/drm/drm_file.c +0 -24
index 9701469a6e93..263fbef73fe5 100644
@@ -425,30 +425,6 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
 	return 0;
 }
 
-static void drm_legacy_dev_reinit(struct drm_device *dev)
-{
-	if (dev->irq_enabled)
-		drm_irq_uninstall(dev);
-
-	mutex_lock(&dev->struct_mutex);
-
-	drm_legacy_agp_clear(dev);
-
-	drm_legacy_sg_cleanup(dev);
-	drm_legacy_vma_flush(dev);
-	drm_legacy_dma_takedown(dev);
-
-	mutex_unlock(&dev->struct_mutex);
-
-	dev->sigdata.lock = NULL;
-
-	dev->context_flag = 0;
-	dev->last_context = 0;
-	dev->if_version = 0;
-
-	DRM_DEBUG("lastclose completed\n");
-}
-
 void drm_lastclose(struct drm_device * dev)
 {
 	DRM_DEBUG("\n");
drivers/gpu/drm/drm_legacy.h +24 -0
index 20c4befc476b..8ee2de06f999 100644
@@ -150,5 +150,29 @@ static inline void drm_legacy_destroy_members(struct drm_device *dev)
 	mutex_destroy(&dev->ctxlist_mutex);
 }
 
+static inline void drm_legacy_dev_reinit(struct drm_device *dev)
+{
+	if (dev->irq_enabled)
+		drm_irq_uninstall(dev);
+
+	mutex_lock(&dev->struct_mutex);
+
+	drm_legacy_agp_clear(dev);
+
+	drm_legacy_sg_cleanup(dev);
+	drm_legacy_vma_flush(dev);
+	drm_legacy_dma_takedown(dev);
+
+	mutex_unlock(&dev->struct_mutex);
+
+	dev->sigdata.lock = NULL;
+
+	dev->context_flag = 0;
+	dev->last_context = 0;
+	dev->if_version = 0;
+
+	DRM_DEBUG("lastclose completed\n");
+}
+
 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
 #endif /* __DRM_LEGACY_H__ */
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#18 lore raw

PATCH 9/12 drm/legacy: don't include any of ati_pcigart in legacy.

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This could probably be done with Kconfig somehow, but I failed in my first 2 minute attempt.

---
 drivers/gpu/drm/ati_pcigart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/ati_pcigart.c +2 -0
index 2362f07fe1fc..0420a28f770a 100644
@@ -5,6 +5,7 @@
  * \author Gareth Hughes <[email protected]>
  */
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 /*
  * Created: Wed Dec 13 21:52:19 2000 by [email protected]
  *
@@ -203,3 +204,4 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
 	return ret;
 }
 EXPORT_SYMBOL(drm_ati_pcigart_init);
+#endif
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#21 lore raw

PATCH 10/12 drm: allow removal of legacy codepaths (v4)

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

If you don't want the legacy drivers, then lets get rid of all the legacy codepaths from the core module.

This drop the size of drm.ko for me by about 10%.

 380515    7422    4192  392129   5fbc1 ../../drm-next-build/drivers/gpu/drm/drm.ko
 351736	   7298	   4192	 363226	  58ada	../../drm-next-build/drivers/gpu/drm/drm.ko

v2: drop drm_lock as well, fix some DMA->DRM typos
v3: avoid ifdefs in mainline code
v4: rework ioctl defs

---
 drivers/gpu/drm/Makefile        |  7 ++---
 drivers/gpu/drm/drm_internal.h  |  2 ++
 drivers/gpu/drm/drm_ioc32.c     | 13 +++++++-
 drivers/gpu/drm/drm_ioctl.c     | 55 +++++++++++++++++++--------------
 drivers/gpu/drm/drm_irq.c       |  2 ++
 drivers/gpu/drm/drm_legacy.h    | 42 +++++++++++++++++++++++--
 drivers/gpu/drm/drm_vm.c        |  2 ++
 drivers/gpu/drm/nouveau/Kconfig |  1 +
 8 files changed, 93 insertions(+), 31 deletions(-)
drivers/gpu/drm/Makefile +3 -4
index 7ebae3d45505..340e075f6e06 100644
@@ -3,11 +3,9 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
-drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
-		drm_context.o drm_dma.o \
+drm-y       :=	drm_auth.o drm_cache.o \
 		drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \
-		drm_lock.o drm_memory.o drm_drv.o \
-		drm_scatter.o drm_pci.o \
+		drm_memory.o drm_drv.o drm_pci.o \
 		drm_sysfs.o drm_hashtab.o drm_mm.o \
 		drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \
 		drm_encoder_slave.o \
@@ -21,6 +19,7 @@ drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_syncobj.o drm_lease.o drm_writeback.o drm_client.o \
 		drm_atomic_uapi.o
 
+drm-$(CONFIG_DRM_LEGACY) += drm_bufs.o drm_context.o drm_dma.o drm_scatter.o drm_lock.o
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
 drm-$(CONFIG_DRM_VM) += drm_vm.o
 drm-$(CONFIG_COMPAT) += drm_ioc32.o
drivers/gpu/drm/drm_internal.h +2 -0
index d9a483a5fce0..e19ac7ca602d 100644
@@ -71,8 +71,10 @@ int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
 /* drm_irq.c */
 
 /* IOCTLS */
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 int drm_legacy_irq_control(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv);
+#endif
 
 int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *filp);
drivers/gpu/drm/drm_ioc32.c +12 -1
index 0e3043e08c69..374b372da58a 100644
@@ -156,6 +156,7 @@ static int compat_drm_setunique(struct file *file, unsigned int cmd,
 	return -EINVAL;
 }
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 typedef struct drm_map32 {
 	u32 offset;		/* Requested physical address (0 for SAREA) */
 	u32 size;		/* Requested physical size (bytes) */
@@ -239,6 +240,7 @@ static int compat_drm_rmmap(struct file *file, unsigned int cmd,
 	map.handle = compat_ptr(handle);
 	return drm_ioctl_kernel(file, drm_legacy_rmmap_ioctl, &map, DRM_AUTH);
 }
+#endif
 
 typedef struct drm_client32 {
 	int idx;	/* Which client desired? */
@@ -301,6 +303,7 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 typedef struct drm_buf_desc32 {
 	int count;		 /* Number of buffers of this size */
 	int size;		 /* Size in bytes */
@@ -604,6 +607,7 @@ static int compat_drm_dma(struct file *file, unsigned int cmd,
 
 	return 0;
 }
+#endif
 
 #if IS_ENABLED(CONFIG_AGP)
 typedef struct drm_agp_mode32 {
@@ -748,6 +752,7 @@ static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
 }
 #endif /* CONFIG_AGP */
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 typedef struct drm_scatter_gather32 {
 	u32 size;	/**< In bytes -- will round to page boundary */
 	u32 handle;	/**< Used for mapping / unmapping */
@@ -788,7 +793,7 @@ static int compat_drm_sg_free(struct file *file, unsigned int cmd,
 	return drm_ioctl_kernel(file, drm_legacy_sg_free, &request,
 				DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
 }
-
+#endif
 #if defined(CONFIG_X86)
 typedef struct drm_update_draw32 {
 	drm_drawable_t handle;
@@ -903,10 +908,13 @@ static struct {
 #define DRM_IOCTL32_DEF(n, f) [DRM_IOCTL_NR(n##32)] = {.fn = f, .name = #n}
 	DRM_IOCTL32_DEF(DRM_IOCTL_VERSION, compat_drm_version),
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_UNIQUE, compat_drm_getunique),
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_MAP, compat_drm_getmap),
+#endif
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_CLIENT, compat_drm_getclient),
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_STATS, compat_drm_getstats),
 	DRM_IOCTL32_DEF(DRM_IOCTL_SET_UNIQUE, compat_drm_setunique),
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	DRM_IOCTL32_DEF(DRM_IOCTL_ADD_MAP, compat_drm_addmap),
 	DRM_IOCTL32_DEF(DRM_IOCTL_ADD_BUFS, compat_drm_addbufs),
 	DRM_IOCTL32_DEF(DRM_IOCTL_MARK_BUFS, compat_drm_markbufs),
@@ -918,6 +926,7 @@ static struct {
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_SAREA_CTX, compat_drm_getsareactx),
 	DRM_IOCTL32_DEF(DRM_IOCTL_RES_CTX, compat_drm_resctx),
 	DRM_IOCTL32_DEF(DRM_IOCTL_DMA, compat_drm_dma),
+#endif
 #if IS_ENABLED(CONFIG_AGP)
 	DRM_IOCTL32_DEF(DRM_IOCTL_AGP_ENABLE, compat_drm_agp_enable),
 	DRM_IOCTL32_DEF(DRM_IOCTL_AGP_INFO, compat_drm_agp_info),
@@ -926,8 +935,10 @@ static struct {
 	DRM_IOCTL32_DEF(DRM_IOCTL_AGP_BIND, compat_drm_agp_bind),
 	DRM_IOCTL32_DEF(DRM_IOCTL_AGP_UNBIND, compat_drm_agp_unbind),
 #endif
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	DRM_IOCTL32_DEF(DRM_IOCTL_SG_ALLOC, compat_drm_sg_alloc),
 	DRM_IOCTL32_DEF(DRM_IOCTL_SG_FREE, compat_drm_sg_free),
+#endif
 #if defined(CONFIG_X86) || defined(CONFIG_IA64)
 	DRM_IOCTL32_DEF(DRM_IOCTL_UPDATE_DRAW, compat_drm_update_draw),
 #endif
drivers/gpu/drm/drm_ioctl.c +31 -24

91 lines not on this page · raw message

drivers/gpu/drm/drm_irq.c +2 -0
index 9bd8908d5fd8..02f38cc9f468 100644
@@ -213,6 +213,7 @@ int drm_irq_uninstall(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_irq_uninstall);
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 int drm_legacy_irq_control(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv)
 {
@@ -253,3 +254,4 @@ int drm_legacy_irq_control(struct drm_device *dev, void *data,
 		return -EINVAL;
 	}
 }
+#endif
drivers/gpu/drm/drm_legacy.h +40 -2

108 lines not on this page · raw message

drivers/gpu/drm/drm_vm.c +2 -0
index 8987501f53b2..10cf83d569e1 100644
@@ -646,6 +646,7 @@ int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma)
 }
 EXPORT_SYMBOL(drm_legacy_mmap);
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_vma_flush(struct drm_device *dev)
 {
 	struct drm_vma_entry *vma, *vma_temp;
@@ -656,3 +657,4 @@ void drm_legacy_vma_flush(struct drm_device *dev)
 		kfree(vma);
 	}
 }
+#endif
drivers/gpu/drm/nouveau/Kconfig +1 -0
index 3ae7a4cfc6bb..cbcf7d2c089d 100644
@@ -23,6 +23,7 @@ config DRM_NOUVEAU
 config NOUVEAU_LEGACY_CTX_SUPPORT
 	bool "Nouveau legacy context support"
 	select DRM_VM
+	select DRM_LEGACY
 	default y
 	help
 	  There was a version of the nouveau DDX that relied on legacy
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#23 lore raw

PATCH 11/12 drm/legacy: place all drm legacy members under DRM_LEGACY.

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This places a bunch of the legacy members of drm_device into only being there when legacy is enabled.

---
 drivers/gpu/drm/drm_legacy.h | 20 ++++++++++++++++++++
 include/drm/drm_device.h     |  3 ++-
 2 files changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_legacy.h +20 -0
index 3c05452a7137..4200e6bd3778 100644
@@ -72,6 +72,7 @@ int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
 
 #define DRM_MAP_HASH_OFFSET 0x10000000
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 static inline int drm_legacy_create_map_hash(struct drm_device *dev)
 {
 	return drm_ht_create(&dev->map_hash, 12);
@@ -81,6 +82,14 @@ static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
 {
 	drm_ht_remove(&dev->map_hash);
 }
+#else
+static inline int drm_legacy_create_map_hash(struct drm_device *dev)
+{
+	return 0;
+}
+
+static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
+#endif
 
 
 #if IS_ENABLED(CONFIG_DRM_LEGACY)
@@ -174,6 +183,8 @@ int drm_legacy_sg_free(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 #endif
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
+
 static inline void drm_legacy_init_members(struct drm_device *dev)
 {
 	INIT_LIST_HEAD(&dev->ctxlist);
@@ -211,6 +222,15 @@ static inline void drm_legacy_dev_reinit(struct drm_device *dev)
 
 	DRM_DEBUG("lastclose completed\n");
 }
+#else
+static inline void drm_legacy_init_members(struct drm_device *dev) {}
+static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
+static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
+#endif
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
+#else
+static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
+#endif
 #endif /* __DRM_LEGACY_H__ */
include/drm/drm_device.h +2 -1
index d5e092dccf3e..7f9ef709b2b6 100644
@@ -306,7 +306,7 @@ struct drm_device {
 
 	/* Everything below here is for legacy driver, never use! */
 	/* private: */
-
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	/* Context handle management - linked list of context handles */
 	struct list_head ctxlist;
 
@@ -353,6 +353,7 @@ struct drm_device {
 
 	/* Scatter gather memory */
 	struct drm_sg_mem *sg;
+#endif
 };
 
 #endif
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#25 lore raw

PATCH 12/12 drm/legacy: remove some legacy lock struct members

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

This removes these unless legacy is enabled.

The lock count init is unneeded anyways since it's kzalloc.

---
 drivers/gpu/drm/drm_auth.c   |  4 ++--
 drivers/gpu/drm/drm_file.c   |  1 -
 drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
 include/drm/drm_auth.h       |  2 ++
 include/drm/drm_file.h       |  2 ++
 5 files changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_auth.c +2 -2
index ef8c4353829b..c3df628bc048 100644
@@ -103,8 +103,8 @@ struct drm_master *drm_master_create(struct drm_device *dev)
 		return NULL;
 
 	kref_init(&master->refcount);
-	spin_lock_init(&master->lock.spinlock);
-	init_waitqueue_head(&master->lock.lock_queue);
+
+	drm_master_legacy_init(master);
 	idr_init(&master->magic_map);
 	master->dev = dev;
 
drivers/gpu/drm/drm_file.c +0 -1
index 263fbef73fe5..233f114d2186 100644
@@ -128,7 +128,6 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor)
 
 	/* for compatibility root is always authenticated */
 	file->authenticated = capable(CAP_SYS_ADMIN);
-	file->lock_count = 0;
 
 	INIT_LIST_HEAD(&file->lhead);
 	INIT_LIST_HEAD(&file->fbs);
drivers/gpu/drm/drm_legacy.h +10 -0
index 4200e6bd3778..5d97c06d78e4 100644
@@ -233,4 +233,14 @@ void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *m
 #else
 static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
 #endif
+
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
+static inline void drm_master_legacy_init(struct drm_master *master)
+{
+	spin_lock_init(&master->lock.spinlock);
+	init_waitqueue_head(&master->lock.lock_queue);
+}
+#else
+static inline void drm_master_legacy_init(struct drm_master *master) {}
+#endif
 #endif /* __DRM_LEGACY_H__ */
include/drm/drm_auth.h +2 -0
index 86bff9841b54..722199f434f0 100644
@@ -80,7 +80,9 @@ struct drm_master {
 	 * &drm_device.master_mutex.
 	 */
 	struct idr magic_map;
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	struct drm_lock_data lock;
+#endif
 	void *driver_priv;
 
 	/* Tree of display resource leases, each of which is a drm_master struct
include/drm/drm_file.h +2 -0
index 6710b612e2f6..67af60bb527a 100644
@@ -335,7 +335,9 @@ struct drm_file {
 	struct drm_prime_file_private prime;
 
 	/* private: */
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	unsigned long lock_count; /* DRI1 legacy lock count */
+#endif
 };
 
 /**
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 4/12
#5 lore raw

Re: [PATCH 04/12] drm/radeon: drop unused ati pcigart include.

In reply to Dave Airlie

Am 23.04.19 um 04:00 schrieb Dave Airlie:

Quoted 3 lines

From: Dave Airlie <[email protected]>

Quoted 9 lines
---
  drivers/gpu/drm/radeon/radeon_drv.h | 1 -
  1 file changed, 1 deletion(-)
drivers/gpu/drm/radeon/radeon_drv.h +0 -0
index afef2d9fccd8..173deb463414 100644

drivers/gpu/drm/radeon/radeon_drv.h line 40

Quoted 7 lines
drivers/gpu/drm/radeon/radeon_drv.h +0 -1
@@ -35,7 +35,6 @@
  #include <linux/platform_device.h>
  #include <drm/drm_legacy.h>
 
-#include <drm/ati_pcigart.h>
  #include "radeon_family.h"
 
  /* General customization:

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

Re: [PATCH 05/12] drm/legacy: move lock cleanup for master into lock file

In reply to Dave Airlie
Quoted 16 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This makes it easier to remove legacy code later.

---
 drivers/gpu/drm/drm_auth.c   | 14 +-------------
 drivers/gpu/drm/drm_legacy.h |  1 +
 drivers/gpu/drm/drm_lock.c   | 16 ++++++++++++++++
 3 files changed, 18 insertions(+), 13 deletions(-)
drivers/gpu/drm/drm_auth.c +0 -0
index 1669c42c40ed..ef8c4353829b 100644

drivers/gpu/drm/drm_auth.c void drm_master_release(struct drm_file *file_priv) · line 277

Quoted 3 lines
drivers/gpu/drm/drm_auth.c +0 -0
@@ -275,19 +275,7 @@ void drm_master_release(struct drm_file *file_priv)
 		goto out;
 
 	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {

Bikeshed (aka feel free to ignore): I'd also move the DRIVER_LEGACY check into the helper, the drm_legacy_ function prefix is kinda clear enough.

Also, drop the {} to appease checkpatch.

Whatever, I like so Reviewed-by: Daniel Vetter <[email protected]>

Quoted 58 lines
drivers/gpu/drm/drm_auth.c +1 -13
-		/*
-		 * Since the master is disappearing, so is the
-		 * possibility to lock.
-		 */
-		mutex_lock(&dev->struct_mutex);
-		if (master->lock.hw_lock) {
-			if (dev->sigdata.lock == master->lock.hw_lock)
-				dev->sigdata.lock = NULL;
-			master->lock.hw_lock = NULL;
-			master->lock.file_priv = NULL;
-			wake_up_interruptible_all(&master->lock.lock_queue);
-		}
-		mutex_unlock(&dev->struct_mutex);
+		drm_legacy_lock_master_cleanup(dev, master);
 	}
 
 	if (dev->master == file_priv->master)
drivers/gpu/drm/drm_legacy.h +1 -0
index 3dc626090fcb..974c2be6bcd5 100644
@@ -126,4 +126,5 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 int drm_legacy_sg_free(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 
+void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
 #endif /* __DRM_LEGACY_H__ */
drivers/gpu/drm/drm_lock.c +16 -0
index 67a1a2ca7174..b37874a15e23 100644
@@ -347,3 +347,19 @@ void drm_legacy_lock_release(struct drm_device *dev, struct file *filp)
 				     _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
 	}
 }
+
+void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master)
+{
+	/*
+	 * Since the master is disappearing, so is the
+	 * possibility to lock.
+	 */	mutex_lock(&dev->struct_mutex);
+	if (master->lock.hw_lock) {
+		if (dev->sigdata.lock == master->lock.hw_lock)
+			dev->sigdata.lock = NULL;
+		master->lock.hw_lock = NULL;
+		master->lock.file_priv = NULL;
+		wake_up_interruptible_all(&master->lock.lock_queue);
+	}
+	mutex_unlock(&dev->struct_mutex);
+}
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

Re: [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines

In reply to Dave Airlie
Quoted 5 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This allows them to be removed later.

vmwgfx still uses these? Is the plan to burn that down :-)

Probably easier to add a todo.rst item to clean that up than do it yourself.
-Daniel

Quoted 67 lines
---
 drivers/gpu/drm/drm_drv.c    |  7 +++----
 drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_drv.c +3 -4
index 15b0fd5adaaf..18f45f9a955c 100644
@@ -692,10 +692,9 @@ int drm_dev_init(struct drm_device *dev,
 	if (ret)
 		goto err_minors;
 
-	ret = drm_ht_create(&dev->map_hash, 12);
+	ret = drm_legacy_create_map_hash(dev);
 	if (ret)
 		goto err_minors;
-
 	drm_legacy_ctxbitmap_init(dev);
 
 	if (drm_core_check_feature(dev, DRIVER_GEM)) {
@@ -717,7 +716,7 @@ int drm_dev_init(struct drm_device *dev,
 		drm_gem_destroy(dev);
 err_ctxbitmap:
 	drm_legacy_ctxbitmap_cleanup(dev);
-	drm_ht_remove(&dev->map_hash);
+	drm_legacy_remove_map_hash(dev);
 err_minors:
 	drm_minor_free(dev, DRM_MINOR_PRIMARY);
 	drm_minor_free(dev, DRM_MINOR_RENDER);
@@ -792,7 +791,7 @@ void drm_dev_fini(struct drm_device *dev)
 		drm_gem_destroy(dev);
 
 	drm_legacy_ctxbitmap_cleanup(dev);
-	drm_ht_remove(&dev->map_hash);
+	drm_legacy_remove_map_hash(dev);
 	drm_fs_inode_free(dev->anon_inode);
 
 	drm_minor_free(dev, DRM_MINOR_PRIMARY);
drivers/gpu/drm/drm_legacy.h +10 -0
index 974c2be6bcd5..ef419d500e51 100644
@@ -63,6 +63,16 @@ int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
 
 #define DRM_MAP_HASH_OFFSET 0x10000000
 
+static inline int drm_legacy_create_map_hash(struct drm_device *dev)
+{
+	return drm_ht_create(&dev->map_hash, 12);
+}
+
+static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
+{
+	drm_ht_remove(&dev->map_hash);
+}
+
 int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
 			    struct drm_file *file_priv);
 int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

Re: [PATCH 07/12] drm/legacy: move init/destroy of struct members into inlines

In reply to Dave Airlie
Quoted 65 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This will allow easier removal later.

---
 drivers/gpu/drm/drm_drv.c    | 10 +++-------
 drivers/gpu/drm/drm_legacy.h | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_drv.c +3 -7
index 18f45f9a955c..e4f36c5ccfcd 100644
@@ -659,20 +659,16 @@ int drm_dev_init(struct drm_device *dev,
 	/* no per-device feature limits by default */
 	dev->driver_features = ~0u;
 
+	drm_legacy_init_members(dev);
 	INIT_LIST_HEAD(&dev->filelist);
 	INIT_LIST_HEAD(&dev->filelist_internal);
 	INIT_LIST_HEAD(&dev->clientlist);
-	INIT_LIST_HEAD(&dev->ctxlist);
-	INIT_LIST_HEAD(&dev->vmalist);
-	INIT_LIST_HEAD(&dev->maplist);
 	INIT_LIST_HEAD(&dev->vblank_event_list);
 
-	spin_lock_init(&dev->buf_lock);
 	spin_lock_init(&dev->event_lock);
 	mutex_init(&dev->struct_mutex);
 	mutex_init(&dev->filelist_mutex);
 	mutex_init(&dev->clientlist_mutex);
-	mutex_init(&dev->ctxlist_mutex);
 	mutex_init(&dev->master_mutex);
 
 	dev->anon_inode = drm_fs_inode_new();
@@ -724,7 +720,7 @@ int drm_dev_init(struct drm_device *dev,
 err_free:
 	put_device(dev->dev);
 	mutex_destroy(&dev->master_mutex);
-	mutex_destroy(&dev->ctxlist_mutex);
+	drm_legacy_destroy_members(dev);
 	mutex_destroy(&dev->clientlist_mutex);
 	mutex_destroy(&dev->filelist_mutex);
 	mutex_destroy(&dev->struct_mutex);
@@ -800,7 +796,7 @@ void drm_dev_fini(struct drm_device *dev)
 	put_device(dev->dev);
 
 	mutex_destroy(&dev->master_mutex);
-	mutex_destroy(&dev->ctxlist_mutex);
+	drm_legacy_destroy_members(dev);
 	mutex_destroy(&dev->clientlist_mutex);
 	mutex_destroy(&dev->filelist_mutex);
 	mutex_destroy(&dev->struct_mutex);
drivers/gpu/drm/drm_legacy.h +3 -0
index ef419d500e51..20c4befc476b 100644
@@ -136,5 +136,19 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 int drm_legacy_sg_free(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 
+static inline void drm_legacy_init_members(struct drm_device *dev)
+{
+	INIT_LIST_HEAD(&dev->ctxlist);

drivers/gpu/drm/drm_legacy.h int drm_legacy_sg_alloc(struct drm_device *dev, void *data, · line 151

Quoted 10 lines
drivers/gpu/drm/drm_legacy.h +10 -0
+	INIT_LIST_HEAD(&dev->vmalist);
+	INIT_LIST_HEAD(&dev->maplist);
+	spin_lock_init(&dev->buf_lock);
+	mutex_init(&dev->ctxlist_mutex);
+}
+
+static inline void drm_legacy_destroy_members(struct drm_device *dev)
+{
+	mutex_destroy(&dev->ctxlist_mutex);
+}

I think with the other inline functions you stuff into drm_legacy.h it'd justification enough to create a drm_legacy_misc.c. Not drm_legacy.c because then you can't include other files into drm_legacy.ko because Kbuild is silly :-)

With that: Reviewed-by: Daniel Vetter <[email protected]>

Quoted 10 lines
drivers/gpu/drm/drm_legacy.h +1 -0
+
 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
 #endif /* __DRM_LEGACY_H__ */
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 8/12
#16 lore raw

Re: [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline

In reply to Dave Airlie
Quoted 51 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This moves the legacy dev reinit into a legacy inline, also removes some unneeded inlines now.

---
 drivers/gpu/drm/drm_file.c   | 24 ------------------------
 drivers/gpu/drm/drm_legacy.h | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 24 deletions(-)
drivers/gpu/drm/drm_file.c +0 -24
index 9701469a6e93..263fbef73fe5 100644
@@ -425,30 +425,6 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
 	return 0;
 }
 
-static void drm_legacy_dev_reinit(struct drm_device *dev)
-{
-	if (dev->irq_enabled)
-		drm_irq_uninstall(dev);
-
-	mutex_lock(&dev->struct_mutex);
-
-	drm_legacy_agp_clear(dev);
-
-	drm_legacy_sg_cleanup(dev);
-	drm_legacy_vma_flush(dev);
-	drm_legacy_dma_takedown(dev);
-
-	mutex_unlock(&dev->struct_mutex);
-
-	dev->sigdata.lock = NULL;
-
-	dev->context_flag = 0;
-	dev->last_context = 0;
-	dev->if_version = 0;
-
-	DRM_DEBUG("lastclose completed\n");
-}
-
 void drm_lastclose(struct drm_device * dev)
 {
 	DRM_DEBUG("\n");
drivers/gpu/drm/drm_legacy.h +0 -0
index 20c4befc476b..8ee2de06f999 100644

drivers/gpu/drm/drm_legacy.h static inline void drm_legacy_destroy_members(struct drm_device *dev) · line 153

Quoted 4 lines
drivers/gpu/drm/drm_legacy.h +1 -0
@@ -150,5 +150,29 @@ static inline void drm_legacy_destroy_members(struct drm_device *dev)
 	mutex_destroy(&dev->ctxlist_mutex);
 }
 
+static inline void drm_legacy_dev_reinit(struct drm_device *dev)

Like previous patch, stuff it into drm_legacy_misc.c or something like that. With that:

Quoted 32 lines
drivers/gpu/drm/drm_legacy.h +23 -0
+{
+	if (dev->irq_enabled)
+		drm_irq_uninstall(dev);
+
+	mutex_lock(&dev->struct_mutex);
+
+	drm_legacy_agp_clear(dev);
+
+	drm_legacy_sg_cleanup(dev);
+	drm_legacy_vma_flush(dev);
+	drm_legacy_dma_takedown(dev);
+
+	mutex_unlock(&dev->struct_mutex);
+
+	dev->sigdata.lock = NULL;
+
+	dev->context_flag = 0;
+	dev->last_context = 0;
+	dev->if_version = 0;
+
+	DRM_DEBUG("lastclose completed\n");
+}
+
 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
 #endif /* __DRM_LEGACY_H__ */
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 9/12
#19 lore raw

Re: [PATCH 09/12] drm/legacy: don't include any of ati_pcigart in legacy.

In reply to Dave Airlie
Quoted 6 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This could probably be done with Kconfig somehow, but I failed in my first 2 minute attempt.

config DRM_ATI_PCIGART

	bool
	default y
	depens on PCI && DRM_LEGACY

Should give you a nice hidden Kconfig symbol that dtrt and can be used in the Makefile. With that

Other option (no idea it's preferred):

config DRM_ATI_PCIGART
bool

and then in

config DRM_LEGACY
select DRM_ATI_PCIGART if PCI

Either should work I think, the latter more closely follows what we do already.
-Daniel

Quoted 28 lines
---
 drivers/gpu/drm/ati_pcigart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/ati_pcigart.c +2 -0
index 2362f07fe1fc..0420a28f770a 100644
@@ -5,6 +5,7 @@
  * \author Gareth Hughes <[email protected]>
  */
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 /*
  * Created: Wed Dec 13 21:52:19 2000 by [email protected]
  *
@@ -203,3 +204,4 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
 	return ret;
 }
 EXPORT_SYMBOL(drm_ati_pcigart_init);
+#endif
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 10/12
#22 lore raw

Re: [PATCH 10/12] drm: allow removal of legacy codepaths (v4)

In reply to Dave Airlie
Quoted 6 lines · Dave Airlie

From: Dave Airlie <[email protected]>

If you don't want the legacy drivers, then lets get rid of all the legacy codepaths from the core module.

This drop the size of drm.ko for me by about 10%.

Quoted 8 lines
 380515    7422    4192  392129   5fbc1 ../../drm-next-build/drivers/gpu/drm/drm.ko
 351736	   7298	   4192	 363226	  58ada	../../drm-next-build/drivers/gpu/drm/drm.ko

v2: drop drm_lock as well, fix some DMA->DRM typos
v3: avoid ifdefs in mainline code
v4: rework ioctl defs

Bikeshed looks appealing enough now I think :-) And the DRM_LEGACY_IOCTL_DEF is a neat trick.

Quoted 407 lines
---
 drivers/gpu/drm/Makefile        |  7 ++---
 drivers/gpu/drm/drm_internal.h  |  2 ++
 drivers/gpu/drm/drm_ioc32.c     | 13 +++++++-
 drivers/gpu/drm/drm_ioctl.c     | 55 +++++++++++++++++++--------------
 drivers/gpu/drm/drm_irq.c       |  2 ++
 drivers/gpu/drm/drm_legacy.h    | 42 +++++++++++++++++++++++--
 drivers/gpu/drm/drm_vm.c        |  2 ++
 drivers/gpu/drm/nouveau/Kconfig |  1 +
 8 files changed, 93 insertions(+), 31 deletions(-)
drivers/gpu/drm/Makefile +3 -4
index 7ebae3d45505..340e075f6e06 100644
@@ -3,11 +3,9 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
-drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
-		drm_context.o drm_dma.o \
+drm-y       :=	drm_auth.o drm_cache.o \
 		drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \
-		drm_lock.o drm_memory.o drm_drv.o \
-		drm_scatter.o drm_pci.o \
+		drm_memory.o drm_drv.o drm_pci.o \
 		drm_sysfs.o drm_hashtab.o drm_mm.o \
 		drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \
 		drm_encoder_slave.o \
@@ -21,6 +19,7 @@ drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_syncobj.o drm_lease.o drm_writeback.o drm_client.o \
 		drm_atomic_uapi.o
 
+drm-$(CONFIG_DRM_LEGACY) += drm_bufs.o drm_context.o drm_dma.o drm_scatter.o drm_lock.o
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
 drm-$(CONFIG_DRM_VM) += drm_vm.o
 drm-$(CONFIG_COMPAT) += drm_ioc32.o
drivers/gpu/drm/drm_internal.h +2 -0
index d9a483a5fce0..e19ac7ca602d 100644
@@ -71,8 +71,10 @@ int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
 /* drm_irq.c */
 
 /* IOCTLS */
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 int drm_legacy_irq_control(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv);
+#endif
 
 int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *filp);
drivers/gpu/drm/drm_ioc32.c +12 -1
index 0e3043e08c69..374b372da58a 100644
@@ -156,6 +156,7 @@ static int compat_drm_setunique(struct file *file, unsigned int cmd,
 	return -EINVAL;
 }
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 typedef struct drm_map32 {
 	u32 offset;		/* Requested physical address (0 for SAREA) */
 	u32 size;		/* Requested physical size (bytes) */
@@ -239,6 +240,7 @@ static int compat_drm_rmmap(struct file *file, unsigned int cmd,
 	map.handle = compat_ptr(handle);
 	return drm_ioctl_kernel(file, drm_legacy_rmmap_ioctl, &map, DRM_AUTH);
 }
+#endif
 
 typedef struct drm_client32 {
 	int idx;	/* Which client desired? */
@@ -301,6 +303,7 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 typedef struct drm_buf_desc32 {
 	int count;		 /* Number of buffers of this size */
 	int size;		 /* Size in bytes */
@@ -604,6 +607,7 @@ static int compat_drm_dma(struct file *file, unsigned int cmd,
 
 	return 0;
 }
+#endif
 
 #if IS_ENABLED(CONFIG_AGP)
 typedef struct drm_agp_mode32 {
@@ -748,6 +752,7 @@ static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
 }
 #endif /* CONFIG_AGP */
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 typedef struct drm_scatter_gather32 {
 	u32 size;	/**< In bytes -- will round to page boundary */
 	u32 handle;	/**< Used for mapping / unmapping */
@@ -788,7 +793,7 @@ static int compat_drm_sg_free(struct file *file, unsigned int cmd,
 	return drm_ioctl_kernel(file, drm_legacy_sg_free, &request,
 				DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
 }
-
+#endif
 #if defined(CONFIG_X86)
 typedef struct drm_update_draw32 {
 	drm_drawable_t handle;
@@ -903,10 +908,13 @@ static struct {
 #define DRM_IOCTL32_DEF(n, f) [DRM_IOCTL_NR(n##32)] = {.fn = f, .name = #n}
 	DRM_IOCTL32_DEF(DRM_IOCTL_VERSION, compat_drm_version),
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_UNIQUE, compat_drm_getunique),
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_MAP, compat_drm_getmap),
+#endif
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_CLIENT, compat_drm_getclient),
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_STATS, compat_drm_getstats),
 	DRM_IOCTL32_DEF(DRM_IOCTL_SET_UNIQUE, compat_drm_setunique),
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	DRM_IOCTL32_DEF(DRM_IOCTL_ADD_MAP, compat_drm_addmap),
 	DRM_IOCTL32_DEF(DRM_IOCTL_ADD_BUFS, compat_drm_addbufs),
 	DRM_IOCTL32_DEF(DRM_IOCTL_MARK_BUFS, compat_drm_markbufs),
@@ -918,6 +926,7 @@ static struct {
 	DRM_IOCTL32_DEF(DRM_IOCTL_GET_SAREA_CTX, compat_drm_getsareactx),
 	DRM_IOCTL32_DEF(DRM_IOCTL_RES_CTX, compat_drm_resctx),
 	DRM_IOCTL32_DEF(DRM_IOCTL_DMA, compat_drm_dma),
+#endif
 #if IS_ENABLED(CONFIG_AGP)
 	DRM_IOCTL32_DEF(DRM_IOCTL_AGP_ENABLE, compat_drm_agp_enable),
 	DRM_IOCTL32_DEF(DRM_IOCTL_AGP_INFO, compat_drm_agp_info),
@@ -926,8 +935,10 @@ static struct {
 	DRM_IOCTL32_DEF(DRM_IOCTL_AGP_BIND, compat_drm_agp_bind),
 	DRM_IOCTL32_DEF(DRM_IOCTL_AGP_UNBIND, compat_drm_agp_unbind),
 #endif
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	DRM_IOCTL32_DEF(DRM_IOCTL_SG_ALLOC, compat_drm_sg_alloc),
 	DRM_IOCTL32_DEF(DRM_IOCTL_SG_FREE, compat_drm_sg_free),
+#endif
 #if defined(CONFIG_X86) || defined(CONFIG_IA64)
 	DRM_IOCTL32_DEF(DRM_IOCTL_UPDATE_DRAW, compat_drm_update_draw),
 #endif
drivers/gpu/drm/drm_ioctl.c +31 -24
index ce8a70875bd5..5878145077d0 100644
@@ -553,6 +553,12 @@ EXPORT_SYMBOL(drm_ioctl_permit);
 		.name = #ioctl			\
 	}
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
+#define DRM_LEGACY_IOCTL_DEF(ioctl, _func, _flags)  DRM_IOCTL_DEF(ioctl, _func, _flags)
+#else
+#define DRM_LEGACY_IOCTL_DEF(ioctl, _func, _flags) DRM_IOCTL_DEF(ioctl, drm_invalid_op, _flags)
+#endif
+
 /* Ioctl table */
 static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version,
@@ -560,7 +566,9 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, DRM_UNLOCKED),
+
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, DRM_UNLOCKED),
+
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_CAP, drm_getcap, DRM_UNLOCKED|DRM_RENDER_ALLOW),
@@ -572,39 +580,38 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_UNLOCKED|DRM_MASTER),
 
-	DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_legacy_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_legacy_rmmap_ioctl, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_legacy_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_legacy_rmmap_ioctl, DRM_AUTH),
 
-	DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_legacy_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_legacy_getsareactx, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_legacy_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_legacy_getsareactx, DRM_AUTH),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_SET_MASTER, drm_setmaster_ioctl, DRM_UNLOCKED|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_DROP_MASTER, drm_dropmaster_ioctl, DRM_UNLOCKED|DRM_ROOT_ONLY),
 
-	DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_legacy_addctx, DRM_AUTH|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_legacy_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_legacy_getctx, DRM_AUTH),
-	DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_legacy_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_legacy_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_legacy_resctx, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_legacy_addctx, DRM_AUTH|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_legacy_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_legacy_getctx, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_legacy_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_legacy_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_legacy_resctx, DRM_AUTH),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
-	DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_legacy_lock, DRM_AUTH),
-	DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_legacy_unlock, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_LOCK, drm_legacy_lock, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_legacy_unlock, DRM_AUTH),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
 
-	DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_legacy_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_legacy_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_legacy_infobufs, DRM_AUTH),
-	DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_legacy_mapbufs, DRM_AUTH),
-	DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_legacy_freebufs, DRM_AUTH),
-	DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_legacy_dma_ioctl, DRM_AUTH),
-
-	DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_legacy_irq_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_legacy_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_legacy_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_legacy_infobufs, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_legacy_mapbufs, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_legacy_freebufs, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_DMA, drm_legacy_dma_ioctl, DRM_AUTH),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_legacy_irq_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
 #if IS_ENABLED(CONFIG_AGP)
 	DRM_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_agp_acquire_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
@@ -617,8 +624,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 #endif
 
-	DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_legacy_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_legacy_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_legacy_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_legacy_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED),
 
drivers/gpu/drm/drm_irq.c +2 -0
index 9bd8908d5fd8..02f38cc9f468 100644
@@ -213,6 +213,7 @@ int drm_irq_uninstall(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_irq_uninstall);
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 int drm_legacy_irq_control(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv)
 {
@@ -253,3 +254,4 @@ int drm_legacy_irq_control(struct drm_device *dev, void *data,
 		return -EINVAL;
 	}
 }
+#endif
drivers/gpu/drm/drm_legacy.h +40 -2
index 8ee2de06f999..3c05452a7137 100644
@@ -42,11 +42,19 @@ struct drm_file;
 #define DRM_KERNEL_CONTEXT		0
 #define DRM_RESERVED_CONTEXTS		1
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_ctxbitmap_init(struct drm_device *dev);
 void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
-void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
 void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
+#else
+static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
+static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
+static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
+#endif
 
+void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
+
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
@@ -56,6 +64,7 @@ int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
 
 int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
+#endif
 
 /*
  * Generic Buffer Management
@@ -73,16 +82,20 @@ static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
 	drm_ht_remove(&dev->map_hash);
 }
 
+
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
 			    struct drm_file *file_priv);
 int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
+
 int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
+#endif
 
 int __drm_legacy_infobufs(struct drm_device *, void *, int *,
 			  int (*)(void *, int, struct drm_buf_entry *));
@@ -91,11 +104,17 @@ int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
 			  int (*)(void *, int, unsigned long, struct drm_buf *),
 			  struct drm_file *);
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_master_rmmaps(struct drm_device *dev,
 			      struct drm_master *master);
 void drm_legacy_rmmaps(struct drm_device *dev);
+#else
+static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
+					    struct drm_master *master) {}
+static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
+#endif
 
-#ifdef CONFIG_DRM_VM
+#if IS_ENABLED(CONFIG_DRM_VM) && IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_vma_flush(struct drm_device *d);
 #else
 static inline void drm_legacy_vma_flush(struct drm_device *d)
@@ -117,24 +136,43 @@ struct drm_agp_mem {
 };
 
 /* drm_lock.c */
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
 void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
+#else
+static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {}
+#endif
 
 /* DMA support */
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 int drm_legacy_dma_setup(struct drm_device *dev);
 void drm_legacy_dma_takedown(struct drm_device *dev);
+#else
+static inline int drm_legacy_dma_setup(struct drm_device *dev)
+{
+	return 0;
+}
+#endif
+
 void drm_legacy_free_buffer(struct drm_device *dev,
 			    struct drm_buf * buf);
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_reclaim_buffers(struct drm_device *dev,
 				struct drm_file *filp);
+#else
+static inline void drm_legacy_reclaim_buffers(struct drm_device *dev,
+					      struct drm_file *filp) {}
+#endif
 
 /* Scatter Gather Support */
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_sg_cleanup(struct drm_device *dev);
 int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 			struct drm_file *file_priv);
 int drm_legacy_sg_free(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
+#endif
 
 static inline void drm_legacy_init_members(struct drm_device *dev)
 {
drivers/gpu/drm/drm_vm.c +2 -0
index 8987501f53b2..10cf83d569e1 100644
@@ -646,6 +646,7 @@ int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma)
 }
 EXPORT_SYMBOL(drm_legacy_mmap);
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_vma_flush(struct drm_device *dev)
 {
 	struct drm_vma_entry *vma, *vma_temp;
@@ -656,3 +657,4 @@ void drm_legacy_vma_flush(struct drm_device *dev)
 		kfree(vma);
 	}
 }
+#endif
drivers/gpu/drm/nouveau/Kconfig +1 -0
index 3ae7a4cfc6bb..cbcf7d2c089d 100644
@@ -23,6 +23,7 @@ config DRM_NOUVEAU
 config NOUVEAU_LEGACY_CTX_SUPPORT
 	bool "Nouveau legacy context support"
 	select DRM_VM
+	select DRM_LEGACY
 	default y
 	help
 	  There was a version of the nouveau DDX that relied on legacy
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 11/12
#24 lore raw

Re: [PATCH 11/12] drm/legacy: place all drm legacy members under DRM_LEGACY.

In reply to Dave Airlie
Quoted 25 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This places a bunch of the legacy members of drm_device into only being there when legacy is enabled.

---
 drivers/gpu/drm/drm_legacy.h | 20 ++++++++++++++++++++
 include/drm/drm_device.h     |  3 ++-
 2 files changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_legacy.h +1 -0
index 3c05452a7137..4200e6bd3778 100644
@@ -72,6 +72,7 @@ int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
 
 #define DRM_MAP_HASH_OFFSET 0x10000000
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 static inline int drm_legacy_create_map_hash(struct drm_device *dev)
 {
 	return drm_ht_create(&dev->map_hash, 12);
@@ -81,6 +82,14 @@ static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
 {

drivers/gpu/drm/drm_legacy.h static inline void drm_legacy_remove_map_hash(struct drm_device *dev) · line 92

Quoted 10 lines
drivers/gpu/drm/drm_legacy.h +8 -0
 	drm_ht_remove(&dev->map_hash);
 }
+#else
+static inline int drm_legacy_create_map_hash(struct drm_device *dev)
+{
+	return 0;
+}
+
+static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
+#endif

Ah, now I get what you've done with the ht stuff ... This should actually keep vmwgfx happy. I'll reply to the earlier patch and upgrade to r-b there.

Quoted 42 lines
drivers/gpu/drm/drm_legacy.h +11 -0
 #if IS_ENABLED(CONFIG_DRM_LEGACY)
@@ -174,6 +183,8 @@ int drm_legacy_sg_free(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 #endif
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
+
 static inline void drm_legacy_init_members(struct drm_device *dev)
 {
 	INIT_LIST_HEAD(&dev->ctxlist);
@@ -211,6 +222,15 @@ static inline void drm_legacy_dev_reinit(struct drm_device *dev)
 
 	DRM_DEBUG("lastclose completed\n");
 }
+#else
+static inline void drm_legacy_init_members(struct drm_device *dev) {}
+static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
+static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
+#endif
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
+#else
+static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
+#endif
 #endif /* __DRM_LEGACY_H__ */
include/drm/drm_device.h +1 -1
index d5e092dccf3e..7f9ef709b2b6 100644
@@ -306,7 +306,7 @@ struct drm_device {
 
 	/* Everything below here is for legacy driver, never use! */
 	/* private: */
-
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	/* Context handle management - linked list of context handles */
 	struct list_head ctxlist;
 

include/drm/drm_device.h struct drm_device { · line 356

Quoted 4 lines
include/drm/drm_device.h +1 -0
@@ -353,6 +353,7 @@ struct drm_device {
 
 	/* Scatter gather memory */
 	struct drm_sg_mem *sg;
+#endif

Nice!

Quoted 10 lines
include/drm/drm_device.h +0 -0
 };
 
 #endif
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#26 lore raw

Re: [PATCH 12/12] drm/legacy: remove some legacy lock struct members

In reply to Dave Airlie
Quoted 47 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This removes these unless legacy is enabled.

The lock count init is unneeded anyways since it's kzalloc.

---
 drivers/gpu/drm/drm_auth.c   |  4 ++--
 drivers/gpu/drm/drm_file.c   |  1 -
 drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
 include/drm/drm_auth.h       |  2 ++
 include/drm/drm_file.h       |  2 ++
 5 files changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_auth.c +2 -2
index ef8c4353829b..c3df628bc048 100644
@@ -103,8 +103,8 @@ struct drm_master *drm_master_create(struct drm_device *dev)
 		return NULL;
 
 	kref_init(&master->refcount);
-	spin_lock_init(&master->lock.spinlock);
-	init_waitqueue_head(&master->lock.lock_queue);
+
+	drm_master_legacy_init(master);
 	idr_init(&master->magic_map);
 	master->dev = dev;
 
drivers/gpu/drm/drm_file.c +0 -1
index 263fbef73fe5..233f114d2186 100644
@@ -128,7 +128,6 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor)
 
 	/* for compatibility root is always authenticated */
 	file->authenticated = capable(CAP_SYS_ADMIN);
-	file->lock_count = 0;
 
 	INIT_LIST_HEAD(&file->lhead);
 	INIT_LIST_HEAD(&file->fbs);
drivers/gpu/drm/drm_legacy.h +0 -0
index 4200e6bd3778..5d97c06d78e4 100644

drivers/gpu/drm/drm_legacy.h void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *m · line 242

Quoted 10 lines
drivers/gpu/drm/drm_legacy.h +7 -0
@@ -233,4 +233,14 @@ void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *m
 #else
 static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
 #endif
+
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
+static inline void drm_master_legacy_init(struct drm_master *master)
+{
+	spin_lock_init(&master->lock.spinlock);
+	init_waitqueue_head(&master->lock.lock_queue);
+}

Probably small enough that the static inline won't upset anyone, but feel free to bikeshed around.

Quoted 9 lines
drivers/gpu/drm/drm_legacy.h +3 -0
+#else
+static inline void drm_master_legacy_init(struct drm_master *master) {}
+#endif
 #endif /* __DRM_LEGACY_H__ */
include/drm/drm_auth.h +0 -0
index 86bff9841b54..722199f434f0 100644

include/drm/drm_auth.h struct drm_master { · line 84

Quoted 5 lines
include/drm/drm_auth.h +1 -0
@@ -80,7 +80,9 @@ struct drm_master {
 	 * &drm_device.master_mutex.
 	 */
 	struct idr magic_map;
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	struct drm_lock_data lock;

Ditch the kerneldoc and put this at the end behind a

	/* private: */

comment to hide it even harder?

Either way: Reviewed-by: Daniel Vetter <[email protected]>

Quoted 25 lines
include/drm/drm_auth.h +1 -0
+#endif
 	void *driver_priv;
 
 	/* Tree of display resource leases, each of which is a drm_master struct
include/drm/drm_file.h +2 -0
index 6710b612e2f6..67af60bb527a 100644
@@ -335,7 +335,9 @@ struct drm_file {
 	struct drm_prime_file_private prime;
 
 	/* private: */
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 	unsigned long lock_count; /* DRI1 legacy lock count */
+#endif
 };
 
 /**
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by
#10 lore raw

Re: [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines

In reply to Daniel Vetter
Quoted 11 lines · Daniel Vetter
Quoted 5 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This allows them to be removed later.

vmwgfx still uses these? Is the plan to burn that down :-)

Probably easier to add a todo.rst item to clean that up than do it yourself.

With the insight of later patches telling me what you plan to do:

Quoted 74 lines

-Daniel

Quoted 67 lines
---
 drivers/gpu/drm/drm_drv.c    |  7 +++----
 drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_drv.c +3 -4
index 15b0fd5adaaf..18f45f9a955c 100644
@@ -692,10 +692,9 @@ int drm_dev_init(struct drm_device *dev,
 	if (ret)
 		goto err_minors;
 
-	ret = drm_ht_create(&dev->map_hash, 12);
+	ret = drm_legacy_create_map_hash(dev);
 	if (ret)
 		goto err_minors;
-
 	drm_legacy_ctxbitmap_init(dev);
 
 	if (drm_core_check_feature(dev, DRIVER_GEM)) {
@@ -717,7 +716,7 @@ int drm_dev_init(struct drm_device *dev,
 		drm_gem_destroy(dev);
 err_ctxbitmap:
 	drm_legacy_ctxbitmap_cleanup(dev);
-	drm_ht_remove(&dev->map_hash);
+	drm_legacy_remove_map_hash(dev);
 err_minors:
 	drm_minor_free(dev, DRM_MINOR_PRIMARY);
 	drm_minor_free(dev, DRM_MINOR_RENDER);
@@ -792,7 +791,7 @@ void drm_dev_fini(struct drm_device *dev)
 		drm_gem_destroy(dev);
 
 	drm_legacy_ctxbitmap_cleanup(dev);
-	drm_ht_remove(&dev->map_hash);
+	drm_legacy_remove_map_hash(dev);
 	drm_fs_inode_free(dev->anon_inode);
 
 	drm_minor_free(dev, DRM_MINOR_PRIMARY);
drivers/gpu/drm/drm_legacy.h +10 -0
index 974c2be6bcd5..ef419d500e51 100644
@@ -63,6 +63,16 @@ int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
 
 #define DRM_MAP_HASH_OFFSET 0x10000000
 
+static inline int drm_legacy_create_map_hash(struct drm_device *dev)
+{
+	return drm_ht_create(&dev->map_hash, 12);
+}
+
+static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
+{
+	drm_ht_remove(&dev->map_hash);
+}
+
 int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
 			    struct drm_file *file_priv);
 int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

Re: [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines

In reply to Dave Airlie

Hi Dave.

Micro nit..

Quoted 15 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This allows them to be removed later.

---
 drivers/gpu/drm/drm_drv.c    |  7 +++----
 drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_drv.c +0 -0
index 15b0fd5adaaf..18f45f9a955c 100644

drivers/gpu/drm/drm_drv.c int drm_dev_init(struct drm_device *dev, · line 698

Quoted 9 lines
drivers/gpu/drm/drm_drv.c +1 -2
@@ -692,10 +692,9 @@ int drm_dev_init(struct drm_device *dev,
 	if (ret)
 		goto err_minors;
 
-	ret = drm_ht_create(&dev->map_hash, 12);
+	ret = drm_legacy_create_map_hash(dev);
 	if (ret)
 		goto err_minors;
-
 	drm_legacy_ctxbitmap_init(dev);

Removal of empty line does not make code easier to read, and an unrelated change.
As I said - micro nit.

Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#14 lore raw

Re: [PATCH 07/12] drm/legacy: move init/destroy of struct members into inlines

In reply to Dave Airlie

Hi Dave.

Quoted 37 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This will allow easier removal later.

---
 drivers/gpu/drm/drm_drv.c    | 10 +++-------
 drivers/gpu/drm/drm_legacy.h | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_drv.c +1 -5
index 18f45f9a955c..e4f36c5ccfcd 100644
@@ -659,20 +659,16 @@ int drm_dev_init(struct drm_device *dev,
 	/* no per-device feature limits by default */
 	dev->driver_features = ~0u;
 
+	drm_legacy_init_members(dev);
 	INIT_LIST_HEAD(&dev->filelist);
 	INIT_LIST_HEAD(&dev->filelist_internal);
 	INIT_LIST_HEAD(&dev->clientlist);
-	INIT_LIST_HEAD(&dev->ctxlist);
-	INIT_LIST_HEAD(&dev->vmalist);
-	INIT_LIST_HEAD(&dev->maplist);
 	INIT_LIST_HEAD(&dev->vblank_event_list);
 
-	spin_lock_init(&dev->buf_lock);
 	spin_lock_init(&dev->event_lock);
 	mutex_init(&dev->struct_mutex);
 	mutex_init(&dev->filelist_mutex);
 	mutex_init(&dev->clientlist_mutex);
-	mutex_init(&dev->ctxlist_mutex);
 	mutex_init(&dev->master_mutex);
 
 	dev->anon_inode = drm_fs_inode_new();

drivers/gpu/drm/drm_drv.c int drm_dev_init(struct drm_device *dev, · line 726

Quoted 8 lines
drivers/gpu/drm/drm_drv.c +1 -1
@@ -724,7 +720,7 @@ int drm_dev_init(struct drm_device *dev,
 err_free:
 	put_device(dev->dev);
 	mutex_destroy(&dev->master_mutex);
-	mutex_destroy(&dev->ctxlist_mutex);
+	drm_legacy_destroy_members(dev);
 	mutex_destroy(&dev->clientlist_mutex);
 	mutex_destroy(&dev->filelist_mutex);
 	mutex_destroy(&dev->struct_mutex);

I do not know if it has any practical influence.
But my OCD tirgger when we do not destroy the mutex
in the opposite order we init them.
This was so before, but as the init order changed we could also change the destroy order.
Moving the drm_legacy_destroy_members() down should do it.

drivers/gpu/drm/drm_drv.c void drm_dev_fini(struct drm_device *dev) · line 802

Quoted 9 lines
drivers/gpu/drm/drm_drv.c +1 -1
@@ -800,7 +796,7 @@ void drm_dev_fini(struct drm_device *dev)
 	put_device(dev->dev);
 
 	mutex_destroy(&dev->master_mutex);
-	mutex_destroy(&dev->ctxlist_mutex);
+	drm_legacy_destroy_members(dev);
 	mutex_destroy(&dev->clientlist_mutex);
 	mutex_destroy(&dev->filelist_mutex);
 	mutex_destroy(&dev->struct_mutex);

Same here.

Quoted 11 lines
drivers/gpu/drm/drm_legacy.h +3 -0
index ef419d500e51..20c4befc476b 100644
@@ -136,5 +136,19 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 int drm_legacy_sg_free(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 
+static inline void drm_legacy_init_members(struct drm_device *dev)
+{
+	INIT_LIST_HEAD(&dev->ctxlist);

drivers/gpu/drm/drm_legacy.h int drm_legacy_sg_alloc(struct drm_device *dev, void *data, · line 151

Quoted 10 lines
drivers/gpu/drm/drm_legacy.h +10 -0
+	INIT_LIST_HEAD(&dev->vmalist);
+	INIT_LIST_HEAD(&dev->maplist);
+	spin_lock_init(&dev->buf_lock);
+	mutex_init(&dev->ctxlist_mutex);
+}
+
+static inline void drm_legacy_destroy_members(struct drm_device *dev)
+{
+	mutex_destroy(&dev->ctxlist_mutex);
+}

Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#17 lore raw

Re: [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline

In reply to Dave Airlie

Hi Dave.

Quoted 6 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This moves the legacy dev reinit into a legacy inline,

also removes some unneeded inlines now.

This comment looks like it belogns to an older iteration of the patch.

Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#20 lore raw

Re: [PATCH 09/12] drm/legacy: don't include any of ati_pcigart in legacy.

In reply to Daniel Vetter
Quoted 23 lines · Daniel Vetter
Quoted 6 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This could probably be done with Kconfig somehow, but I failed in my first 2 minute attempt.

config DRM_ATI_PCIGART

	bool
	default y
	depens on PCI && DRM_LEGACY

Should give you a nice hidden Kconfig symbol that dtrt and can be used in the Makefile. With that

Other option (no idea it's preferred):

config DRM_ATI_PCIGART
bool

Quoted 7 lines

and then in

config DRM_LEGACY
select DRM_ATI_PCIGART if PCI

Either should work I think, the latter more closely follows what we do already.

Personal preference is the latter, because we keep the DRM_LEGACY logic located in one place.
But as long as we do it in Kconfig then all is good.

Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel