All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY
@ 2016-08-03 19:11 Daniel Vetter
  2016-08-03 19:11 ` [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions Daniel Vetter
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Daniel Vetter @ 2016-08-03 19:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Daniel Vetter

It's super confusing that new drivers need to be marked with
DRIVER_MODESET when really it means DRIVER_MODERN. Much better to
invert the meaning and rename it to something that's suitably
off-putting.

Since there's over 100 places using DRIVER_MODESET we need to roll out
this change without a flag day.

v2: Update docs.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 Documentation/gpu/drm-internals.rst | 9 ++++++---
 drivers/gpu/drm/i810/i810_drv.c     | 4 +---
 drivers/gpu/drm/mga/mga_drv.c       | 2 +-
 drivers/gpu/drm/r128/r128_drv.c     | 2 +-
 drivers/gpu/drm/savage/savage_drv.c | 2 +-
 drivers/gpu/drm/sis/sis_drv.c       | 2 +-
 drivers/gpu/drm/tdfx/tdfx_drv.c     | 1 +
 drivers/gpu/drm/via/via_drv.c       | 2 +-
 include/drm/drmP.h                  | 1 +
 9 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst
index 3bb26135971f..37284bcc7764 100644
--- a/Documentation/gpu/drm-internals.rst
+++ b/Documentation/gpu/drm-internals.rst
@@ -53,9 +53,12 @@ u32 driver_features;
 DRIVER_USE_AGP
     Driver uses AGP interface, the DRM core will manage AGP resources.
 
-DRIVER_REQUIRE_AGP
-    Driver needs AGP interface to function. AGP initialization failure
-    will become a fatal error.
+DRIVER_LEGACY
+    Denote a legacy driver using shadow attach. Don't use.
+
+DRIVER_KMS_LEGACY_CONTEXT
+    Used only by nouveau for backwards compatibility with existing userspace.
+    Don't use.
 
 DRIVER_PCI_DMA
     Driver is capable of PCI DMA, mapping of PCI DMA buffers to
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 44f4a131c8dd..0be55dc1ef4b 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -56,9 +56,7 @@ static const struct file_operations i810_driver_fops = {
 };
 
 static struct drm_driver driver = {
-	.driver_features =
-	    DRIVER_USE_AGP |
-	    DRIVER_HAVE_DMA,
+	.driver_features = DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_LEGACY,
 	.dev_priv_size = sizeof(drm_i810_buf_priv_t),
 	.load = i810_driver_load,
 	.lastclose = i810_driver_lastclose,
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 5e2f131a6a72..25b2a1a424e6 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -58,7 +58,7 @@ static const struct file_operations mga_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_PCI_DMA |
+	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_LEGACY |
 	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
 	.dev_priv_size = sizeof(drm_mga_buf_priv_t),
 	.load = mga_driver_load,
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index c57b4de63caf..a982be57d1ef 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -56,7 +56,7 @@ static const struct file_operations r128_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
+	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_LEGACY |
 	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
 	.dev_priv_size = sizeof(drm_r128_buf_priv_t),
 	.load = r128_driver_load,
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 21aed1febeb4..3b807135a5cd 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -50,7 +50,7 @@ static const struct file_operations savage_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA,
+	    DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA | DRIVER_LEGACY,
 	.dev_priv_size = sizeof(drm_savage_buf_priv_t),
 	.load = savage_driver_load,
 	.firstopen = savage_driver_firstopen,
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 79bce76cb8f7..ae9839886c4d 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -102,7 +102,7 @@ static void sis_driver_postclose(struct drm_device *dev, struct drm_file *file)
 }
 
 static struct drm_driver driver = {
-	.driver_features = DRIVER_USE_AGP,
+	.driver_features = DRIVER_USE_AGP | DRIVER_LEGACY,
 	.load = sis_driver_load,
 	.unload = sis_driver_unload,
 	.open = sis_driver_open,
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index fab5ebcb0fef..f418892b0c71 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -56,6 +56,7 @@ static const struct file_operations tdfx_driver_fops = {
 };
 
 static struct drm_driver driver = {
+	.driver_features = DRIVER_LEGACY,
 	.set_busid = drm_pci_set_busid,
 	.fops = &tdfx_driver_fops,
 	.name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index ed8aa8ff861a..e5582bab7e3c 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -72,7 +72,7 @@ static const struct file_operations via_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_HAVE_IRQ |
+	    DRIVER_USE_AGP | DRIVER_HAVE_IRQ | DRIVER_LEGACY |
 	    DRIVER_IRQ_SHARED,
 	.load = via_driver_load,
 	.unload = via_driver_unload,
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 5f9caf7ee949..9c828d6f7cdc 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -146,6 +146,7 @@ void drm_err(const char *format, ...);
 
 /* driver capabilities and requirements mask */
 #define DRIVER_USE_AGP			0x1
+#define DRIVER_LEGACY			0x2
 #define DRIVER_PCI_DMA			0x8
 #define DRIVER_SG			0x10
 #define DRIVER_HAVE_DMA			0x20
-- 
2.8.1

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

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

* [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions
  2016-08-03 19:11 [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY Daniel Vetter
@ 2016-08-03 19:11 ` Daniel Vetter
  2016-08-04  7:37   ` David Herrmann
  2016-08-04  7:37   ` Frank Binns
  2016-08-04  7:22 ` [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY Frank Binns
  2016-08-04  7:32 ` David Herrmann
  2 siblings, 2 replies; 10+ messages in thread
From: Daniel Vetter @ 2016-08-03 19:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Daniel Vetter

Except for nouveau, only legacy drivers need this really. And nouveau
is already marked up with DRIVER_KMS_LEGACY_CONTEXT as the special
case.

I've tried to be careful to leave everything related to modeset still
using the DRIVER_MODESET flag. Otherwise it's a direct replacement of
!DRIVER_MODESET with DRIVER_LEGACY checks. Also helps readability
since fewer negative checks overall.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_agpsupport.c |  6 ++----
 drivers/gpu/drm/drm_auth.c       |  2 +-
 drivers/gpu/drm/drm_bufs.c       | 22 +++++++++++-----------
 drivers/gpu/drm/drm_context.c    | 24 ++++++++++++------------
 drivers/gpu/drm/drm_dma.c        |  6 ++----
 drivers/gpu/drm/drm_fops.c       |  6 +++---
 drivers/gpu/drm/drm_ioctl.c      |  4 ++--
 drivers/gpu/drm/drm_irq.c        | 10 +++++-----
 drivers/gpu/drm/drm_lock.c       |  4 ++--
 drivers/gpu/drm/drm_pci.c        |  8 ++++----
 drivers/gpu/drm/drm_scatter.c    |  6 +++---
 11 files changed, 47 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 605bd243fb36..d621c8a4cf00 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -430,9 +430,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
  * intact so it can still be used. It is safe to call this if AGP is disabled or
  * was already removed.
  *
- * If DRIVER_MODESET is active, nothing is done to protect the modesetting
- * resources from getting destroyed. Drivers are responsible of cleaning them up
- * during device shutdown.
+ * Cleanup is only done for drivers who have DRIVER_LEGACY set.
  */
 void drm_legacy_agp_clear(struct drm_device *dev)
 {
@@ -440,7 +438,7 @@ void drm_legacy_agp_clear(struct drm_device *dev)
 
 	if (!dev->agp)
 		return;
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 4153e8a193af..6b143514a566 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -251,7 +251,7 @@ void drm_master_release(struct drm_file *file_priv)
 	if (!drm_is_current_master(file_priv))
 		goto out;
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		/*
 		 * Since the master is disappearing, so is the
 		 * possibility to lock.
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index c3a12cd8bd0d..32191513e82d 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -397,7 +397,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
 		return -EPERM;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	err = drm_addmap_core(dev, map->offset, map->size, map->type,
@@ -443,7 +443,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
 	int i;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	idx = map->offset;
@@ -545,7 +545,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
 void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
 {
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -558,7 +558,7 @@ void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
 {
 	struct drm_map_list *r_list, *list_temp;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -595,7 +595,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
 	int ret;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	mutex_lock(&dev->struct_mutex);
@@ -1220,7 +1220,7 @@ int drm_legacy_addbufs(struct drm_device *dev, void *data,
 	struct drm_buf_desc *request = data;
 	int ret;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@@ -1266,7 +1266,7 @@ int drm_legacy_infobufs(struct drm_device *dev, void *data,
 	int i;
 	int count;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@@ -1347,7 +1347,7 @@ int drm_legacy_markbufs(struct drm_device *dev, void *data,
 	int order;
 	struct drm_buf_entry *entry;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@@ -1395,7 +1395,7 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
 	int idx;
 	struct drm_buf *buf;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@@ -1450,7 +1450,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
 	struct drm_buf_map *request = data;
 	int i;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@@ -1530,7 +1530,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
 int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
 		  struct drm_file *file_priv)
 {
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (dev->driver->dma_ioctl)
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index 192a5f9eeb74..3c4000facb36 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -54,7 +54,7 @@ struct drm_ctx_list {
 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
 {
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -92,7 +92,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
 void drm_legacy_ctxbitmap_init(struct drm_device * dev)
 {
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	idr_init(&dev->ctx_idr);
@@ -109,7 +109,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
 {
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->struct_mutex);
@@ -131,7 +131,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
 	struct drm_ctx_list *pos, *tmp;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	mutex_lock(&dev->ctxlist_mutex);
@@ -177,7 +177,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
 	struct drm_map_list *_entry;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	mutex_lock(&dev->struct_mutex);
@@ -225,7 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
 	struct drm_map_list *r_list = NULL;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	mutex_lock(&dev->struct_mutex);
@@ -329,7 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
 	int i;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (res->count >= DRM_RESERVED_CONTEXTS) {
@@ -363,7 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
 	struct drm_ctx *ctx = data;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	ctx->handle = drm_legacy_ctxbitmap_next(dev);
@@ -410,7 +410,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
 	struct drm_ctx *ctx = data;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	/* This is 0, because we don't handle any context flags */
@@ -436,7 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
 	struct drm_ctx *ctx = data;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	DRM_DEBUG("%d\n", ctx->handle);
@@ -460,7 +460,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
 	struct drm_ctx *ctx = data;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	DRM_DEBUG("%d\n", ctx->handle);
@@ -486,7 +486,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
 	struct drm_ctx *ctx = data;
 
 	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
-	    drm_core_check_feature(dev, DRIVER_MODESET))
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	DRM_DEBUG("%d\n", ctx->handle);
diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
index ea481800ef56..3f83e2ca80ad 100644
--- a/drivers/gpu/drm/drm_dma.c
+++ b/drivers/gpu/drm/drm_dma.c
@@ -50,9 +50,8 @@ int drm_legacy_dma_setup(struct drm_device *dev)
 	int i;
 
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
-	    drm_core_check_feature(dev, DRIVER_MODESET)) {
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return 0;
-	}
 
 	dev->buf_use = 0;
 	atomic_set(&dev->buf_alloc, 0);
@@ -81,9 +80,8 @@ void drm_legacy_dma_takedown(struct drm_device *dev)
 	int i, j;
 
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
-	    drm_core_check_feature(dev, DRIVER_MODESET)) {
+	    !drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
-	}
 
 	if (!dma)
 		return;
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 323c238fcac7..036cd275c53e 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -92,7 +92,7 @@ static int drm_setup(struct drm_device * dev)
 	int ret;
 
 	if (dev->driver->firstopen &&
-	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
+	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		ret = dev->driver->firstopen(dev);
 		if (ret != 0)
 			return ret;
@@ -346,7 +346,7 @@ void drm_lastclose(struct drm_device * dev)
 		dev->driver->lastclose(dev);
 	DRM_DEBUG("driver lastclose completed\n");
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		drm_legacy_dev_reinit(dev);
 }
 
@@ -389,7 +389,7 @@ int drm_release(struct inode *inode, struct file *filp)
 		  (long)old_encode_dev(file_priv->minor->kdev->devt),
 		  dev->open_count);
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		drm_legacy_lock_release(dev, filp);
 
 	if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 5085fd90f74d..0663a92922a8 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -714,9 +714,9 @@ long drm_ioctl(struct file *filp,
 	if (ksize > in_size)
 		memset(kdata + in_size, 0, ksize - in_size);
 
-	/* Enforce sane locking for kms driver ioctls. Core ioctls are
+	/* Enforce sane locking for modern driver ioctls. Core ioctls are
 	 * too messy still. */
-	if ((drm_core_check_feature(dev, DRIVER_MODESET) && is_driver_ioctl) ||
+	if ((!drm_core_check_feature(dev, DRIVER_LEGACY) && is_driver_ioctl) ||
 	    (ioctl->flags & DRM_UNLOCKED))
 		retcode = func(dev, kdata, file_priv);
 	else {
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index a33465d8e133..d6d022b7c29b 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -482,7 +482,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
 		return ret;
 	}
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		vga_client_register(dev->pdev, (void *)dev, drm_irq_vgaarb_nokms, NULL);
 
 	/* After installing handler */
@@ -491,7 +491,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
 
 	if (ret < 0) {
 		dev->irq_enabled = false;
-		if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		if (drm_core_check_feature(dev, DRIVER_LEGACY))
 			vga_client_register(dev->pdev, NULL, NULL, NULL);
 		free_irq(irq, dev);
 	} else {
@@ -557,7 +557,7 @@ int drm_irq_uninstall(struct drm_device *dev)
 
 	DRM_DEBUG("irq=%d\n", dev->irq);
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		vga_client_register(dev->pdev, NULL, NULL, NULL);
 
 	if (dev->driver->irq_uninstall)
@@ -592,7 +592,7 @@ int drm_control(struct drm_device *dev, void *data,
 
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
 		return 0;
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return 0;
 	/* UMS was only ever supported on pci devices. */
 	if (WARN_ON(!dev->pdev))
@@ -1488,7 +1488,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data,
 		return 0;
 
 	/* KMS drivers handle this internally */
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return 0;
 
 	pipe = modeset->crtc;
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index 48ac0ebbd663..c901f3c5b269 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -163,7 +163,7 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
 	struct drm_master *master = file_priv->master;
 	int ret = 0;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	++file_priv->lock_count;
@@ -252,7 +252,7 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
 	struct drm_lock *lock = data;
 	struct drm_master *master = file_priv->master;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (lock->context == DRM_KERNEL_CONTEXT) {
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index b2f8f1062d5f..d86362fc8ac6 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -175,7 +175,7 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
 {
 	struct drm_irq_busid *p = data;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	/* UMS was only ever support on PCI devices. */
@@ -263,7 +263,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 
 	/* No locking needed since shadow-attach is single-threaded since it may
 	 * only be called from the per-driver module init hook. */
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
 
 	return 0;
@@ -299,7 +299,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
 
 	DRM_DEBUG("\n");
 
-	if (driver->driver_features & DRIVER_MODESET)
+	if (!(driver->driver_features & DRIVER_LEGACY))
 		return pci_register_driver(pdriver);
 
 	/* If not using KMS, fall back to stealth mode manual scanning. */
@@ -421,7 +421,7 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
 	struct drm_device *dev, *tmp;
 	DRM_DEBUG("\n");
 
-	if (driver->driver_features & DRIVER_MODESET) {
+	if (!(driver->driver_features & DRIVER_LEGACY)) {
 		pci_unregister_driver(pdriver);
 	} else {
 		list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
index bf70431073f6..275bca44f38c 100644
--- a/drivers/gpu/drm/drm_scatter.c
+++ b/drivers/gpu/drm/drm_scatter.c
@@ -68,7 +68,7 @@ static void drm_sg_cleanup(struct drm_sg_mem * entry)
 void drm_legacy_sg_cleanup(struct drm_device *dev)
 {
 	if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
-	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
+	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		drm_sg_cleanup(dev->sg);
 		dev->sg = NULL;
 	}
@@ -88,7 +88,7 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 
 	DRM_DEBUG("\n");
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (!drm_core_check_feature(dev, DRIVER_SG))
@@ -201,7 +201,7 @@ int drm_legacy_sg_free(struct drm_device *dev, void *data,
 	struct drm_scatter_gather *request = data;
 	struct drm_sg_mem *entry;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (!drm_core_check_feature(dev, DRIVER_SG))
-- 
2.8.1

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

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

* Re: [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY
  2016-08-03 19:11 [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY Daniel Vetter
  2016-08-03 19:11 ` [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions Daniel Vetter
@ 2016-08-04  7:22 ` Frank Binns
  2016-08-04  7:32 ` David Herrmann
  2 siblings, 0 replies; 10+ messages in thread
From: Frank Binns @ 2016-08-04  7:22 UTC (permalink / raw)
  To: Daniel Vetter, DRI Development; +Cc: Daniel Vetter

On 03/08/16 20:11, Daniel Vetter wrote:
> It's super confusing that new drivers need to be marked with
> DRIVER_MODESET when really it means DRIVER_MODERN. Much better to
> invert the meaning and rename it to something that's suitably
> off-putting.
>
> Since there's over 100 places using DRIVER_MODESET we need to roll out
> this change without a flag day.
>
> v2: Update docs.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Reviewed-by: Frank Binns <frank.binns@imgtec.com>

> ---
>   Documentation/gpu/drm-internals.rst | 9 ++++++---
>   drivers/gpu/drm/i810/i810_drv.c     | 4 +---
>   drivers/gpu/drm/mga/mga_drv.c       | 2 +-
>   drivers/gpu/drm/r128/r128_drv.c     | 2 +-
>   drivers/gpu/drm/savage/savage_drv.c | 2 +-
>   drivers/gpu/drm/sis/sis_drv.c       | 2 +-
>   drivers/gpu/drm/tdfx/tdfx_drv.c     | 1 +
>   drivers/gpu/drm/via/via_drv.c       | 2 +-
>   include/drm/drmP.h                  | 1 +
>   9 files changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst
> index 3bb26135971f..37284bcc7764 100644
> --- a/Documentation/gpu/drm-internals.rst
> +++ b/Documentation/gpu/drm-internals.rst
> @@ -53,9 +53,12 @@ u32 driver_features;
>   DRIVER_USE_AGP
>       Driver uses AGP interface, the DRM core will manage AGP resources.
>   
> -DRIVER_REQUIRE_AGP
> -    Driver needs AGP interface to function. AGP initialization failure
> -    will become a fatal error.
> +DRIVER_LEGACY
> +    Denote a legacy driver using shadow attach. Don't use.
> +
> +DRIVER_KMS_LEGACY_CONTEXT
> +    Used only by nouveau for backwards compatibility with existing userspace.
> +    Don't use.
>   
>   DRIVER_PCI_DMA
>       Driver is capable of PCI DMA, mapping of PCI DMA buffers to
> diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
> index 44f4a131c8dd..0be55dc1ef4b 100644
> --- a/drivers/gpu/drm/i810/i810_drv.c
> +++ b/drivers/gpu/drm/i810/i810_drv.c
> @@ -56,9 +56,7 @@ static const struct file_operations i810_driver_fops = {
>   };
>   
>   static struct drm_driver driver = {
> -	.driver_features =
> -	    DRIVER_USE_AGP |
> -	    DRIVER_HAVE_DMA,
> +	.driver_features = DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_LEGACY,
>   	.dev_priv_size = sizeof(drm_i810_buf_priv_t),
>   	.load = i810_driver_load,
>   	.lastclose = i810_driver_lastclose,
> diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
> index 5e2f131a6a72..25b2a1a424e6 100644
> --- a/drivers/gpu/drm/mga/mga_drv.c
> +++ b/drivers/gpu/drm/mga/mga_drv.c
> @@ -58,7 +58,7 @@ static const struct file_operations mga_driver_fops = {
>   
>   static struct drm_driver driver = {
>   	.driver_features =
> -	    DRIVER_USE_AGP | DRIVER_PCI_DMA |
> +	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_LEGACY |
>   	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
>   	.dev_priv_size = sizeof(drm_mga_buf_priv_t),
>   	.load = mga_driver_load,
> diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
> index c57b4de63caf..a982be57d1ef 100644
> --- a/drivers/gpu/drm/r128/r128_drv.c
> +++ b/drivers/gpu/drm/r128/r128_drv.c
> @@ -56,7 +56,7 @@ static const struct file_operations r128_driver_fops = {
>   
>   static struct drm_driver driver = {
>   	.driver_features =
> -	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
> +	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_LEGACY |
>   	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
>   	.dev_priv_size = sizeof(drm_r128_buf_priv_t),
>   	.load = r128_driver_load,
> diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
> index 21aed1febeb4..3b807135a5cd 100644
> --- a/drivers/gpu/drm/savage/savage_drv.c
> +++ b/drivers/gpu/drm/savage/savage_drv.c
> @@ -50,7 +50,7 @@ static const struct file_operations savage_driver_fops = {
>   
>   static struct drm_driver driver = {
>   	.driver_features =
> -	    DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA,
> +	    DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA | DRIVER_LEGACY,
>   	.dev_priv_size = sizeof(drm_savage_buf_priv_t),
>   	.load = savage_driver_load,
>   	.firstopen = savage_driver_firstopen,
> diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
> index 79bce76cb8f7..ae9839886c4d 100644
> --- a/drivers/gpu/drm/sis/sis_drv.c
> +++ b/drivers/gpu/drm/sis/sis_drv.c
> @@ -102,7 +102,7 @@ static void sis_driver_postclose(struct drm_device *dev, struct drm_file *file)
>   }
>   
>   static struct drm_driver driver = {
> -	.driver_features = DRIVER_USE_AGP,
> +	.driver_features = DRIVER_USE_AGP | DRIVER_LEGACY,
>   	.load = sis_driver_load,
>   	.unload = sis_driver_unload,
>   	.open = sis_driver_open,
> diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
> index fab5ebcb0fef..f418892b0c71 100644
> --- a/drivers/gpu/drm/tdfx/tdfx_drv.c
> +++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
> @@ -56,6 +56,7 @@ static const struct file_operations tdfx_driver_fops = {
>   };
>   
>   static struct drm_driver driver = {
> +	.driver_features = DRIVER_LEGACY,
>   	.set_busid = drm_pci_set_busid,
>   	.fops = &tdfx_driver_fops,
>   	.name = DRIVER_NAME,
> diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
> index ed8aa8ff861a..e5582bab7e3c 100644
> --- a/drivers/gpu/drm/via/via_drv.c
> +++ b/drivers/gpu/drm/via/via_drv.c
> @@ -72,7 +72,7 @@ static const struct file_operations via_driver_fops = {
>   
>   static struct drm_driver driver = {
>   	.driver_features =
> -	    DRIVER_USE_AGP | DRIVER_HAVE_IRQ |
> +	    DRIVER_USE_AGP | DRIVER_HAVE_IRQ | DRIVER_LEGACY |
>   	    DRIVER_IRQ_SHARED,
>   	.load = via_driver_load,
>   	.unload = via_driver_unload,
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 5f9caf7ee949..9c828d6f7cdc 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -146,6 +146,7 @@ void drm_err(const char *format, ...);
>   
>   /* driver capabilities and requirements mask */
>   #define DRIVER_USE_AGP			0x1
> +#define DRIVER_LEGACY			0x2
>   #define DRIVER_PCI_DMA			0x8
>   #define DRIVER_SG			0x10
>   #define DRIVER_HAVE_DMA			0x20

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

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

* Re: [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY
  2016-08-03 19:11 [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY Daniel Vetter
  2016-08-03 19:11 ` [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions Daniel Vetter
  2016-08-04  7:22 ` [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY Frank Binns
@ 2016-08-04  7:32 ` David Herrmann
  2016-08-04  7:37   ` Chris Wilson
  2 siblings, 1 reply; 10+ messages in thread
From: David Herrmann @ 2016-08-04  7:32 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, DRI Development

Hi

On Wed, Aug 3, 2016 at 9:11 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> It's super confusing that new drivers need to be marked with
> DRIVER_MODESET when really it means DRIVER_MODERN. Much better to
> invert the meaning and rename it to something that's suitably
> off-putting.
>
> Since there's over 100 places using DRIVER_MODESET we need to roll out
> this change without a flag day.
>
> v2: Update docs.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  Documentation/gpu/drm-internals.rst | 9 ++++++---
>  drivers/gpu/drm/i810/i810_drv.c     | 4 +---
>  drivers/gpu/drm/mga/mga_drv.c       | 2 +-
>  drivers/gpu/drm/r128/r128_drv.c     | 2 +-
>  drivers/gpu/drm/savage/savage_drv.c | 2 +-
>  drivers/gpu/drm/sis/sis_drv.c       | 2 +-
>  drivers/gpu/drm/tdfx/tdfx_drv.c     | 1 +
>  drivers/gpu/drm/via/via_drv.c       | 2 +-
>  include/drm/drmP.h                  | 1 +
>  9 files changed, 14 insertions(+), 11 deletions(-)

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

Also, how about this:


diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index fc35731..e609cfc 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -111,6 +111,7 @@ source "drivers/gpu/drm/i2c/Kconfig"
 config DRM_TDFX
  tristate "3dfx Banshee/Voodoo3+"
  depends on DRM && PCI
+ depends on BROKEN
  help
   Choose this option if you have a 3dfx Banshee or Voodoo3 (or later),
   graphics card.  If M is selected, the module will be called tdfx.
@@ -120,6 +121,7 @@ source "drivers/gpu/drm/arm/Kconfig"
 config DRM_R128
  tristate "ATI Rage 128"
  depends on DRM && PCI
+ depends on BROKEN
  select FW_LOADER
  help
   Choose this option if you have an ATI Rage 128 graphics card.  If M
@@ -181,6 +183,7 @@ config DRM_I810
  tristate "Intel I810"
  # !PREEMPT because of missing ioctl locking
  depends on DRM && AGP && AGP_INTEL && (!PREEMPT || BROKEN)
+ depends on BROKEN
  help
   Choose this option if you have an Intel I810 graphics card.  If M is
   selected, the module will be called i810.  AGP support is required
@@ -191,6 +194,7 @@ source "drivers/gpu/drm/i915/Kconfig"
 config DRM_MGA
  tristate "Matrox g200/g400"
  depends on DRM && PCI
+ depends on BROKEN
  select FW_LOADER
  help
   Choose this option if you have a Matrox G200, G400 or G450 graphics
@@ -201,6 +205,7 @@ config DRM_SIS
  tristate "SiS video cards"
  depends on DRM && AGP
  depends on FB_SIS || FB_SIS=n
+ depends on BROKEN
  help
   Choose this option if you have a SiS 630 or compatible video
           chipset. If M is selected the module will be called sis. AGP
@@ -209,6 +214,7 @@ config DRM_SIS
 config DRM_VIA
  tristate "Via unichrome video cards"
  depends on DRM && PCI
+ depends on BROKEN
  help
   Choose this option if you have a Via unichrome or compatible video
   chipset. If M is selected the module will be called via.
@@ -216,6 +222,7 @@ config DRM_VIA
 config DRM_SAVAGE
  tristate "Savage video cards"
  depends on DRM && PCI
+ depends on BROKEN
  help
   Choose this option if you have a Savage3D/4/SuperSavage/Pro/Twister
   chipset. If M is selected the module will be called savage.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions
  2016-08-03 19:11 ` [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions Daniel Vetter
@ 2016-08-04  7:37   ` David Herrmann
  2016-08-04  7:37   ` Frank Binns
  1 sibling, 0 replies; 10+ messages in thread
From: David Herrmann @ 2016-08-04  7:37 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, DRI Development

Hi

On Wed, Aug 3, 2016 at 9:11 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Except for nouveau, only legacy drivers need this really. And nouveau
> is already marked up with DRIVER_KMS_LEGACY_CONTEXT as the special
> case.
>
> I've tried to be careful to leave everything related to modeset still
> using the DRIVER_MODESET flag. Otherwise it's a direct replacement of
> !DRIVER_MODESET with DRIVER_LEGACY checks. Also helps readability
> since fewer negative checks overall.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_agpsupport.c |  6 ++----
>  drivers/gpu/drm/drm_auth.c       |  2 +-
>  drivers/gpu/drm/drm_bufs.c       | 22 +++++++++++-----------
>  drivers/gpu/drm/drm_context.c    | 24 ++++++++++++------------
>  drivers/gpu/drm/drm_dma.c        |  6 ++----
>  drivers/gpu/drm/drm_fops.c       |  6 +++---
>  drivers/gpu/drm/drm_ioctl.c      |  4 ++--
>  drivers/gpu/drm/drm_irq.c        | 10 +++++-----
>  drivers/gpu/drm/drm_lock.c       |  4 ++--
>  drivers/gpu/drm/drm_pci.c        |  8 ++++----
>  drivers/gpu/drm/drm_scatter.c    |  6 +++---
>  11 files changed, 47 insertions(+), 51 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
> index 605bd243fb36..d621c8a4cf00 100644
> --- a/drivers/gpu/drm/drm_agpsupport.c
> +++ b/drivers/gpu/drm/drm_agpsupport.c
> @@ -430,9 +430,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
>   * intact so it can still be used. It is safe to call this if AGP is disabled or
>   * was already removed.
>   *
> - * If DRIVER_MODESET is active, nothing is done to protect the modesetting
> - * resources from getting destroyed. Drivers are responsible of cleaning them up
> - * during device shutdown.
> + * Cleanup is only done for drivers who have DRIVER_LEGACY set.
>   */
>  void drm_legacy_agp_clear(struct drm_device *dev)
>  {
> @@ -440,7 +438,7 @@ void drm_legacy_agp_clear(struct drm_device *dev)
>
>         if (!dev->agp)
>                 return;
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
> diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
> index 4153e8a193af..6b143514a566 100644
> --- a/drivers/gpu/drm/drm_auth.c
> +++ b/drivers/gpu/drm/drm_auth.c
> @@ -251,7 +251,7 @@ void drm_master_release(struct drm_file *file_priv)
>         if (!drm_is_current_master(file_priv))
>                 goto out;
>
> -       if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
> +       if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
>                 /*
>                  * Since the master is disappearing, so is the
>                  * possibility to lock.
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index c3a12cd8bd0d..32191513e82d 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -397,7 +397,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>                 return -EPERM;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         err = drm_addmap_core(dev, map->offset, map->size, map->type,
> @@ -443,7 +443,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>         int i;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         idx = map->offset;
> @@ -545,7 +545,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>  void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>  {
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -558,7 +558,7 @@ void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
>  {
>         struct drm_map_list *r_list, *list_temp;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -595,7 +595,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>         int ret;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -1220,7 +1220,7 @@ int drm_legacy_addbufs(struct drm_device *dev, void *data,
>         struct drm_buf_desc *request = data;
>         int ret;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1266,7 +1266,7 @@ int drm_legacy_infobufs(struct drm_device *dev, void *data,
>         int i;
>         int count;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1347,7 +1347,7 @@ int drm_legacy_markbufs(struct drm_device *dev, void *data,
>         int order;
>         struct drm_buf_entry *entry;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1395,7 +1395,7 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
>         int idx;
>         struct drm_buf *buf;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1450,7 +1450,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
>         struct drm_buf_map *request = data;
>         int i;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1530,7 +1530,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
>  int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
>                   struct drm_file *file_priv)
>  {
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (dev->driver->dma_ioctl)
> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> index 192a5f9eeb74..3c4000facb36 100644
> --- a/drivers/gpu/drm/drm_context.c
> +++ b/drivers/gpu/drm/drm_context.c
> @@ -54,7 +54,7 @@ struct drm_ctx_list {
>  void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>  {
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -92,7 +92,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
>  void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>  {
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         idr_init(&dev->ctx_idr);
> @@ -109,7 +109,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>  void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>  {
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -131,7 +131,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
>         struct drm_ctx_list *pos, *tmp;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
>
>         mutex_lock(&dev->ctxlist_mutex);
> @@ -177,7 +177,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
>         struct drm_map_list *_entry;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -225,7 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
>         struct drm_map_list *r_list = NULL;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         mutex_lock(&dev->struct_mutex);
> @@ -329,7 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>         int i;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (res->count >= DRM_RESERVED_CONTEXTS) {
> @@ -363,7 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>         struct drm_ctx *ctx = data;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         ctx->handle = drm_legacy_ctxbitmap_next(dev);
> @@ -410,7 +410,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>         struct drm_ctx *ctx = data;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         /* This is 0, because we don't handle any context flags */
> @@ -436,7 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
>         struct drm_ctx *ctx = data;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         DRM_DEBUG("%d\n", ctx->handle);
> @@ -460,7 +460,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
>         struct drm_ctx *ctx = data;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         DRM_DEBUG("%d\n", ctx->handle);
> @@ -486,7 +486,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
>         struct drm_ctx *ctx = data;
>
>         if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -           drm_core_check_feature(dev, DRIVER_MODESET))
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         DRM_DEBUG("%d\n", ctx->handle);
> diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
> index ea481800ef56..3f83e2ca80ad 100644
> --- a/drivers/gpu/drm/drm_dma.c
> +++ b/drivers/gpu/drm/drm_dma.c
> @@ -50,9 +50,8 @@ int drm_legacy_dma_setup(struct drm_device *dev)
>         int i;
>
>         if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
> -           drm_core_check_feature(dev, DRIVER_MODESET)) {
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return 0;
> -       }
>
>         dev->buf_use = 0;
>         atomic_set(&dev->buf_alloc, 0);
> @@ -81,9 +80,8 @@ void drm_legacy_dma_takedown(struct drm_device *dev)
>         int i, j;
>
>         if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
> -           drm_core_check_feature(dev, DRIVER_MODESET)) {
> +           !drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return;
> -       }

Both these DRIVER_HAVE_DMA checks are sufficient without the
DRIVER_MODESET/LEGACY checks. I mean, the entire HAVE_DMA flag is
legacy-only. But that's for a future cleanup to rename HAVE_DMA to
LEGACY_DMA.

This patch is:

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

Thanks
David

>
>         if (!dma)
>                 return;
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 323c238fcac7..036cd275c53e 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -92,7 +92,7 @@ static int drm_setup(struct drm_device * dev)
>         int ret;
>
>         if (dev->driver->firstopen &&
> -           !drm_core_check_feature(dev, DRIVER_MODESET)) {
> +           drm_core_check_feature(dev, DRIVER_LEGACY)) {
>                 ret = dev->driver->firstopen(dev);
>                 if (ret != 0)
>                         return ret;
> @@ -346,7 +346,7 @@ void drm_lastclose(struct drm_device * dev)
>                 dev->driver->lastclose(dev);
>         DRM_DEBUG("driver lastclose completed\n");
>
> -       if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (drm_core_check_feature(dev, DRIVER_LEGACY))
>                 drm_legacy_dev_reinit(dev);
>  }
>
> @@ -389,7 +389,7 @@ int drm_release(struct inode *inode, struct file *filp)
>                   (long)old_encode_dev(file_priv->minor->kdev->devt),
>                   dev->open_count);
>
> -       if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (drm_core_check_feature(dev, DRIVER_LEGACY))
>                 drm_legacy_lock_release(dev, filp);
>
>         if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 5085fd90f74d..0663a92922a8 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -714,9 +714,9 @@ long drm_ioctl(struct file *filp,
>         if (ksize > in_size)
>                 memset(kdata + in_size, 0, ksize - in_size);
>
> -       /* Enforce sane locking for kms driver ioctls. Core ioctls are
> +       /* Enforce sane locking for modern driver ioctls. Core ioctls are
>          * too messy still. */
> -       if ((drm_core_check_feature(dev, DRIVER_MODESET) && is_driver_ioctl) ||
> +       if ((!drm_core_check_feature(dev, DRIVER_LEGACY) && is_driver_ioctl) ||
>             (ioctl->flags & DRM_UNLOCKED))
>                 retcode = func(dev, kdata, file_priv);
>         else {
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index a33465d8e133..d6d022b7c29b 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -482,7 +482,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
>                 return ret;
>         }
>
> -       if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (drm_core_check_feature(dev, DRIVER_LEGACY))
>                 vga_client_register(dev->pdev, (void *)dev, drm_irq_vgaarb_nokms, NULL);
>
>         /* After installing handler */
> @@ -491,7 +491,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
>
>         if (ret < 0) {
>                 dev->irq_enabled = false;
> -               if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +               if (drm_core_check_feature(dev, DRIVER_LEGACY))
>                         vga_client_register(dev->pdev, NULL, NULL, NULL);
>                 free_irq(irq, dev);
>         } else {
> @@ -557,7 +557,7 @@ int drm_irq_uninstall(struct drm_device *dev)
>
>         DRM_DEBUG("irq=%d\n", dev->irq);
>
> -       if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (drm_core_check_feature(dev, DRIVER_LEGACY))
>                 vga_client_register(dev->pdev, NULL, NULL, NULL);
>
>         if (dev->driver->irq_uninstall)
> @@ -592,7 +592,7 @@ int drm_control(struct drm_device *dev, void *data,
>
>         if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
>                 return 0;
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return 0;
>         /* UMS was only ever supported on pci devices. */
>         if (WARN_ON(!dev->pdev))
> @@ -1488,7 +1488,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data,
>                 return 0;
>
>         /* KMS drivers handle this internally */
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return 0;
>
>         pipe = modeset->crtc;
> diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
> index 48ac0ebbd663..c901f3c5b269 100644
> --- a/drivers/gpu/drm/drm_lock.c
> +++ b/drivers/gpu/drm/drm_lock.c
> @@ -163,7 +163,7 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
>         struct drm_master *master = file_priv->master;
>         int ret = 0;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         ++file_priv->lock_count;
> @@ -252,7 +252,7 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
>         struct drm_lock *lock = data;
>         struct drm_master *master = file_priv->master;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (lock->context == DRM_KERNEL_CONTEXT) {
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index b2f8f1062d5f..d86362fc8ac6 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -175,7 +175,7 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
>  {
>         struct drm_irq_busid *p = data;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         /* UMS was only ever support on PCI devices. */
> @@ -263,7 +263,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
>
>         /* No locking needed since shadow-attach is single-threaded since it may
>          * only be called from the per-driver module init hook. */
> -       if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (drm_core_check_feature(dev, DRIVER_LEGACY))
>                 list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
>
>         return 0;
> @@ -299,7 +299,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
>
>         DRM_DEBUG("\n");
>
> -       if (driver->driver_features & DRIVER_MODESET)
> +       if (!(driver->driver_features & DRIVER_LEGACY))
>                 return pci_register_driver(pdriver);
>
>         /* If not using KMS, fall back to stealth mode manual scanning. */
> @@ -421,7 +421,7 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
>         struct drm_device *dev, *tmp;
>         DRM_DEBUG("\n");
>
> -       if (driver->driver_features & DRIVER_MODESET) {
> +       if (!(driver->driver_features & DRIVER_LEGACY)) {
>                 pci_unregister_driver(pdriver);
>         } else {
>                 list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
> diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
> index bf70431073f6..275bca44f38c 100644
> --- a/drivers/gpu/drm/drm_scatter.c
> +++ b/drivers/gpu/drm/drm_scatter.c
> @@ -68,7 +68,7 @@ static void drm_sg_cleanup(struct drm_sg_mem * entry)
>  void drm_legacy_sg_cleanup(struct drm_device *dev)
>  {
>         if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
> -           !drm_core_check_feature(dev, DRIVER_MODESET)) {
> +           drm_core_check_feature(dev, DRIVER_LEGACY)) {
>                 drm_sg_cleanup(dev->sg);
>                 dev->sg = NULL;
>         }
> @@ -88,7 +88,7 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
>
>         DRM_DEBUG("\n");
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (!drm_core_check_feature(dev, DRIVER_SG))
> @@ -201,7 +201,7 @@ int drm_legacy_sg_free(struct drm_device *dev, void *data,
>         struct drm_scatter_gather *request = data;
>         struct drm_sg_mem *entry;
>
> -       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>                 return -EINVAL;
>
>         if (!drm_core_check_feature(dev, DRIVER_SG))
> --
> 2.8.1
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY
  2016-08-04  7:32 ` David Herrmann
@ 2016-08-04  7:37   ` Chris Wilson
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2016-08-04  7:37 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

On Thu, Aug 04, 2016 at 09:32:01AM +0200, David Herrmann wrote:
> Hi
> 
> On Wed, Aug 3, 2016 at 9:11 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> > It's super confusing that new drivers need to be marked with
> > DRIVER_MODESET when really it means DRIVER_MODERN. Much better to
> > invert the meaning and rename it to something that's suitably
> > off-putting.
> >
> > Since there's over 100 places using DRIVER_MODESET we need to roll out
> > this change without a flag day.
> >
> > v2: Update docs.
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> >  Documentation/gpu/drm-internals.rst | 9 ++++++---
> >  drivers/gpu/drm/i810/i810_drv.c     | 4 +---
> >  drivers/gpu/drm/mga/mga_drv.c       | 2 +-
> >  drivers/gpu/drm/r128/r128_drv.c     | 2 +-
> >  drivers/gpu/drm/savage/savage_drv.c | 2 +-
> >  drivers/gpu/drm/sis/sis_drv.c       | 2 +-
> >  drivers/gpu/drm/tdfx/tdfx_drv.c     | 1 +
> >  drivers/gpu/drm/via/via_drv.c       | 2 +-
> >  include/drm/drmP.h                  | 1 +
> >  9 files changed, 14 insertions(+), 11 deletions(-)
> 
> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
> 
> Also, how about this:

config DRM_LEGACY
	bool "Enable legacy drivers (DANGEROUS)"
	depends on DRM
	depends on BROKEN
	help
	  ...

Then everyone else gets depends on DRM_LEGACY. The benefit is that we
get the chance to add a useful help message and hopefully explains the
situation more cleary to devs.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions
  2016-08-03 19:11 ` [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions Daniel Vetter
  2016-08-04  7:37   ` David Herrmann
@ 2016-08-04  7:37   ` Frank Binns
  2016-08-04  8:20     ` Daniel Vetter
  1 sibling, 1 reply; 10+ messages in thread
From: Frank Binns @ 2016-08-04  7:37 UTC (permalink / raw)
  To: Daniel Vetter, DRI Development; +Cc: Daniel Vetter

On 03/08/16 20:11, Daniel Vetter wrote:
> Except for nouveau, only legacy drivers need this really. And nouveau
> is already marked up with DRIVER_KMS_LEGACY_CONTEXT as the special
> case.
>
> I've tried to be careful to leave everything related to modeset still
> using the DRIVER_MODESET flag. Otherwise it's a direct replacement of
> !DRIVER_MODESET with DRIVER_LEGACY checks. Also helps readability
> since fewer negative checks overall.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

I don't think this goes far enough. For example, the documentation
for the 'firstopen' callback says that it's called for legacy UMS drivers
but it does a check based on DRIVER_MODESET. There are also some
places in drm_pci.c that should be changed as well.

Anyway, this is progress so:
Reviewed-by: Frank Binns <frank.binns@imgtec.com>

> ---
>   drivers/gpu/drm/drm_agpsupport.c |  6 ++----
>   drivers/gpu/drm/drm_auth.c       |  2 +-
>   drivers/gpu/drm/drm_bufs.c       | 22 +++++++++++-----------
>   drivers/gpu/drm/drm_context.c    | 24 ++++++++++++------------
>   drivers/gpu/drm/drm_dma.c        |  6 ++----
>   drivers/gpu/drm/drm_fops.c       |  6 +++---
>   drivers/gpu/drm/drm_ioctl.c      |  4 ++--
>   drivers/gpu/drm/drm_irq.c        | 10 +++++-----
>   drivers/gpu/drm/drm_lock.c       |  4 ++--
>   drivers/gpu/drm/drm_pci.c        |  8 ++++----
>   drivers/gpu/drm/drm_scatter.c    |  6 +++---
>   11 files changed, 47 insertions(+), 51 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
> index 605bd243fb36..d621c8a4cf00 100644
> --- a/drivers/gpu/drm/drm_agpsupport.c
> +++ b/drivers/gpu/drm/drm_agpsupport.c
> @@ -430,9 +430,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
>    * intact so it can still be used. It is safe to call this if AGP is disabled or
>    * was already removed.
>    *
> - * If DRIVER_MODESET is active, nothing is done to protect the modesetting
> - * resources from getting destroyed. Drivers are responsible of cleaning them up
> - * during device shutdown.
> + * Cleanup is only done for drivers who have DRIVER_LEGACY set.
>    */
>   void drm_legacy_agp_clear(struct drm_device *dev)
>   {
> @@ -440,7 +438,7 @@ void drm_legacy_agp_clear(struct drm_device *dev)
>   
>   	if (!dev->agp)
>   		return;
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
> diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
> index 4153e8a193af..6b143514a566 100644
> --- a/drivers/gpu/drm/drm_auth.c
> +++ b/drivers/gpu/drm/drm_auth.c
> @@ -251,7 +251,7 @@ void drm_master_release(struct drm_file *file_priv)
>   	if (!drm_is_current_master(file_priv))
>   		goto out;
>   
> -	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
> +	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
>   		/*
>   		 * Since the master is disappearing, so is the
>   		 * possibility to lock.
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index c3a12cd8bd0d..32191513e82d 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -397,7 +397,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>   		return -EPERM;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	err = drm_addmap_core(dev, map->offset, map->size, map->type,
> @@ -443,7 +443,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>   	int i;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	idx = map->offset;
> @@ -545,7 +545,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>   void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>   {
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -558,7 +558,7 @@ void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
>   {
>   	struct drm_map_list *r_list, *list_temp;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -595,7 +595,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>   	int ret;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -1220,7 +1220,7 @@ int drm_legacy_addbufs(struct drm_device *dev, void *data,
>   	struct drm_buf_desc *request = data;
>   	int ret;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1266,7 +1266,7 @@ int drm_legacy_infobufs(struct drm_device *dev, void *data,
>   	int i;
>   	int count;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1347,7 +1347,7 @@ int drm_legacy_markbufs(struct drm_device *dev, void *data,
>   	int order;
>   	struct drm_buf_entry *entry;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1395,7 +1395,7 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
>   	int idx;
>   	struct drm_buf *buf;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1450,7 +1450,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
>   	struct drm_buf_map *request = data;
>   	int i;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> @@ -1530,7 +1530,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
>   int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
>   		  struct drm_file *file_priv)
>   {
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (dev->driver->dma_ioctl)
> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> index 192a5f9eeb74..3c4000facb36 100644
> --- a/drivers/gpu/drm/drm_context.c
> +++ b/drivers/gpu/drm/drm_context.c
> @@ -54,7 +54,7 @@ struct drm_ctx_list {
>   void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>   {
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -92,7 +92,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
>   void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>   {
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	idr_init(&dev->ctx_idr);
> @@ -109,7 +109,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>   void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>   {
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -131,7 +131,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
>   	struct drm_ctx_list *pos, *tmp;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
>   
>   	mutex_lock(&dev->ctxlist_mutex);
> @@ -177,7 +177,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
>   	struct drm_map_list *_entry;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -225,7 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
>   	struct drm_map_list *r_list = NULL;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	mutex_lock(&dev->struct_mutex);
> @@ -329,7 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>   	int i;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (res->count >= DRM_RESERVED_CONTEXTS) {
> @@ -363,7 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>   	struct drm_ctx *ctx = data;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	ctx->handle = drm_legacy_ctxbitmap_next(dev);
> @@ -410,7 +410,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>   	struct drm_ctx *ctx = data;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	/* This is 0, because we don't handle any context flags */
> @@ -436,7 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
>   	struct drm_ctx *ctx = data;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	DRM_DEBUG("%d\n", ctx->handle);
> @@ -460,7 +460,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
>   	struct drm_ctx *ctx = data;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	DRM_DEBUG("%d\n", ctx->handle);
> @@ -486,7 +486,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
>   	struct drm_ctx *ctx = data;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> -	    drm_core_check_feature(dev, DRIVER_MODESET))
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	DRM_DEBUG("%d\n", ctx->handle);
> diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
> index ea481800ef56..3f83e2ca80ad 100644
> --- a/drivers/gpu/drm/drm_dma.c
> +++ b/drivers/gpu/drm/drm_dma.c
> @@ -50,9 +50,8 @@ int drm_legacy_dma_setup(struct drm_device *dev)
>   	int i;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
> -	    drm_core_check_feature(dev, DRIVER_MODESET)) {
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return 0;
> -	}
>   
>   	dev->buf_use = 0;
>   	atomic_set(&dev->buf_alloc, 0);
> @@ -81,9 +80,8 @@ void drm_legacy_dma_takedown(struct drm_device *dev)
>   	int i, j;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
> -	    drm_core_check_feature(dev, DRIVER_MODESET)) {
> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return;
> -	}
>   
>   	if (!dma)
>   		return;
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 323c238fcac7..036cd275c53e 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -92,7 +92,7 @@ static int drm_setup(struct drm_device * dev)
>   	int ret;
>   
>   	if (dev->driver->firstopen &&
> -	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
> +	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
>   		ret = dev->driver->firstopen(dev);
>   		if (ret != 0)
>   			return ret;
> @@ -346,7 +346,7 @@ void drm_lastclose(struct drm_device * dev)
>   		dev->driver->lastclose(dev);
>   	DRM_DEBUG("driver lastclose completed\n");
>   
> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>   		drm_legacy_dev_reinit(dev);
>   }
>   
> @@ -389,7 +389,7 @@ int drm_release(struct inode *inode, struct file *filp)
>   		  (long)old_encode_dev(file_priv->minor->kdev->devt),
>   		  dev->open_count);
>   
> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>   		drm_legacy_lock_release(dev, filp);
>   
>   	if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 5085fd90f74d..0663a92922a8 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -714,9 +714,9 @@ long drm_ioctl(struct file *filp,
>   	if (ksize > in_size)
>   		memset(kdata + in_size, 0, ksize - in_size);
>   
> -	/* Enforce sane locking for kms driver ioctls. Core ioctls are
> +	/* Enforce sane locking for modern driver ioctls. Core ioctls are
>   	 * too messy still. */
> -	if ((drm_core_check_feature(dev, DRIVER_MODESET) && is_driver_ioctl) ||
> +	if ((!drm_core_check_feature(dev, DRIVER_LEGACY) && is_driver_ioctl) ||
>   	    (ioctl->flags & DRM_UNLOCKED))
>   		retcode = func(dev, kdata, file_priv);
>   	else {
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index a33465d8e133..d6d022b7c29b 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -482,7 +482,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
>   		return ret;
>   	}
>   
> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>   		vga_client_register(dev->pdev, (void *)dev, drm_irq_vgaarb_nokms, NULL);
>   
>   	/* After installing handler */
> @@ -491,7 +491,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
>   
>   	if (ret < 0) {
>   		dev->irq_enabled = false;
> -		if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +		if (drm_core_check_feature(dev, DRIVER_LEGACY))
>   			vga_client_register(dev->pdev, NULL, NULL, NULL);
>   		free_irq(irq, dev);
>   	} else {
> @@ -557,7 +557,7 @@ int drm_irq_uninstall(struct drm_device *dev)
>   
>   	DRM_DEBUG("irq=%d\n", dev->irq);
>   
> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>   		vga_client_register(dev->pdev, NULL, NULL, NULL);
>   
>   	if (dev->driver->irq_uninstall)
> @@ -592,7 +592,7 @@ int drm_control(struct drm_device *dev, void *data,
>   
>   	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
>   		return 0;
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return 0;
>   	/* UMS was only ever supported on pci devices. */
>   	if (WARN_ON(!dev->pdev))
> @@ -1488,7 +1488,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data,
>   		return 0;
>   
>   	/* KMS drivers handle this internally */
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return 0;
>   
>   	pipe = modeset->crtc;
> diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
> index 48ac0ebbd663..c901f3c5b269 100644
> --- a/drivers/gpu/drm/drm_lock.c
> +++ b/drivers/gpu/drm/drm_lock.c
> @@ -163,7 +163,7 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
>   	struct drm_master *master = file_priv->master;
>   	int ret = 0;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	++file_priv->lock_count;
> @@ -252,7 +252,7 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
>   	struct drm_lock *lock = data;
>   	struct drm_master *master = file_priv->master;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (lock->context == DRM_KERNEL_CONTEXT) {
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index b2f8f1062d5f..d86362fc8ac6 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -175,7 +175,7 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
>   {
>   	struct drm_irq_busid *p = data;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	/* UMS was only ever support on PCI devices. */
> @@ -263,7 +263,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
>   
>   	/* No locking needed since shadow-attach is single-threaded since it may
>   	 * only be called from the per-driver module init hook. */
> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>   		list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
>   
>   	return 0;
> @@ -299,7 +299,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
>   
>   	DRM_DEBUG("\n");
>   
> -	if (driver->driver_features & DRIVER_MODESET)
> +	if (!(driver->driver_features & DRIVER_LEGACY))
>   		return pci_register_driver(pdriver);
>   
>   	/* If not using KMS, fall back to stealth mode manual scanning. */
> @@ -421,7 +421,7 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
>   	struct drm_device *dev, *tmp;
>   	DRM_DEBUG("\n");
>   
> -	if (driver->driver_features & DRIVER_MODESET) {
> +	if (!(driver->driver_features & DRIVER_LEGACY)) {
>   		pci_unregister_driver(pdriver);
>   	} else {
>   		list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
> diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
> index bf70431073f6..275bca44f38c 100644
> --- a/drivers/gpu/drm/drm_scatter.c
> +++ b/drivers/gpu/drm/drm_scatter.c
> @@ -68,7 +68,7 @@ static void drm_sg_cleanup(struct drm_sg_mem * entry)
>   void drm_legacy_sg_cleanup(struct drm_device *dev)
>   {
>   	if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
> -	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
> +	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
>   		drm_sg_cleanup(dev->sg);
>   		dev->sg = NULL;
>   	}
> @@ -88,7 +88,7 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
>   
>   	DRM_DEBUG("\n");
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_SG))
> @@ -201,7 +201,7 @@ int drm_legacy_sg_free(struct drm_device *dev, void *data,
>   	struct drm_scatter_gather *request = data;
>   	struct drm_sg_mem *entry;
>   
> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>   		return -EINVAL;
>   
>   	if (!drm_core_check_feature(dev, DRIVER_SG))

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

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

* Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions
  2016-08-04  7:37   ` Frank Binns
@ 2016-08-04  8:20     ` Daniel Vetter
  2016-08-04  8:36       ` Frank Binns
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Vetter @ 2016-08-04  8:20 UTC (permalink / raw)
  To: Frank Binns; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

On Thu, Aug 04, 2016 at 08:37:49AM +0100, Frank Binns wrote:
> On 03/08/16 20:11, Daniel Vetter wrote:
> > Except for nouveau, only legacy drivers need this really. And nouveau
> > is already marked up with DRIVER_KMS_LEGACY_CONTEXT as the special
> > case.
> > 
> > I've tried to be careful to leave everything related to modeset still
> > using the DRIVER_MODESET flag. Otherwise it's a direct replacement of
> > !DRIVER_MODESET with DRIVER_LEGACY checks. Also helps readability
> > since fewer negative checks overall.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> I don't think this goes far enough. For example, the documentation
> for the 'firstopen' callback says that it's called for legacy UMS drivers
> but it does a check based on DRIVER_MODESET. There are also some
> places in drm_pci.c that should be changed as well.

I switched the check for firstopen from DRIVER_MODESET to DRIVER_LEGACY.
And which hook in drm_pci.c should be converted in your opinion?
-Daniel

> 
> Anyway, this is progress so:
> Reviewed-by: Frank Binns <frank.binns@imgtec.com>
> 
> > ---
> >   drivers/gpu/drm/drm_agpsupport.c |  6 ++----
> >   drivers/gpu/drm/drm_auth.c       |  2 +-
> >   drivers/gpu/drm/drm_bufs.c       | 22 +++++++++++-----------
> >   drivers/gpu/drm/drm_context.c    | 24 ++++++++++++------------
> >   drivers/gpu/drm/drm_dma.c        |  6 ++----
> >   drivers/gpu/drm/drm_fops.c       |  6 +++---
> >   drivers/gpu/drm/drm_ioctl.c      |  4 ++--
> >   drivers/gpu/drm/drm_irq.c        | 10 +++++-----
> >   drivers/gpu/drm/drm_lock.c       |  4 ++--
> >   drivers/gpu/drm/drm_pci.c        |  8 ++++----
> >   drivers/gpu/drm/drm_scatter.c    |  6 +++---
> >   11 files changed, 47 insertions(+), 51 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
> > index 605bd243fb36..d621c8a4cf00 100644
> > --- a/drivers/gpu/drm/drm_agpsupport.c
> > +++ b/drivers/gpu/drm/drm_agpsupport.c
> > @@ -430,9 +430,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
> >    * intact so it can still be used. It is safe to call this if AGP is disabled or
> >    * was already removed.
> >    *
> > - * If DRIVER_MODESET is active, nothing is done to protect the modesetting
> > - * resources from getting destroyed. Drivers are responsible of cleaning them up
> > - * during device shutdown.
> > + * Cleanup is only done for drivers who have DRIVER_LEGACY set.
> >    */
> >   void drm_legacy_agp_clear(struct drm_device *dev)
> >   {
> > @@ -440,7 +438,7 @@ void drm_legacy_agp_clear(struct drm_device *dev)
> >   	if (!dev->agp)
> >   		return;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return;
> >   	list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
> > diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
> > index 4153e8a193af..6b143514a566 100644
> > --- a/drivers/gpu/drm/drm_auth.c
> > +++ b/drivers/gpu/drm/drm_auth.c
> > @@ -251,7 +251,7 @@ void drm_master_release(struct drm_file *file_priv)
> >   	if (!drm_is_current_master(file_priv))
> >   		goto out;
> > -	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
> > +	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
> >   		/*
> >   		 * Since the master is disappearing, so is the
> >   		 * possibility to lock.
> > diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> > index c3a12cd8bd0d..32191513e82d 100644
> > --- a/drivers/gpu/drm/drm_bufs.c
> > +++ b/drivers/gpu/drm/drm_bufs.c
> > @@ -397,7 +397,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
> >   		return -EPERM;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	err = drm_addmap_core(dev, map->offset, map->size, map->type,
> > @@ -443,7 +443,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
> >   	int i;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	idx = map->offset;
> > @@ -545,7 +545,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
> >   void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
> >   {
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return;
> >   	mutex_lock(&dev->struct_mutex);
> > @@ -558,7 +558,7 @@ void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
> >   {
> >   	struct drm_map_list *r_list, *list_temp;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return;
> >   	mutex_lock(&dev->struct_mutex);
> > @@ -595,7 +595,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
> >   	int ret;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	mutex_lock(&dev->struct_mutex);
> > @@ -1220,7 +1220,7 @@ int drm_legacy_addbufs(struct drm_device *dev, void *data,
> >   	struct drm_buf_desc *request = data;
> >   	int ret;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > @@ -1266,7 +1266,7 @@ int drm_legacy_infobufs(struct drm_device *dev, void *data,
> >   	int i;
> >   	int count;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > @@ -1347,7 +1347,7 @@ int drm_legacy_markbufs(struct drm_device *dev, void *data,
> >   	int order;
> >   	struct drm_buf_entry *entry;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > @@ -1395,7 +1395,7 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
> >   	int idx;
> >   	struct drm_buf *buf;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > @@ -1450,7 +1450,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
> >   	struct drm_buf_map *request = data;
> >   	int i;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > @@ -1530,7 +1530,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
> >   int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
> >   		  struct drm_file *file_priv)
> >   {
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (dev->driver->dma_ioctl)
> > diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> > index 192a5f9eeb74..3c4000facb36 100644
> > --- a/drivers/gpu/drm/drm_context.c
> > +++ b/drivers/gpu/drm/drm_context.c
> > @@ -54,7 +54,7 @@ struct drm_ctx_list {
> >   void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
> >   {
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return;
> >   	mutex_lock(&dev->struct_mutex);
> > @@ -92,7 +92,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
> >   void drm_legacy_ctxbitmap_init(struct drm_device * dev)
> >   {
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return;
> >   	idr_init(&dev->ctx_idr);
> > @@ -109,7 +109,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
> >   void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
> >   {
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return;
> >   	mutex_lock(&dev->struct_mutex);
> > @@ -131,7 +131,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
> >   	struct drm_ctx_list *pos, *tmp;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return;
> >   	mutex_lock(&dev->ctxlist_mutex);
> > @@ -177,7 +177,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
> >   	struct drm_map_list *_entry;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	mutex_lock(&dev->struct_mutex);
> > @@ -225,7 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
> >   	struct drm_map_list *r_list = NULL;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	mutex_lock(&dev->struct_mutex);
> > @@ -329,7 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
> >   	int i;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (res->count >= DRM_RESERVED_CONTEXTS) {
> > @@ -363,7 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
> >   	struct drm_ctx *ctx = data;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	ctx->handle = drm_legacy_ctxbitmap_next(dev);
> > @@ -410,7 +410,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
> >   	struct drm_ctx *ctx = data;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	/* This is 0, because we don't handle any context flags */
> > @@ -436,7 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
> >   	struct drm_ctx *ctx = data;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	DRM_DEBUG("%d\n", ctx->handle);
> > @@ -460,7 +460,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
> >   	struct drm_ctx *ctx = data;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	DRM_DEBUG("%d\n", ctx->handle);
> > @@ -486,7 +486,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
> >   	struct drm_ctx *ctx = data;
> >   	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	DRM_DEBUG("%d\n", ctx->handle);
> > diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
> > index ea481800ef56..3f83e2ca80ad 100644
> > --- a/drivers/gpu/drm/drm_dma.c
> > +++ b/drivers/gpu/drm/drm_dma.c
> > @@ -50,9 +50,8 @@ int drm_legacy_dma_setup(struct drm_device *dev)
> >   	int i;
> >   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
> > -	    drm_core_check_feature(dev, DRIVER_MODESET)) {
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return 0;
> > -	}
> >   	dev->buf_use = 0;
> >   	atomic_set(&dev->buf_alloc, 0);
> > @@ -81,9 +80,8 @@ void drm_legacy_dma_takedown(struct drm_device *dev)
> >   	int i, j;
> >   	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
> > -	    drm_core_check_feature(dev, DRIVER_MODESET)) {
> > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return;
> > -	}
> >   	if (!dma)
> >   		return;
> > diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> > index 323c238fcac7..036cd275c53e 100644
> > --- a/drivers/gpu/drm/drm_fops.c
> > +++ b/drivers/gpu/drm/drm_fops.c
> > @@ -92,7 +92,7 @@ static int drm_setup(struct drm_device * dev)
> >   	int ret;
> >   	if (dev->driver->firstopen &&
> > -	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
> > +	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
> >   		ret = dev->driver->firstopen(dev);
> >   		if (ret != 0)
> >   			return ret;
> > @@ -346,7 +346,7 @@ void drm_lastclose(struct drm_device * dev)
> >   		dev->driver->lastclose(dev);
> >   	DRM_DEBUG("driver lastclose completed\n");
> > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		drm_legacy_dev_reinit(dev);
> >   }
> > @@ -389,7 +389,7 @@ int drm_release(struct inode *inode, struct file *filp)
> >   		  (long)old_encode_dev(file_priv->minor->kdev->devt),
> >   		  dev->open_count);
> > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		drm_legacy_lock_release(dev, filp);
> >   	if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> > index 5085fd90f74d..0663a92922a8 100644
> > --- a/drivers/gpu/drm/drm_ioctl.c
> > +++ b/drivers/gpu/drm/drm_ioctl.c
> > @@ -714,9 +714,9 @@ long drm_ioctl(struct file *filp,
> >   	if (ksize > in_size)
> >   		memset(kdata + in_size, 0, ksize - in_size);
> > -	/* Enforce sane locking for kms driver ioctls. Core ioctls are
> > +	/* Enforce sane locking for modern driver ioctls. Core ioctls are
> >   	 * too messy still. */
> > -	if ((drm_core_check_feature(dev, DRIVER_MODESET) && is_driver_ioctl) ||
> > +	if ((!drm_core_check_feature(dev, DRIVER_LEGACY) && is_driver_ioctl) ||
> >   	    (ioctl->flags & DRM_UNLOCKED))
> >   		retcode = func(dev, kdata, file_priv);
> >   	else {
> > diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> > index a33465d8e133..d6d022b7c29b 100644
> > --- a/drivers/gpu/drm/drm_irq.c
> > +++ b/drivers/gpu/drm/drm_irq.c
> > @@ -482,7 +482,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
> >   		return ret;
> >   	}
> > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		vga_client_register(dev->pdev, (void *)dev, drm_irq_vgaarb_nokms, NULL);
> >   	/* After installing handler */
> > @@ -491,7 +491,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
> >   	if (ret < 0) {
> >   		dev->irq_enabled = false;
> > -		if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > +		if (drm_core_check_feature(dev, DRIVER_LEGACY))
> >   			vga_client_register(dev->pdev, NULL, NULL, NULL);
> >   		free_irq(irq, dev);
> >   	} else {
> > @@ -557,7 +557,7 @@ int drm_irq_uninstall(struct drm_device *dev)
> >   	DRM_DEBUG("irq=%d\n", dev->irq);
> > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		vga_client_register(dev->pdev, NULL, NULL, NULL);
> >   	if (dev->driver->irq_uninstall)
> > @@ -592,7 +592,7 @@ int drm_control(struct drm_device *dev, void *data,
> >   	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
> >   		return 0;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return 0;
> >   	/* UMS was only ever supported on pci devices. */
> >   	if (WARN_ON(!dev->pdev))
> > @@ -1488,7 +1488,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data,
> >   		return 0;
> >   	/* KMS drivers handle this internally */
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return 0;
> >   	pipe = modeset->crtc;
> > diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
> > index 48ac0ebbd663..c901f3c5b269 100644
> > --- a/drivers/gpu/drm/drm_lock.c
> > +++ b/drivers/gpu/drm/drm_lock.c
> > @@ -163,7 +163,7 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
> >   	struct drm_master *master = file_priv->master;
> >   	int ret = 0;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	++file_priv->lock_count;
> > @@ -252,7 +252,7 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
> >   	struct drm_lock *lock = data;
> >   	struct drm_master *master = file_priv->master;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (lock->context == DRM_KERNEL_CONTEXT) {
> > diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> > index b2f8f1062d5f..d86362fc8ac6 100644
> > --- a/drivers/gpu/drm/drm_pci.c
> > +++ b/drivers/gpu/drm/drm_pci.c
> > @@ -175,7 +175,7 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
> >   {
> >   	struct drm_irq_busid *p = data;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	/* UMS was only ever support on PCI devices. */
> > @@ -263,7 +263,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
> >   	/* No locking needed since shadow-attach is single-threaded since it may
> >   	 * only be called from the per-driver module init hook. */
> > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
> >   	return 0;
> > @@ -299,7 +299,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
> >   	DRM_DEBUG("\n");
> > -	if (driver->driver_features & DRIVER_MODESET)
> > +	if (!(driver->driver_features & DRIVER_LEGACY))
> >   		return pci_register_driver(pdriver);
> >   	/* If not using KMS, fall back to stealth mode manual scanning. */
> > @@ -421,7 +421,7 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
> >   	struct drm_device *dev, *tmp;
> >   	DRM_DEBUG("\n");
> > -	if (driver->driver_features & DRIVER_MODESET) {
> > +	if (!(driver->driver_features & DRIVER_LEGACY)) {
> >   		pci_unregister_driver(pdriver);
> >   	} else {
> >   		list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
> > diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
> > index bf70431073f6..275bca44f38c 100644
> > --- a/drivers/gpu/drm/drm_scatter.c
> > +++ b/drivers/gpu/drm/drm_scatter.c
> > @@ -68,7 +68,7 @@ static void drm_sg_cleanup(struct drm_sg_mem * entry)
> >   void drm_legacy_sg_cleanup(struct drm_device *dev)
> >   {
> >   	if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
> > -	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
> > +	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
> >   		drm_sg_cleanup(dev->sg);
> >   		dev->sg = NULL;
> >   	}
> > @@ -88,7 +88,7 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
> >   	DRM_DEBUG("\n");
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (!drm_core_check_feature(dev, DRIVER_SG))
> > @@ -201,7 +201,7 @@ int drm_legacy_sg_free(struct drm_device *dev, void *data,
> >   	struct drm_scatter_gather *request = data;
> >   	struct drm_sg_mem *entry;
> > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> >   		return -EINVAL;
> >   	if (!drm_core_check_feature(dev, DRIVER_SG))
> 

-- 
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] 10+ messages in thread

* Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions
  2016-08-04  8:20     ` Daniel Vetter
@ 2016-08-04  8:36       ` Frank Binns
  2016-08-04  9:01         ` Daniel Vetter
  0 siblings, 1 reply; 10+ messages in thread
From: Frank Binns @ 2016-08-04  8:36 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

On 04/08/16 09:20, Daniel Vetter wrote:
> On Thu, Aug 04, 2016 at 08:37:49AM +0100, Frank Binns wrote:
>> On 03/08/16 20:11, Daniel Vetter wrote:
>>> Except for nouveau, only legacy drivers need this really. And nouveau
>>> is already marked up with DRIVER_KMS_LEGACY_CONTEXT as the special
>>> case.
>>>
>>> I've tried to be careful to leave everything related to modeset still
>>> using the DRIVER_MODESET flag. Otherwise it's a direct replacement of
>>> !DRIVER_MODESET with DRIVER_LEGACY checks. Also helps readability
>>> since fewer negative checks overall.
>>>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>> I don't think this goes far enough. For example, the documentation
>> for the 'firstopen' callback says that it's called for legacy UMS drivers
>> but it does a check based on DRIVER_MODESET. There are also some
>> places in drm_pci.c that should be changed as well.
> I switched the check for firstopen from DRIVER_MODESET to DRIVER_LEGACY.
> And which hook in drm_pci.c should be converted in your opinion?
> -Daniel

Whoops, I read the patch without having had my morning coffee
(at least that's my excuse).

Sorry for the noise.

>> Anyway, this is progress so:
>> Reviewed-by: Frank Binns <frank.binns@imgtec.com>
>>
>>> ---
>>>    drivers/gpu/drm/drm_agpsupport.c |  6 ++----
>>>    drivers/gpu/drm/drm_auth.c       |  2 +-
>>>    drivers/gpu/drm/drm_bufs.c       | 22 +++++++++++-----------
>>>    drivers/gpu/drm/drm_context.c    | 24 ++++++++++++------------
>>>    drivers/gpu/drm/drm_dma.c        |  6 ++----
>>>    drivers/gpu/drm/drm_fops.c       |  6 +++---
>>>    drivers/gpu/drm/drm_ioctl.c      |  4 ++--
>>>    drivers/gpu/drm/drm_irq.c        | 10 +++++-----
>>>    drivers/gpu/drm/drm_lock.c       |  4 ++--
>>>    drivers/gpu/drm/drm_pci.c        |  8 ++++----
>>>    drivers/gpu/drm/drm_scatter.c    |  6 +++---
>>>    11 files changed, 47 insertions(+), 51 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
>>> index 605bd243fb36..d621c8a4cf00 100644
>>> --- a/drivers/gpu/drm/drm_agpsupport.c
>>> +++ b/drivers/gpu/drm/drm_agpsupport.c
>>> @@ -430,9 +430,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
>>>     * intact so it can still be used. It is safe to call this if AGP is disabled or
>>>     * was already removed.
>>>     *
>>> - * If DRIVER_MODESET is active, nothing is done to protect the modesetting
>>> - * resources from getting destroyed. Drivers are responsible of cleaning them up
>>> - * during device shutdown.
>>> + * Cleanup is only done for drivers who have DRIVER_LEGACY set.
>>>     */
>>>    void drm_legacy_agp_clear(struct drm_device *dev)
>>>    {
>>> @@ -440,7 +438,7 @@ void drm_legacy_agp_clear(struct drm_device *dev)
>>>    	if (!dev->agp)
>>>    		return;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return;
>>>    	list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
>>> diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
>>> index 4153e8a193af..6b143514a566 100644
>>> --- a/drivers/gpu/drm/drm_auth.c
>>> +++ b/drivers/gpu/drm/drm_auth.c
>>> @@ -251,7 +251,7 @@ void drm_master_release(struct drm_file *file_priv)
>>>    	if (!drm_is_current_master(file_priv))
>>>    		goto out;
>>> -	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
>>> +	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
>>>    		/*
>>>    		 * Since the master is disappearing, so is the
>>>    		 * possibility to lock.
>>> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
>>> index c3a12cd8bd0d..32191513e82d 100644
>>> --- a/drivers/gpu/drm/drm_bufs.c
>>> +++ b/drivers/gpu/drm/drm_bufs.c
>>> @@ -397,7 +397,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
>>>    		return -EPERM;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	err = drm_addmap_core(dev, map->offset, map->size, map->type,
>>> @@ -443,7 +443,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
>>>    	int i;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	idx = map->offset;
>>> @@ -545,7 +545,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>>>    void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>>>    {
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return;
>>>    	mutex_lock(&dev->struct_mutex);
>>> @@ -558,7 +558,7 @@ void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
>>>    {
>>>    	struct drm_map_list *r_list, *list_temp;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return;
>>>    	mutex_lock(&dev->struct_mutex);
>>> @@ -595,7 +595,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
>>>    	int ret;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	mutex_lock(&dev->struct_mutex);
>>> @@ -1220,7 +1220,7 @@ int drm_legacy_addbufs(struct drm_device *dev, void *data,
>>>    	struct drm_buf_desc *request = data;
>>>    	int ret;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
>>> @@ -1266,7 +1266,7 @@ int drm_legacy_infobufs(struct drm_device *dev, void *data,
>>>    	int i;
>>>    	int count;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
>>> @@ -1347,7 +1347,7 @@ int drm_legacy_markbufs(struct drm_device *dev, void *data,
>>>    	int order;
>>>    	struct drm_buf_entry *entry;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
>>> @@ -1395,7 +1395,7 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
>>>    	int idx;
>>>    	struct drm_buf *buf;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
>>> @@ -1450,7 +1450,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
>>>    	struct drm_buf_map *request = data;
>>>    	int i;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
>>> @@ -1530,7 +1530,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
>>>    int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
>>>    		  struct drm_file *file_priv)
>>>    {
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (dev->driver->dma_ioctl)
>>> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
>>> index 192a5f9eeb74..3c4000facb36 100644
>>> --- a/drivers/gpu/drm/drm_context.c
>>> +++ b/drivers/gpu/drm/drm_context.c
>>> @@ -54,7 +54,7 @@ struct drm_ctx_list {
>>>    void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
>>>    {
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return;
>>>    	mutex_lock(&dev->struct_mutex);
>>> @@ -92,7 +92,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
>>>    void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>>>    {
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return;
>>>    	idr_init(&dev->ctx_idr);
>>> @@ -109,7 +109,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
>>>    void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
>>>    {
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return;
>>>    	mutex_lock(&dev->struct_mutex);
>>> @@ -131,7 +131,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
>>>    	struct drm_ctx_list *pos, *tmp;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return;
>>>    	mutex_lock(&dev->ctxlist_mutex);
>>> @@ -177,7 +177,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
>>>    	struct drm_map_list *_entry;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	mutex_lock(&dev->struct_mutex);
>>> @@ -225,7 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
>>>    	struct drm_map_list *r_list = NULL;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	mutex_lock(&dev->struct_mutex);
>>> @@ -329,7 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
>>>    	int i;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (res->count >= DRM_RESERVED_CONTEXTS) {
>>> @@ -363,7 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>>>    	struct drm_ctx *ctx = data;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	ctx->handle = drm_legacy_ctxbitmap_next(dev);
>>> @@ -410,7 +410,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
>>>    	struct drm_ctx *ctx = data;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	/* This is 0, because we don't handle any context flags */
>>> @@ -436,7 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
>>>    	struct drm_ctx *ctx = data;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	DRM_DEBUG("%d\n", ctx->handle);
>>> @@ -460,7 +460,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
>>>    	struct drm_ctx *ctx = data;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	DRM_DEBUG("%d\n", ctx->handle);
>>> @@ -486,7 +486,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
>>>    	struct drm_ctx *ctx = data;
>>>    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	DRM_DEBUG("%d\n", ctx->handle);
>>> diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
>>> index ea481800ef56..3f83e2ca80ad 100644
>>> --- a/drivers/gpu/drm/drm_dma.c
>>> +++ b/drivers/gpu/drm/drm_dma.c
>>> @@ -50,9 +50,8 @@ int drm_legacy_dma_setup(struct drm_device *dev)
>>>    	int i;
>>>    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET)) {
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return 0;
>>> -	}
>>>    	dev->buf_use = 0;
>>>    	atomic_set(&dev->buf_alloc, 0);
>>> @@ -81,9 +80,8 @@ void drm_legacy_dma_takedown(struct drm_device *dev)
>>>    	int i, j;
>>>    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
>>> -	    drm_core_check_feature(dev, DRIVER_MODESET)) {
>>> +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return;
>>> -	}
>>>    	if (!dma)
>>>    		return;
>>> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
>>> index 323c238fcac7..036cd275c53e 100644
>>> --- a/drivers/gpu/drm/drm_fops.c
>>> +++ b/drivers/gpu/drm/drm_fops.c
>>> @@ -92,7 +92,7 @@ static int drm_setup(struct drm_device * dev)
>>>    	int ret;
>>>    	if (dev->driver->firstopen &&
>>> -	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
>>> +	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
>>>    		ret = dev->driver->firstopen(dev);
>>>    		if (ret != 0)
>>>    			return ret;
>>> @@ -346,7 +346,7 @@ void drm_lastclose(struct drm_device * dev)
>>>    		dev->driver->lastclose(dev);
>>>    	DRM_DEBUG("driver lastclose completed\n");
>>> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		drm_legacy_dev_reinit(dev);
>>>    }
>>> @@ -389,7 +389,7 @@ int drm_release(struct inode *inode, struct file *filp)
>>>    		  (long)old_encode_dev(file_priv->minor->kdev->devt),
>>>    		  dev->open_count);
>>> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		drm_legacy_lock_release(dev, filp);
>>>    	if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
>>> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
>>> index 5085fd90f74d..0663a92922a8 100644
>>> --- a/drivers/gpu/drm/drm_ioctl.c
>>> +++ b/drivers/gpu/drm/drm_ioctl.c
>>> @@ -714,9 +714,9 @@ long drm_ioctl(struct file *filp,
>>>    	if (ksize > in_size)
>>>    		memset(kdata + in_size, 0, ksize - in_size);
>>> -	/* Enforce sane locking for kms driver ioctls. Core ioctls are
>>> +	/* Enforce sane locking for modern driver ioctls. Core ioctls are
>>>    	 * too messy still. */
>>> -	if ((drm_core_check_feature(dev, DRIVER_MODESET) && is_driver_ioctl) ||
>>> +	if ((!drm_core_check_feature(dev, DRIVER_LEGACY) && is_driver_ioctl) ||
>>>    	    (ioctl->flags & DRM_UNLOCKED))
>>>    		retcode = func(dev, kdata, file_priv);
>>>    	else {
>>> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
>>> index a33465d8e133..d6d022b7c29b 100644
>>> --- a/drivers/gpu/drm/drm_irq.c
>>> +++ b/drivers/gpu/drm/drm_irq.c
>>> @@ -482,7 +482,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
>>>    		return ret;
>>>    	}
>>> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		vga_client_register(dev->pdev, (void *)dev, drm_irq_vgaarb_nokms, NULL);
>>>    	/* After installing handler */
>>> @@ -491,7 +491,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
>>>    	if (ret < 0) {
>>>    		dev->irq_enabled = false;
>>> -		if (!drm_core_check_feature(dev, DRIVER_MODESET))
>>> +		if (drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    			vga_client_register(dev->pdev, NULL, NULL, NULL);
>>>    		free_irq(irq, dev);
>>>    	} else {
>>> @@ -557,7 +557,7 @@ int drm_irq_uninstall(struct drm_device *dev)
>>>    	DRM_DEBUG("irq=%d\n", dev->irq);
>>> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		vga_client_register(dev->pdev, NULL, NULL, NULL);
>>>    	if (dev->driver->irq_uninstall)
>>> @@ -592,7 +592,7 @@ int drm_control(struct drm_device *dev, void *data,
>>>    	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
>>>    		return 0;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return 0;
>>>    	/* UMS was only ever supported on pci devices. */
>>>    	if (WARN_ON(!dev->pdev))
>>> @@ -1488,7 +1488,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data,
>>>    		return 0;
>>>    	/* KMS drivers handle this internally */
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return 0;
>>>    	pipe = modeset->crtc;
>>> diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
>>> index 48ac0ebbd663..c901f3c5b269 100644
>>> --- a/drivers/gpu/drm/drm_lock.c
>>> +++ b/drivers/gpu/drm/drm_lock.c
>>> @@ -163,7 +163,7 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
>>>    	struct drm_master *master = file_priv->master;
>>>    	int ret = 0;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	++file_priv->lock_count;
>>> @@ -252,7 +252,7 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
>>>    	struct drm_lock *lock = data;
>>>    	struct drm_master *master = file_priv->master;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (lock->context == DRM_KERNEL_CONTEXT) {
>>> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
>>> index b2f8f1062d5f..d86362fc8ac6 100644
>>> --- a/drivers/gpu/drm/drm_pci.c
>>> +++ b/drivers/gpu/drm/drm_pci.c
>>> @@ -175,7 +175,7 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
>>>    {
>>>    	struct drm_irq_busid *p = data;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	/* UMS was only ever support on PCI devices. */
>>> @@ -263,7 +263,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
>>>    	/* No locking needed since shadow-attach is single-threaded since it may
>>>    	 * only be called from the per-driver module init hook. */
>>> -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
>>>    	return 0;
>>> @@ -299,7 +299,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
>>>    	DRM_DEBUG("\n");
>>> -	if (driver->driver_features & DRIVER_MODESET)
>>> +	if (!(driver->driver_features & DRIVER_LEGACY))
>>>    		return pci_register_driver(pdriver);
>>>    	/* If not using KMS, fall back to stealth mode manual scanning. */
>>> @@ -421,7 +421,7 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
>>>    	struct drm_device *dev, *tmp;
>>>    	DRM_DEBUG("\n");
>>> -	if (driver->driver_features & DRIVER_MODESET) {
>>> +	if (!(driver->driver_features & DRIVER_LEGACY)) {
>>>    		pci_unregister_driver(pdriver);
>>>    	} else {
>>>    		list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
>>> diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
>>> index bf70431073f6..275bca44f38c 100644
>>> --- a/drivers/gpu/drm/drm_scatter.c
>>> +++ b/drivers/gpu/drm/drm_scatter.c
>>> @@ -68,7 +68,7 @@ static void drm_sg_cleanup(struct drm_sg_mem * entry)
>>>    void drm_legacy_sg_cleanup(struct drm_device *dev)
>>>    {
>>>    	if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
>>> -	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
>>> +	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
>>>    		drm_sg_cleanup(dev->sg);
>>>    		dev->sg = NULL;
>>>    	}
>>> @@ -88,7 +88,7 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
>>>    	DRM_DEBUG("\n");
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (!drm_core_check_feature(dev, DRIVER_SG))
>>> @@ -201,7 +201,7 @@ int drm_legacy_sg_free(struct drm_device *dev, void *data,
>>>    	struct drm_scatter_gather *request = data;
>>>    	struct drm_sg_mem *entry;
>>> -	if (drm_core_check_feature(dev, DRIVER_MODESET))
>>> +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
>>>    		return -EINVAL;
>>>    	if (!drm_core_check_feature(dev, DRIVER_SG))

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

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

* Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions
  2016-08-04  8:36       ` Frank Binns
@ 2016-08-04  9:01         ` Daniel Vetter
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2016-08-04  9:01 UTC (permalink / raw)
  To: Frank Binns; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

On Thu, Aug 04, 2016 at 09:36:36AM +0100, Frank Binns wrote:
> On 04/08/16 09:20, Daniel Vetter wrote:
> > On Thu, Aug 04, 2016 at 08:37:49AM +0100, Frank Binns wrote:
> > > On 03/08/16 20:11, Daniel Vetter wrote:
> > > > Except for nouveau, only legacy drivers need this really. And nouveau
> > > > is already marked up with DRIVER_KMS_LEGACY_CONTEXT as the special
> > > > case.
> > > > 
> > > > I've tried to be careful to leave everything related to modeset still
> > > > using the DRIVER_MODESET flag. Otherwise it's a direct replacement of
> > > > !DRIVER_MODESET with DRIVER_LEGACY checks. Also helps readability
> > > > since fewer negative checks overall.
> > > > 
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > I don't think this goes far enough. For example, the documentation
> > > for the 'firstopen' callback says that it's called for legacy UMS drivers
> > > but it does a check based on DRIVER_MODESET. There are also some
> > > places in drm_pci.c that should be changed as well.
> > I switched the check for firstopen from DRIVER_MODESET to DRIVER_LEGACY.
> > And which hook in drm_pci.c should be converted in your opinion?
> > -Daniel
> 
> Whoops, I read the patch without having had my morning coffee
> (at least that's my excuse).
> 
> Sorry for the noise.

No worries, and thx for the review, both in my -misc queue now.
-Daniel

> 
> > > Anyway, this is progress so:
> > > Reviewed-by: Frank Binns <frank.binns@imgtec.com>
> > > 
> > > > ---
> > > >    drivers/gpu/drm/drm_agpsupport.c |  6 ++----
> > > >    drivers/gpu/drm/drm_auth.c       |  2 +-
> > > >    drivers/gpu/drm/drm_bufs.c       | 22 +++++++++++-----------
> > > >    drivers/gpu/drm/drm_context.c    | 24 ++++++++++++------------
> > > >    drivers/gpu/drm/drm_dma.c        |  6 ++----
> > > >    drivers/gpu/drm/drm_fops.c       |  6 +++---
> > > >    drivers/gpu/drm/drm_ioctl.c      |  4 ++--
> > > >    drivers/gpu/drm/drm_irq.c        | 10 +++++-----
> > > >    drivers/gpu/drm/drm_lock.c       |  4 ++--
> > > >    drivers/gpu/drm/drm_pci.c        |  8 ++++----
> > > >    drivers/gpu/drm/drm_scatter.c    |  6 +++---
> > > >    11 files changed, 47 insertions(+), 51 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
> > > > index 605bd243fb36..d621c8a4cf00 100644
> > > > --- a/drivers/gpu/drm/drm_agpsupport.c
> > > > +++ b/drivers/gpu/drm/drm_agpsupport.c
> > > > @@ -430,9 +430,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
> > > >     * intact so it can still be used. It is safe to call this if AGP is disabled or
> > > >     * was already removed.
> > > >     *
> > > > - * If DRIVER_MODESET is active, nothing is done to protect the modesetting
> > > > - * resources from getting destroyed. Drivers are responsible of cleaning them up
> > > > - * during device shutdown.
> > > > + * Cleanup is only done for drivers who have DRIVER_LEGACY set.
> > > >     */
> > > >    void drm_legacy_agp_clear(struct drm_device *dev)
> > > >    {
> > > > @@ -440,7 +438,7 @@ void drm_legacy_agp_clear(struct drm_device *dev)
> > > >    	if (!dev->agp)
> > > >    		return;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return;
> > > >    	list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
> > > > diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
> > > > index 4153e8a193af..6b143514a566 100644
> > > > --- a/drivers/gpu/drm/drm_auth.c
> > > > +++ b/drivers/gpu/drm/drm_auth.c
> > > > @@ -251,7 +251,7 @@ void drm_master_release(struct drm_file *file_priv)
> > > >    	if (!drm_is_current_master(file_priv))
> > > >    		goto out;
> > > > -	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > > +	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
> > > >    		/*
> > > >    		 * Since the master is disappearing, so is the
> > > >    		 * possibility to lock.
> > > > diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> > > > index c3a12cd8bd0d..32191513e82d 100644
> > > > --- a/drivers/gpu/drm/drm_bufs.c
> > > > +++ b/drivers/gpu/drm/drm_bufs.c
> > > > @@ -397,7 +397,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
> > > >    		return -EPERM;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	err = drm_addmap_core(dev, map->offset, map->size, map->type,
> > > > @@ -443,7 +443,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
> > > >    	int i;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	idx = map->offset;
> > > > @@ -545,7 +545,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
> > > >    void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
> > > >    {
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return;
> > > >    	mutex_lock(&dev->struct_mutex);
> > > > @@ -558,7 +558,7 @@ void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
> > > >    {
> > > >    	struct drm_map_list *r_list, *list_temp;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return;
> > > >    	mutex_lock(&dev->struct_mutex);
> > > > @@ -595,7 +595,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
> > > >    	int ret;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	mutex_lock(&dev->struct_mutex);
> > > > @@ -1220,7 +1220,7 @@ int drm_legacy_addbufs(struct drm_device *dev, void *data,
> > > >    	struct drm_buf_desc *request = data;
> > > >    	int ret;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > > > @@ -1266,7 +1266,7 @@ int drm_legacy_infobufs(struct drm_device *dev, void *data,
> > > >    	int i;
> > > >    	int count;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > > > @@ -1347,7 +1347,7 @@ int drm_legacy_markbufs(struct drm_device *dev, void *data,
> > > >    	int order;
> > > >    	struct drm_buf_entry *entry;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > > > @@ -1395,7 +1395,7 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
> > > >    	int idx;
> > > >    	struct drm_buf *buf;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > > > @@ -1450,7 +1450,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
> > > >    	struct drm_buf_map *request = data;
> > > >    	int i;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > > > @@ -1530,7 +1530,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
> > > >    int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
> > > >    		  struct drm_file *file_priv)
> > > >    {
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (dev->driver->dma_ioctl)
> > > > diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> > > > index 192a5f9eeb74..3c4000facb36 100644
> > > > --- a/drivers/gpu/drm/drm_context.c
> > > > +++ b/drivers/gpu/drm/drm_context.c
> > > > @@ -54,7 +54,7 @@ struct drm_ctx_list {
> > > >    void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
> > > >    {
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return;
> > > >    	mutex_lock(&dev->struct_mutex);
> > > > @@ -92,7 +92,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
> > > >    void drm_legacy_ctxbitmap_init(struct drm_device * dev)
> > > >    {
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return;
> > > >    	idr_init(&dev->ctx_idr);
> > > > @@ -109,7 +109,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
> > > >    void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
> > > >    {
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return;
> > > >    	mutex_lock(&dev->struct_mutex);
> > > > @@ -131,7 +131,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
> > > >    	struct drm_ctx_list *pos, *tmp;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return;
> > > >    	mutex_lock(&dev->ctxlist_mutex);
> > > > @@ -177,7 +177,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
> > > >    	struct drm_map_list *_entry;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	mutex_lock(&dev->struct_mutex);
> > > > @@ -225,7 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
> > > >    	struct drm_map_list *r_list = NULL;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	mutex_lock(&dev->struct_mutex);
> > > > @@ -329,7 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
> > > >    	int i;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (res->count >= DRM_RESERVED_CONTEXTS) {
> > > > @@ -363,7 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
> > > >    	struct drm_ctx *ctx = data;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	ctx->handle = drm_legacy_ctxbitmap_next(dev);
> > > > @@ -410,7 +410,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
> > > >    	struct drm_ctx *ctx = data;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	/* This is 0, because we don't handle any context flags */
> > > > @@ -436,7 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
> > > >    	struct drm_ctx *ctx = data;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	DRM_DEBUG("%d\n", ctx->handle);
> > > > @@ -460,7 +460,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
> > > >    	struct drm_ctx *ctx = data;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	DRM_DEBUG("%d\n", ctx->handle);
> > > > @@ -486,7 +486,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
> > > >    	struct drm_ctx *ctx = data;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	DRM_DEBUG("%d\n", ctx->handle);
> > > > diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
> > > > index ea481800ef56..3f83e2ca80ad 100644
> > > > --- a/drivers/gpu/drm/drm_dma.c
> > > > +++ b/drivers/gpu/drm/drm_dma.c
> > > > @@ -50,9 +50,8 @@ int drm_legacy_dma_setup(struct drm_device *dev)
> > > >    	int i;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return 0;
> > > > -	}
> > > >    	dev->buf_use = 0;
> > > >    	atomic_set(&dev->buf_alloc, 0);
> > > > @@ -81,9 +80,8 @@ void drm_legacy_dma_takedown(struct drm_device *dev)
> > > >    	int i, j;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
> > > > -	    drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > > +	    !drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return;
> > > > -	}
> > > >    	if (!dma)
> > > >    		return;
> > > > diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> > > > index 323c238fcac7..036cd275c53e 100644
> > > > --- a/drivers/gpu/drm/drm_fops.c
> > > > +++ b/drivers/gpu/drm/drm_fops.c
> > > > @@ -92,7 +92,7 @@ static int drm_setup(struct drm_device * dev)
> > > >    	int ret;
> > > >    	if (dev->driver->firstopen &&
> > > > -	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > > +	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
> > > >    		ret = dev->driver->firstopen(dev);
> > > >    		if (ret != 0)
> > > >    			return ret;
> > > > @@ -346,7 +346,7 @@ void drm_lastclose(struct drm_device * dev)
> > > >    		dev->driver->lastclose(dev);
> > > >    	DRM_DEBUG("driver lastclose completed\n");
> > > > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		drm_legacy_dev_reinit(dev);
> > > >    }
> > > > @@ -389,7 +389,7 @@ int drm_release(struct inode *inode, struct file *filp)
> > > >    		  (long)old_encode_dev(file_priv->minor->kdev->devt),
> > > >    		  dev->open_count);
> > > > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		drm_legacy_lock_release(dev, filp);
> > > >    	if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> > > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> > > > index 5085fd90f74d..0663a92922a8 100644
> > > > --- a/drivers/gpu/drm/drm_ioctl.c
> > > > +++ b/drivers/gpu/drm/drm_ioctl.c
> > > > @@ -714,9 +714,9 @@ long drm_ioctl(struct file *filp,
> > > >    	if (ksize > in_size)
> > > >    		memset(kdata + in_size, 0, ksize - in_size);
> > > > -	/* Enforce sane locking for kms driver ioctls. Core ioctls are
> > > > +	/* Enforce sane locking for modern driver ioctls. Core ioctls are
> > > >    	 * too messy still. */
> > > > -	if ((drm_core_check_feature(dev, DRIVER_MODESET) && is_driver_ioctl) ||
> > > > +	if ((!drm_core_check_feature(dev, DRIVER_LEGACY) && is_driver_ioctl) ||
> > > >    	    (ioctl->flags & DRM_UNLOCKED))
> > > >    		retcode = func(dev, kdata, file_priv);
> > > >    	else {
> > > > diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> > > > index a33465d8e133..d6d022b7c29b 100644
> > > > --- a/drivers/gpu/drm/drm_irq.c
> > > > +++ b/drivers/gpu/drm/drm_irq.c
> > > > @@ -482,7 +482,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
> > > >    		return ret;
> > > >    	}
> > > > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		vga_client_register(dev->pdev, (void *)dev, drm_irq_vgaarb_nokms, NULL);
> > > >    	/* After installing handler */
> > > > @@ -491,7 +491,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
> > > >    	if (ret < 0) {
> > > >    		dev->irq_enabled = false;
> > > > -		if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +		if (drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    			vga_client_register(dev->pdev, NULL, NULL, NULL);
> > > >    		free_irq(irq, dev);
> > > >    	} else {
> > > > @@ -557,7 +557,7 @@ int drm_irq_uninstall(struct drm_device *dev)
> > > >    	DRM_DEBUG("irq=%d\n", dev->irq);
> > > > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		vga_client_register(dev->pdev, NULL, NULL, NULL);
> > > >    	if (dev->driver->irq_uninstall)
> > > > @@ -592,7 +592,7 @@ int drm_control(struct drm_device *dev, void *data,
> > > >    	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
> > > >    		return 0;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return 0;
> > > >    	/* UMS was only ever supported on pci devices. */
> > > >    	if (WARN_ON(!dev->pdev))
> > > > @@ -1488,7 +1488,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data,
> > > >    		return 0;
> > > >    	/* KMS drivers handle this internally */
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return 0;
> > > >    	pipe = modeset->crtc;
> > > > diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
> > > > index 48ac0ebbd663..c901f3c5b269 100644
> > > > --- a/drivers/gpu/drm/drm_lock.c
> > > > +++ b/drivers/gpu/drm/drm_lock.c
> > > > @@ -163,7 +163,7 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
> > > >    	struct drm_master *master = file_priv->master;
> > > >    	int ret = 0;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	++file_priv->lock_count;
> > > > @@ -252,7 +252,7 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
> > > >    	struct drm_lock *lock = data;
> > > >    	struct drm_master *master = file_priv->master;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (lock->context == DRM_KERNEL_CONTEXT) {
> > > > diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> > > > index b2f8f1062d5f..d86362fc8ac6 100644
> > > > --- a/drivers/gpu/drm/drm_pci.c
> > > > +++ b/drivers/gpu/drm/drm_pci.c
> > > > @@ -175,7 +175,7 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
> > > >    {
> > > >    	struct drm_irq_busid *p = data;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	/* UMS was only ever support on PCI devices. */
> > > > @@ -263,7 +263,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
> > > >    	/* No locking needed since shadow-attach is single-threaded since it may
> > > >    	 * only be called from the per-driver module init hook. */
> > > > -	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
> > > >    	return 0;
> > > > @@ -299,7 +299,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
> > > >    	DRM_DEBUG("\n");
> > > > -	if (driver->driver_features & DRIVER_MODESET)
> > > > +	if (!(driver->driver_features & DRIVER_LEGACY))
> > > >    		return pci_register_driver(pdriver);
> > > >    	/* If not using KMS, fall back to stealth mode manual scanning. */
> > > > @@ -421,7 +421,7 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
> > > >    	struct drm_device *dev, *tmp;
> > > >    	DRM_DEBUG("\n");
> > > > -	if (driver->driver_features & DRIVER_MODESET) {
> > > > +	if (!(driver->driver_features & DRIVER_LEGACY)) {
> > > >    		pci_unregister_driver(pdriver);
> > > >    	} else {
> > > >    		list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
> > > > diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
> > > > index bf70431073f6..275bca44f38c 100644
> > > > --- a/drivers/gpu/drm/drm_scatter.c
> > > > +++ b/drivers/gpu/drm/drm_scatter.c
> > > > @@ -68,7 +68,7 @@ static void drm_sg_cleanup(struct drm_sg_mem * entry)
> > > >    void drm_legacy_sg_cleanup(struct drm_device *dev)
> > > >    {
> > > >    	if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
> > > > -	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > > +	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
> > > >    		drm_sg_cleanup(dev->sg);
> > > >    		dev->sg = NULL;
> > > >    	}
> > > > @@ -88,7 +88,7 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
> > > >    	DRM_DEBUG("\n");
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_SG))
> > > > @@ -201,7 +201,7 @@ int drm_legacy_sg_free(struct drm_device *dev, void *data,
> > > >    	struct drm_scatter_gather *request = data;
> > > >    	struct drm_sg_mem *entry;
> > > > -	if (drm_core_check_feature(dev, DRIVER_MODESET))
> > > > +	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> > > >    		return -EINVAL;
> > > >    	if (!drm_core_check_feature(dev, DRIVER_SG))
> 

-- 
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] 10+ messages in thread

end of thread, other threads:[~2016-08-04  9:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-03 19:11 [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY Daniel Vetter
2016-08-03 19:11 ` [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions Daniel Vetter
2016-08-04  7:37   ` David Herrmann
2016-08-04  7:37   ` Frank Binns
2016-08-04  8:20     ` Daniel Vetter
2016-08-04  8:36       ` Frank Binns
2016-08-04  9:01         ` Daniel Vetter
2016-08-04  7:22 ` [PATCH 1/2] drm: Mark up legacy/dri1 drivers with DRM_LEGACY Frank Binns
2016-08-04  7:32 ` David Herrmann
2016-08-04  7:37   ` Chris Wilson

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.