Skip to contentSkip to conversation

drm: Mark up legacy/dri1 drivers with DRM_LEGACY

PATCH In review Daniel Vetter 5 participants 10 messages Aug 3, 2016 – Aug 4, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm: Mark up legacy/dri1 drivers with DRM_LEGACY

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.

---
 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(-)
Documentation/gpu/drm-internals.rst +6 -3
index 3bb26135971f..37284bcc7764 100644
@@ -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
drivers/gpu/drm/i810/i810_drv.c +1 -3
index 44f4a131c8dd..0be55dc1ef4b 100644
@@ -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,
drivers/gpu/drm/mga/mga_drv.c +1 -1
index 5e2f131a6a72..25b2a1a424e6 100644
@@ -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,
drivers/gpu/drm/r128/r128_drv.c +1 -1
index c57b4de63caf..a982be57d1ef 100644
@@ -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,
drivers/gpu/drm/savage/savage_drv.c +1 -1
index 21aed1febeb4..3b807135a5cd 100644
@@ -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,
drivers/gpu/drm/sis/sis_drv.c +1 -1
index 79bce76cb8f7..ae9839886c4d 100644
@@ -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,
drivers/gpu/drm/tdfx/tdfx_drv.c +1 -0
index fab5ebcb0fef..f418892b0c71 100644
@@ -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,
drivers/gpu/drm/via/via_drv.c +1 -1
index ed8aa8ff861a..e5582bab7e3c 100644
@@ -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,
include/drm/drmP.h +1 -0
index 5f9caf7ee949..9c828d6f7cdc 100644
@@ -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
Signature · 6 lines
2.8.1

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

PATCH 2/2 drm: Used DRM_LEGACY for all legacy functions

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.

---
 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(-)
drivers/gpu/drm/drm_agpsupport.c +2 -4
index 605bd243fb36..d621c8a4cf00 100644
@@ -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) {
drivers/gpu/drm/drm_auth.c +1 -1
index 4153e8a193af..6b143514a566 100644
@@ -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.
drivers/gpu/drm/drm_bufs.c +11 -11
index c3a12cd8bd0d..32191513e82d 100644
@@ -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)
drivers/gpu/drm/drm_context.c +12 -12
index 192a5f9eeb74..3c4000facb36 100644
@@ -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);
drivers/gpu/drm/drm_dma.c +2 -4
index ea481800ef56..3f83e2ca80ad 100644
@@ -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;
drivers/gpu/drm/drm_fops.c +3 -3
index 323c238fcac7..036cd275c53e 100644
@@ -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))
drivers/gpu/drm/drm_ioctl.c +2 -2
index 5085fd90f74d..0663a92922a8 100644
@@ -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 {
drivers/gpu/drm/drm_irq.c +5 -5
index a33465d8e133..d6d022b7c29b 100644
@@ -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;
drivers/gpu/drm/drm_lock.c +2 -2
index 48ac0ebbd663..c901f3c5b269 100644
@@ -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) {
drivers/gpu/drm/drm_pci.c +4 -4
index b2f8f1062d5f..d86362fc8ac6 100644
@@ -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,
drivers/gpu/drm/drm_scatter.c +3 -3
index bf70431073f6..275bca44f38c 100644
@@ -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))
Signature · 6 lines
2.8.1

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

Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions

Hi

Quoted 292 lines · 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.

---
 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(-)
drivers/gpu/drm/drm_agpsupport.c +2 -4
index 605bd243fb36..d621c8a4cf00 100644
@@ -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) {
drivers/gpu/drm/drm_auth.c +1 -1
index 4153e8a193af..6b143514a566 100644
@@ -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.
drivers/gpu/drm/drm_bufs.c +11 -11
index c3a12cd8bd0d..32191513e82d 100644
@@ -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)
drivers/gpu/drm/drm_context.c +12 -12
index 192a5f9eeb74..3c4000facb36 100644
@@ -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);
drivers/gpu/drm/drm_dma.c +1 -2
index ea481800ef56..3f83e2ca80ad 100644
@@ -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);

drivers/gpu/drm/drm_dma.c void drm_legacy_dma_takedown(struct drm_device *dev) · line 86

Quoted 7 lines
drivers/gpu/drm/drm_dma.c +1 -2
@@ -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:

Thanks
David

Quoted 193 lines
drivers/gpu/drm/drm_dma.c +0 -0
        if (!dma)
                return;
drivers/gpu/drm/drm_fops.c +3 -3
index 323c238fcac7..036cd275c53e 100644
@@ -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))
drivers/gpu/drm/drm_ioctl.c +2 -2
index 5085fd90f74d..0663a92922a8 100644
@@ -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 {
drivers/gpu/drm/drm_irq.c +5 -5
index a33465d8e133..d6d022b7c29b 100644
@@ -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;
drivers/gpu/drm/drm_lock.c +2 -2
index 48ac0ebbd663..c901f3c5b269 100644
@@ -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) {
drivers/gpu/drm/drm_pci.c +4 -4
index b2f8f1062d5f..d86362fc8ac6 100644
@@ -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,
drivers/gpu/drm/drm_scatter.c +3 -4
index bf70431073f6..275bca44f38c 100644
@@ -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))
--
Quoted 2 lines

2.8.1

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

Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions

In reply to Daniel Vetter
Quoted 10 lines · 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.

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:

Quoted 473 lines
---
  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(-)
drivers/gpu/drm/drm_agpsupport.c +2 -4
index 605bd243fb36..d621c8a4cf00 100644
@@ -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) {
drivers/gpu/drm/drm_auth.c +1 -1
index 4153e8a193af..6b143514a566 100644
@@ -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.
drivers/gpu/drm/drm_bufs.c +11 -11
index c3a12cd8bd0d..32191513e82d 100644
@@ -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)
drivers/gpu/drm/drm_context.c +12 -12
index 192a5f9eeb74..3c4000facb36 100644
@@ -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);
drivers/gpu/drm/drm_dma.c +2 -4
index ea481800ef56..3f83e2ca80ad 100644
@@ -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;
drivers/gpu/drm/drm_fops.c +3 -3
index 323c238fcac7..036cd275c53e 100644
@@ -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))
drivers/gpu/drm/drm_ioctl.c +2 -2
index 5085fd90f74d..0663a92922a8 100644
@@ -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 {
drivers/gpu/drm/drm_irq.c +5 -5
index a33465d8e133..d6d022b7c29b 100644
@@ -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;
drivers/gpu/drm/drm_lock.c +2 -2
index 48ac0ebbd663..c901f3c5b269 100644
@@ -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) {
drivers/gpu/drm/drm_pci.c +4 -4
index b2f8f1062d5f..d86362fc8ac6 100644
@@ -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,
drivers/gpu/drm/drm_scatter.c +2 -2
index bf70431073f6..275bca44f38c 100644
@@ -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))

drivers/gpu/drm/drm_scatter.c int drm_legacy_sg_free(struct drm_device *dev, void *data, · line 207

Quoted 8 lines
drivers/gpu/drm/drm_scatter.c +1 -1
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions

Quoted 10 lines · Frank Binns
Quoted 9 lines · 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.

Quoted 6 lines
Quoted 1 line

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

Quoted 406 lines

Anyway, this is progress so:

Quoted 401 lines
---
  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(-)
drivers/gpu/drm/drm_agpsupport.c +2 -4
index 605bd243fb36..d621c8a4cf00 100644
@@ -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) {
drivers/gpu/drm/drm_auth.c +1 -1
index 4153e8a193af..6b143514a566 100644
@@ -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.
drivers/gpu/drm/drm_bufs.c +11 -11
index c3a12cd8bd0d..32191513e82d 100644
@@ -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)
drivers/gpu/drm/drm_context.c +12 -12
index 192a5f9eeb74..3c4000facb36 100644
@@ -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);
drivers/gpu/drm/drm_dma.c +2 -4
index ea481800ef56..3f83e2ca80ad 100644
@@ -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;
drivers/gpu/drm/drm_fops.c +3 -3
index 323c238fcac7..036cd275c53e 100644
@@ -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))
drivers/gpu/drm/drm_ioctl.c +2 -2
index 5085fd90f74d..0663a92922a8 100644
@@ -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 {
drivers/gpu/drm/drm_irq.c +5 -5
index a33465d8e133..d6d022b7c29b 100644
@@ -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;
drivers/gpu/drm/drm_lock.c +2 -2
index 48ac0ebbd663..c901f3c5b269 100644
@@ -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) {
drivers/gpu/drm/drm_pci.c +4 -4
index b2f8f1062d5f..d86362fc8ac6 100644
@@ -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,
drivers/gpu/drm/drm_scatter.c +3 -3
index bf70431073f6..275bca44f38c 100644
@@ -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))
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions

Quoted 11 lines · Daniel Vetter
Quoted 10 lines · Frank Binns
Quoted 9 lines · 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.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 396 lines
Quoted 396 lines

Anyway, this is progress so:

Quoted 393 lines
---
   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(-)
drivers/gpu/drm/drm_agpsupport.c +2 -4
index 605bd243fb36..d621c8a4cf00 100644
@@ -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) {
drivers/gpu/drm/drm_auth.c +1 -1
index 4153e8a193af..6b143514a566 100644
@@ -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.
drivers/gpu/drm/drm_bufs.c +11 -11
index c3a12cd8bd0d..32191513e82d 100644
@@ -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)
drivers/gpu/drm/drm_context.c +12 -12
index 192a5f9eeb74..3c4000facb36 100644
@@ -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);
drivers/gpu/drm/drm_dma.c +2 -4
index ea481800ef56..3f83e2ca80ad 100644
@@ -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;
drivers/gpu/drm/drm_fops.c +3 -3
index 323c238fcac7..036cd275c53e 100644
@@ -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))
drivers/gpu/drm/drm_ioctl.c +2 -2
index 5085fd90f74d..0663a92922a8 100644
@@ -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 {
drivers/gpu/drm/drm_irq.c +5 -5
index a33465d8e133..d6d022b7c29b 100644
@@ -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;
drivers/gpu/drm/drm_lock.c +2 -2
index 48ac0ebbd663..c901f3c5b269 100644
@@ -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) {
drivers/gpu/drm/drm_pci.c +4 -4
index b2f8f1062d5f..d86362fc8ac6 100644
@@ -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,
drivers/gpu/drm/drm_scatter.c +2 -2
index bf70431073f6..275bca44f38c 100644
@@ -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;
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_scatter.c int drm_legacy_sg_free(struct drm_device *dev, void *data, · line 205

Quoted 8 lines
drivers/gpu/drm/drm_scatter.c +1 -1
   	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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH 2/2] drm: Used DRM_LEGACY for all legacy functions

Quoted 17 lines · Frank Binns
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Frank Binns
Quoted 10 lines · 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.

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.

Quoted 8 lines
Quoted 3 lines

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

Quoted 406 lines
Quoted 405 lines
Quoted 405 lines

Anyway, this is progress so:

Quoted 401 lines
---
   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(-)
drivers/gpu/drm/drm_agpsupport.c +2 -4
index 605bd243fb36..d621c8a4cf00 100644
@@ -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) {
drivers/gpu/drm/drm_auth.c +1 -1
index 4153e8a193af..6b143514a566 100644
@@ -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.
drivers/gpu/drm/drm_bufs.c +11 -11
index c3a12cd8bd0d..32191513e82d 100644
@@ -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)
drivers/gpu/drm/drm_context.c +12 -12
index 192a5f9eeb74..3c4000facb36 100644
@@ -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);
drivers/gpu/drm/drm_dma.c +2 -4
index ea481800ef56..3f83e2ca80ad 100644
@@ -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;
drivers/gpu/drm/drm_fops.c +3 -3
index 323c238fcac7..036cd275c53e 100644
@@ -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))
drivers/gpu/drm/drm_ioctl.c +2 -2
index 5085fd90f74d..0663a92922a8 100644
@@ -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 {
drivers/gpu/drm/drm_irq.c +5 -5
index a33465d8e133..d6d022b7c29b 100644
@@ -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;
drivers/gpu/drm/drm_lock.c +2 -2
index 48ac0ebbd663..c901f3c5b269 100644
@@ -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) {
drivers/gpu/drm/drm_pci.c +4 -4
index b2f8f1062d5f..d86362fc8ac6 100644
@@ -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,
drivers/gpu/drm/drm_scatter.c +3 -3
index bf70431073f6..275bca44f38c 100644
@@ -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))
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/2
#7 lore raw
In reply to Daniel Vetter
Quoted 11 lines · 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.

Quoted 129 lines
---
  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(-)
Documentation/gpu/drm-internals.rst +6 -3
index 3bb26135971f..37284bcc7764 100644
@@ -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
drivers/gpu/drm/i810/i810_drv.c +1 -3
index 44f4a131c8dd..0be55dc1ef4b 100644
@@ -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,
drivers/gpu/drm/mga/mga_drv.c +1 -1
index 5e2f131a6a72..25b2a1a424e6 100644
@@ -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,
drivers/gpu/drm/r128/r128_drv.c +1 -1
index c57b4de63caf..a982be57d1ef 100644
@@ -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,
drivers/gpu/drm/savage/savage_drv.c +1 -1
index 21aed1febeb4..3b807135a5cd 100644
@@ -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,
drivers/gpu/drm/sis/sis_drv.c +1 -1
index 79bce76cb8f7..ae9839886c4d 100644
@@ -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,
drivers/gpu/drm/tdfx/tdfx_drv.c +1 -0
index fab5ebcb0fef..f418892b0c71 100644
@@ -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,
drivers/gpu/drm/via/via_drv.c +1 -1
index ed8aa8ff861a..e5582bab7e3c 100644
@@ -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,
include/drm/drmP.h +0 -0
index 5f9caf7ee949..9c828d6f7cdc 100644

include/drm/drmP.h void drm_err(const char *format, ...); · line 152

Quoted 7 lines
include/drm/drmP.h +1 -0
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 1/2
#8 lore raw
In reply to Daniel Vetter

Hi

Quoted 11 lines · 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.

Quoted 11 lines
---
 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(-)

Also, how about this:

drivers/gpu/drm/Kconfig +7 -0
index fc35731..e609cfc 100644
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw
Quoted 26 lines · David Herrmann

Hi

Quoted 11 lines · 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.

Quoted 11 lines
---
 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(-)
Quoted 3 lines

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

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel