All of lore.kernel.org
 help / color / mirror / Atom feed
* drm: make legacy support code optional
@ 2019-04-23  2:00 Dave Airlie
  2019-04-23  2:00 ` [PATCH 01/12] drm/nouveau: add kconfig option to turn off nouveau legacy contexts. (v2) Dave Airlie
                   ` (11 more replies)
  0 siblings, 12 replies; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 01/12] drm/nouveau: add kconfig option to turn off nouveau legacy contexts. (v2)
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23  2:00 ` [PATCH 02/12] drm/legacy: move drm_legacy_master_rmmaps to non-driver legacy header Dave Airlie
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

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 <peter.antoine@intel.com>
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 <daniel.vetter@ffwll.ch>
    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 <airlied@redhat.com>
    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.

    Signed-off-by: Peter Antoine <peter.antoine@intel.com> (v2)
    Cc: Peter Antoine <peter.antoine@intel.com> (v2)
    Reviewed-by: Peter Antoine <peter.antoine@intel.com>
    Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

v2: move DRM_VM dependency into legacy config.

Cc: stable@vger.kernel.org
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/Kconfig       | 12 +++++++++++-
 drivers/gpu/drm/nouveau/nouveau_drm.c |  7 +++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
index 00cd9ab8948d..3ae7a4cfc6bb 100644
--- a/drivers/gpu/drm/nouveau/Kconfig
+++ b/drivers/gpu/drm/nouveau/Kconfig
@@ -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
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 5020265bfbd9..6ab9033f49da 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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,
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 02/12] drm/legacy: move drm_legacy_master_rmmaps to non-driver legacy header.
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
  2019-04-23  2:00 ` [PATCH 01/12] drm/nouveau: add kconfig option to turn off nouveau legacy contexts. (v2) Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23  2:00 ` [PATCH 03/12] drm/legacy: move map cleanups into drm_bufs.c Dave Airlie
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

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

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_legacy.h | 3 +++
 include/drm/drm_legacy.h     | 2 --
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 280fbeb846ff..e6bf1a94374b 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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
diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h
index 3e99ab69c122..2182a56ac421 100644
--- a/include/drm/drm_legacy.h
+++ b/include/drm/drm_legacy.h
@@ -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);
 
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 03/12] drm/legacy: move map cleanups into drm_bufs.c
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
  2019-04-23  2:00 ` [PATCH 01/12] drm/nouveau: add kconfig option to turn off nouveau legacy contexts. (v2) Dave Airlie
  2019-04-23  2:00 ` [PATCH 02/12] drm/legacy: move drm_legacy_master_rmmaps to non-driver legacy header Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23  2:00 ` [PATCH 04/12] drm/radeon: drop unused ati pcigart include Dave Airlie
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

This makes it easier to clean this up later.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index e407adb033e7..bfc419ed9d6c 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -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
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 50d849d1bc6e..15b0fd5adaaf 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -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);
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index e6bf1a94374b..3dc626090fcb 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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);
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 04/12] drm/radeon: drop unused ati pcigart include.
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
                   ` (2 preceding siblings ...)
  2019-04-23  2:00 ` [PATCH 03/12] drm/legacy: move map cleanups into drm_bufs.c Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23 13:07   ` Christian König
  2019-04-23  2:00 ` [PATCH 05/12] drm/legacy: move lock cleanup for master into lock file Dave Airlie
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/radeon/radeon_drv.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index afef2d9fccd8..173deb463414 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -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:
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 05/12] drm/legacy: move lock cleanup for master into lock file
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
                   ` (3 preceding siblings ...)
  2019-04-23  2:00 ` [PATCH 04/12] drm/radeon: drop unused ati pcigart include Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23 18:44   ` Daniel Vetter
  2019-04-23  2:00 ` [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines Dave Airlie
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

This makes it easier to remove legacy code later.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 1669c42c40ed..ef8c4353829b 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -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)
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 3dc626090fcb..974c2be6bcd5 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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__ */
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index 67a1a2ca7174..b37874a15e23 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -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);
+}
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
                   ` (4 preceding siblings ...)
  2019-04-23  2:00 ` [PATCH 05/12] drm/legacy: move lock cleanup for master into lock file Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23 18:45   ` Daniel Vetter
  2019-04-23 19:48   ` Sam Ravnborg
  2019-04-23  2:00 ` [PATCH 07/12] drm/legacy: move init/destroy of struct members " Dave Airlie
                   ` (5 subsequent siblings)
  11 siblings, 2 replies; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

This allows them to be removed later.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_drv.c    |  7 +++----
 drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 15b0fd5adaaf..18f45f9a955c 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -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);
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 974c2be6bcd5..ef419d500e51 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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);
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 07/12] drm/legacy: move init/destroy of struct members into inlines
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
                   ` (5 preceding siblings ...)
  2019-04-23  2:00 ` [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23 18:46   ` Daniel Vetter
  2019-04-23 19:52   ` Sam Ravnborg
  2019-04-23  2:00 ` [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline Dave Airlie
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

This will allow easier removal later.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_drv.c    | 10 +++-------
 drivers/gpu/drm/drm_legacy.h | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 18f45f9a955c..e4f36c5ccfcd 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -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);
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index ef419d500e51..20c4befc476b 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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__ */
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
                   ` (6 preceding siblings ...)
  2019-04-23  2:00 ` [PATCH 07/12] drm/legacy: move init/destroy of struct members " Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23 18:47   ` Daniel Vetter
  2019-04-23 19:55   ` Sam Ravnborg
  2019-04-23  2:00 ` [PATCH 09/12] drm/legacy: don't include any of ati_pcigart in legacy Dave Airlie
                   ` (3 subsequent siblings)
  11 siblings, 2 replies; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

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

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_file.c   | 24 ------------------------
 drivers/gpu/drm/drm_legacy.h | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 9701469a6e93..263fbef73fe5 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -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");
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 20c4befc476b..8ee2de06f999 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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__ */
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 09/12] drm/legacy: don't include any of ati_pcigart in legacy.
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
                   ` (7 preceding siblings ...)
  2019-04-23  2:00 ` [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23 18:50   ` Daniel Vetter
  2019-04-23  2:00 ` [PATCH 10/12] drm: allow removal of legacy codepaths (v4) Dave Airlie
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

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

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ati_pcigart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/ati_pcigart.c b/drivers/gpu/drm/ati_pcigart.c
index 2362f07fe1fc..0420a28f770a 100644
--- a/drivers/gpu/drm/ati_pcigart.c
+++ b/drivers/gpu/drm/ati_pcigart.c
@@ -5,6 +5,7 @@
  * \author Gareth Hughes <gareth@valinux.com>
  */
 
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 /*
  * Created: Wed Dec 13 21:52:19 2000 by gareth@valinux.com
  *
@@ -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
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 10/12] drm: allow removal of legacy codepaths (v4)
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
                   ` (8 preceding siblings ...)
  2019-04-23  2:00 ` [PATCH 09/12] drm/legacy: don't include any of ati_pcigart in legacy Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23 18:53   ` Daniel Vetter
  2019-04-23  2:00 ` [PATCH 11/12] drm/legacy: place all drm legacy members under DRM_LEGACY Dave Airlie
  2019-04-23  2:00 ` [PATCH 12/12] drm/legacy: remove some legacy lock struct members Dave Airlie
  11 siblings, 1 reply; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

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

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 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(-)

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 7ebae3d45505..340e075f6e06 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -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
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index d9a483a5fce0..e19ac7ca602d 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -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);
diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index 0e3043e08c69..374b372da58a 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -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
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index ce8a70875bd5..5878145077d0 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -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),
 
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 9bd8908d5fd8..02f38cc9f468 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 8ee2de06f999..3c05452a7137 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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)
 {
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 8987501f53b2..10cf83d569e1 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -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
diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
index 3ae7a4cfc6bb..cbcf7d2c089d 100644
--- a/drivers/gpu/drm/nouveau/Kconfig
+++ b/drivers/gpu/drm/nouveau/Kconfig
@@ -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
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 11/12] drm/legacy: place all drm legacy members under DRM_LEGACY.
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
                   ` (9 preceding siblings ...)
  2019-04-23  2:00 ` [PATCH 10/12] drm: allow removal of legacy codepaths (v4) Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23 18:55   ` Daniel Vetter
  2019-04-23  2:00 ` [PATCH 12/12] drm/legacy: remove some legacy lock struct members Dave Airlie
  11 siblings, 1 reply; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

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

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_legacy.h | 20 ++++++++++++++++++++
 include/drm/drm_device.h     |  3 ++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 3c05452a7137..4200e6bd3778 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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__ */
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index d5e092dccf3e..7f9ef709b2b6 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -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
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 12/12] drm/legacy: remove some legacy lock struct members
  2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
                   ` (10 preceding siblings ...)
  2019-04-23  2:00 ` [PATCH 11/12] drm/legacy: place all drm legacy members under DRM_LEGACY Dave Airlie
@ 2019-04-23  2:00 ` Dave Airlie
  2019-04-23 18:57   ` Daniel Vetter
  11 siblings, 1 reply; 27+ messages in thread
From: Dave Airlie @ 2019-04-23  2:00 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

This removes these unless legacy is enabled.

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

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index ef8c4353829b..c3df628bc048 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -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;
 
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 263fbef73fe5..233f114d2186 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -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);
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 4200e6bd3778..5d97c06d78e4 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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__ */
diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
index 86bff9841b54..722199f434f0 100644
--- a/include/drm/drm_auth.h
+++ b/include/drm/drm_auth.h
@@ -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
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 6710b612e2f6..67af60bb527a 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -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
 };
 
 /**
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 04/12] drm/radeon: drop unused ati pcigart include.
  2019-04-23  2:00 ` [PATCH 04/12] drm/radeon: drop unused ati pcigart include Dave Airlie
@ 2019-04-23 13:07   ` Christian König
  0 siblings, 0 replies; 27+ messages in thread
From: Christian König @ 2019-04-23 13:07 UTC (permalink / raw)
  To: Dave Airlie, dri-devel

Am 23.04.19 um 04:00 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/radeon/radeon_drv.h | 1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
> index afef2d9fccd8..173deb463414 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.h
> +++ b/drivers/gpu/drm/radeon/radeon_drv.h
> @@ -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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 05/12] drm/legacy: move lock cleanup for master into lock file
  2019-04-23  2:00 ` [PATCH 05/12] drm/legacy: move lock cleanup for master into lock file Dave Airlie
@ 2019-04-23 18:44   ` Daniel Vetter
  0 siblings, 0 replies; 27+ messages in thread
From: Daniel Vetter @ 2019-04-23 18:44 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

On Tue, Apr 23, 2019 at 12:00:34PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This makes it easier to remove legacy code later.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  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(-)
> 
> diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
> index 1669c42c40ed..ef8c4353829b 100644
> --- a/drivers/gpu/drm/drm_auth.c
> +++ b/drivers/gpu/drm/drm_auth.c
> @@ -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 <daniel.vetter@ffwll.ch>

> -		/*
> -		 * 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)
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 3dc626090fcb..974c2be6bcd5 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -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__ */
> diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
> index 67a1a2ca7174..b37874a15e23 100644
> --- a/drivers/gpu/drm/drm_lock.c
> +++ b/drivers/gpu/drm/drm_lock.c
> @@ -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);
> +}
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines
  2019-04-23  2:00 ` [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines Dave Airlie
@ 2019-04-23 18:45   ` Daniel Vetter
  2019-04-23 18:58     ` Daniel Vetter
  2019-04-23 19:48   ` Sam Ravnborg
  1 sibling, 1 reply; 27+ messages in thread
From: Daniel Vetter @ 2019-04-23 18:45 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

On Tue, Apr 23, 2019 at 12:00:35PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This allows them to be removed later.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

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

> ---
>  drivers/gpu/drm/drm_drv.c    |  7 +++----
>  drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 15b0fd5adaaf..18f45f9a955c 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -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);
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 974c2be6bcd5..ef419d500e51 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -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);
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 07/12] drm/legacy: move init/destroy of struct members into inlines
  2019-04-23  2:00 ` [PATCH 07/12] drm/legacy: move init/destroy of struct members " Dave Airlie
@ 2019-04-23 18:46   ` Daniel Vetter
  2019-04-23 19:52   ` Sam Ravnborg
  1 sibling, 0 replies; 27+ messages in thread
From: Daniel Vetter @ 2019-04-23 18:46 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

On Tue, Apr 23, 2019 at 12:00:36PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This will allow easier removal later.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_drv.c    | 10 +++-------
>  drivers/gpu/drm/drm_legacy.h | 14 ++++++++++++++
>  2 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 18f45f9a955c..e4f36c5ccfcd 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -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);
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index ef419d500e51..20c4befc476b 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -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);
> +}

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 <daniel.vetter@ffwll.ch>

> +
>  void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
>  #endif /* __DRM_LEGACY_H__ */
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline
  2019-04-23  2:00 ` [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline Dave Airlie
@ 2019-04-23 18:47   ` Daniel Vetter
  2019-04-23 19:55   ` Sam Ravnborg
  1 sibling, 0 replies; 27+ messages in thread
From: Daniel Vetter @ 2019-04-23 18:47 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

On Tue, Apr 23, 2019 at 12:00:37PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This moves the legacy dev reinit into a legacy inline,
> also removes some unneeded inlines now.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_file.c   | 24 ------------------------
>  drivers/gpu/drm/drm_legacy.h | 24 ++++++++++++++++++++++++
>  2 files changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index 9701469a6e93..263fbef73fe5 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -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");
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 20c4befc476b..8ee2de06f999 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -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:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +{
> +	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__ */
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 09/12] drm/legacy: don't include any of ati_pcigart in legacy.
  2019-04-23  2:00 ` [PATCH 09/12] drm/legacy: don't include any of ati_pcigart in legacy Dave Airlie
@ 2019-04-23 18:50   ` Daniel Vetter
  2019-04-23 19:58     ` Sam Ravnborg
  0 siblings, 1 reply; 27+ messages in thread
From: Daniel Vetter @ 2019-04-23 18:50 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

On Tue, Apr 23, 2019 at 12:00:38PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This could probably be done with Kconfig somehow, but I failed in my
> first 2 minute attempt.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

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

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

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

> ---
>  drivers/gpu/drm/ati_pcigart.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/ati_pcigart.c b/drivers/gpu/drm/ati_pcigart.c
> index 2362f07fe1fc..0420a28f770a 100644
> --- a/drivers/gpu/drm/ati_pcigart.c
> +++ b/drivers/gpu/drm/ati_pcigart.c
> @@ -5,6 +5,7 @@
>   * \author Gareth Hughes <gareth@valinux.com>
>   */
>  
> +#if IS_ENABLED(CONFIG_DRM_LEGACY)
>  /*
>   * Created: Wed Dec 13 21:52:19 2000 by gareth@valinux.com
>   *
> @@ -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
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 10/12] drm: allow removal of legacy codepaths (v4)
  2019-04-23  2:00 ` [PATCH 10/12] drm: allow removal of legacy codepaths (v4) Dave Airlie
@ 2019-04-23 18:53   ` Daniel Vetter
  0 siblings, 0 replies; 27+ messages in thread
From: Daniel Vetter @ 2019-04-23 18:53 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

On Tue, Apr 23, 2019 at 12:00:39PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> 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
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

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

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  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(-)
> 
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 7ebae3d45505..340e075f6e06 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -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
> diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
> index d9a483a5fce0..e19ac7ca602d 100644
> --- a/drivers/gpu/drm/drm_internal.h
> +++ b/drivers/gpu/drm/drm_internal.h
> @@ -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);
> diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
> index 0e3043e08c69..374b372da58a 100644
> --- a/drivers/gpu/drm/drm_ioc32.c
> +++ b/drivers/gpu/drm/drm_ioc32.c
> @@ -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
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index ce8a70875bd5..5878145077d0 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -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),
>  
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 9bd8908d5fd8..02f38cc9f468 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -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
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 8ee2de06f999..3c05452a7137 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -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)
>  {
> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
> index 8987501f53b2..10cf83d569e1 100644
> --- a/drivers/gpu/drm/drm_vm.c
> +++ b/drivers/gpu/drm/drm_vm.c
> @@ -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
> diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
> index 3ae7a4cfc6bb..cbcf7d2c089d 100644
> --- a/drivers/gpu/drm/nouveau/Kconfig
> +++ b/drivers/gpu/drm/nouveau/Kconfig
> @@ -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
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 11/12] drm/legacy: place all drm legacy members under DRM_LEGACY.
  2019-04-23  2:00 ` [PATCH 11/12] drm/legacy: place all drm legacy members under DRM_LEGACY Dave Airlie
@ 2019-04-23 18:55   ` Daniel Vetter
  0 siblings, 0 replies; 27+ messages in thread
From: Daniel Vetter @ 2019-04-23 18:55 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

On Tue, Apr 23, 2019 at 12:00:40PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This places a bunch of the legacy members of drm_device into
> only being there when legacy is enabled.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_legacy.h | 20 ++++++++++++++++++++
>  include/drm/drm_device.h     |  3 ++-
>  2 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 3c05452a7137..4200e6bd3778 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -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

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.


>  
>  
>  #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__ */
> diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
> index d5e092dccf3e..7f9ef709b2b6 100644
> --- a/include/drm/drm_device.h
> +++ b/include/drm/drm_device.h
> @@ -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

Nice!

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  };
>  
>  #endif
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 12/12] drm/legacy: remove some legacy lock struct members
  2019-04-23  2:00 ` [PATCH 12/12] drm/legacy: remove some legacy lock struct members Dave Airlie
@ 2019-04-23 18:57   ` Daniel Vetter
  0 siblings, 0 replies; 27+ messages in thread
From: Daniel Vetter @ 2019-04-23 18:57 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

On Tue, Apr 23, 2019 at 12:00:41PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This removes these unless legacy is enabled.
> 
> The lock count init is unneeded anyways since it's kzalloc.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  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(-)
> 
> diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
> index ef8c4353829b..c3df628bc048 100644
> --- a/drivers/gpu/drm/drm_auth.c
> +++ b/drivers/gpu/drm/drm_auth.c
> @@ -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;
>  
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index 263fbef73fe5..233f114d2186 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -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);
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 4200e6bd3778..5d97c06d78e4 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -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.

> +#else
> +static inline void drm_master_legacy_init(struct drm_master *master) {}
> +#endif
>  #endif /* __DRM_LEGACY_H__ */
> diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
> index 86bff9841b54..722199f434f0 100644
> --- a/include/drm/drm_auth.h
> +++ b/include/drm/drm_auth.h
> @@ -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 <daniel.vetter@ffwll.ch>
> +#endif
>  	void *driver_priv;
>  
>  	/* Tree of display resource leases, each of which is a drm_master struct
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index 6710b612e2f6..67af60bb527a 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -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
>  };
>  
>  /**
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines
  2019-04-23 18:45   ` Daniel Vetter
@ 2019-04-23 18:58     ` Daniel Vetter
  0 siblings, 0 replies; 27+ messages in thread
From: Daniel Vetter @ 2019-04-23 18:58 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

On Tue, Apr 23, 2019 at 08:45:11PM +0200, Daniel Vetter wrote:
> On Tue, Apr 23, 2019 at 12:00:35PM +1000, Dave Airlie wrote:
> > From: Dave Airlie <airlied@redhat.com>
> > 
> > This allows them to be removed later.
> > 
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
> 
> 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:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> -Daniel
> 
> > ---
> >  drivers/gpu/drm/drm_drv.c    |  7 +++----
> >  drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
> >  2 files changed, 13 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> > index 15b0fd5adaaf..18f45f9a955c 100644
> > --- a/drivers/gpu/drm/drm_drv.c
> > +++ b/drivers/gpu/drm/drm_drv.c
> > @@ -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);
> > diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> > index 974c2be6bcd5..ef419d500e51 100644
> > --- a/drivers/gpu/drm/drm_legacy.h
> > +++ b/drivers/gpu/drm/drm_legacy.h
> > @@ -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);
> > -- 
> > 2.20.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines
  2019-04-23  2:00 ` [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines Dave Airlie
  2019-04-23 18:45   ` Daniel Vetter
@ 2019-04-23 19:48   ` Sam Ravnborg
  1 sibling, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2019-04-23 19:48 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

Hi Dave.

Micro nit..

On Tue, Apr 23, 2019 at 12:00:35PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This allows them to be removed later.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_drv.c    |  7 +++----
>  drivers/gpu/drm/drm_legacy.h | 10 ++++++++++
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 15b0fd5adaaf..18f45f9a955c 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 07/12] drm/legacy: move init/destroy of struct members into inlines
  2019-04-23  2:00 ` [PATCH 07/12] drm/legacy: move init/destroy of struct members " Dave Airlie
  2019-04-23 18:46   ` Daniel Vetter
@ 2019-04-23 19:52   ` Sam Ravnborg
  1 sibling, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2019-04-23 19:52 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

Hi Dave.

On Tue, Apr 23, 2019 at 12:00:36PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This will allow easier removal later.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_drv.c    | 10 +++-------
>  drivers/gpu/drm/drm_legacy.h | 14 ++++++++++++++
>  2 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 18f45f9a955c..e4f36c5ccfcd 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -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);

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.

> @@ -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.

> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index ef419d500e51..20c4befc476b 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -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);
> +}

	Sam
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline
  2019-04-23  2:00 ` [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline Dave Airlie
  2019-04-23 18:47   ` Daniel Vetter
@ 2019-04-23 19:55   ` Sam Ravnborg
  1 sibling, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2019-04-23 19:55 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel

Hi Dave.

On Tue, Apr 23, 2019 at 12:00:37PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> 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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 09/12] drm/legacy: don't include any of ati_pcigart in legacy.
  2019-04-23 18:50   ` Daniel Vetter
@ 2019-04-23 19:58     ` Sam Ravnborg
  0 siblings, 0 replies; 27+ messages in thread
From: Sam Ravnborg @ 2019-04-23 19:58 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: dri-devel

On Tue, Apr 23, 2019 at 08:50:35PM +0200, Daniel Vetter wrote:
> On Tue, Apr 23, 2019 at 12:00:38PM +1000, Dave Airlie wrote:
> > From: Dave Airlie <airlied@redhat.com>
> > 
> > This could probably be done with Kconfig somehow, but I failed in my
> > first 2 minute attempt.
> > 
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
> 
> 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
> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> 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.

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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-04-23 19:58 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23  2:00 drm: make legacy support code optional Dave Airlie
2019-04-23  2:00 ` [PATCH 01/12] drm/nouveau: add kconfig option to turn off nouveau legacy contexts. (v2) Dave Airlie
2019-04-23  2:00 ` [PATCH 02/12] drm/legacy: move drm_legacy_master_rmmaps to non-driver legacy header Dave Airlie
2019-04-23  2:00 ` [PATCH 03/12] drm/legacy: move map cleanups into drm_bufs.c Dave Airlie
2019-04-23  2:00 ` [PATCH 04/12] drm/radeon: drop unused ati pcigart include Dave Airlie
2019-04-23 13:07   ` Christian König
2019-04-23  2:00 ` [PATCH 05/12] drm/legacy: move lock cleanup for master into lock file Dave Airlie
2019-04-23 18:44   ` Daniel Vetter
2019-04-23  2:00 ` [PATCH 06/12] drm/legacy: move map_hash create/destroy into inlines Dave Airlie
2019-04-23 18:45   ` Daniel Vetter
2019-04-23 18:58     ` Daniel Vetter
2019-04-23 19:48   ` Sam Ravnborg
2019-04-23  2:00 ` [PATCH 07/12] drm/legacy: move init/destroy of struct members " Dave Airlie
2019-04-23 18:46   ` Daniel Vetter
2019-04-23 19:52   ` Sam Ravnborg
2019-04-23  2:00 ` [PATCH 08/12] drm/legacy: move legacy dev reinit into an inline Dave Airlie
2019-04-23 18:47   ` Daniel Vetter
2019-04-23 19:55   ` Sam Ravnborg
2019-04-23  2:00 ` [PATCH 09/12] drm/legacy: don't include any of ati_pcigart in legacy Dave Airlie
2019-04-23 18:50   ` Daniel Vetter
2019-04-23 19:58     ` Sam Ravnborg
2019-04-23  2:00 ` [PATCH 10/12] drm: allow removal of legacy codepaths (v4) Dave Airlie
2019-04-23 18:53   ` Daniel Vetter
2019-04-23  2:00 ` [PATCH 11/12] drm/legacy: place all drm legacy members under DRM_LEGACY Dave Airlie
2019-04-23 18:55   ` Daniel Vetter
2019-04-23  2:00 ` [PATCH 12/12] drm/legacy: remove some legacy lock struct members Dave Airlie
2019-04-23 18:57   ` Daniel Vetter

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.