All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 00/12] Support render-node only drivers
@ 2014-02-21  7:55 Thierry Reding
  2014-02-21  7:55 ` [RFC 01/12] drm: Rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY Thierry Reding
                   ` (13 more replies)
  0 siblings, 14 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

This series builds on top of David's reliable DRM minor series:

	[PATCH 00/13] DRM Reliable Minor-IDs

Tegra K1 has a Kepler-type GPU without any display engine. Instead it
reuses the Tegra display engine. That means that effectively the GPU
becomes a render-node only device. In order to reflect that, it would
be preferable for the associated /dev/dri/cardX node not to show up.

To achieve that, the DRIVER_MODESET feature needs to be removed from
the GPU driver, but that unfortunately implies activating a bunch of
legacy behaviour for pre-KMS drivers. To allow for drivers that don't
support modesetting IOCTLs (because they drive no output) but which
aren't legacy either, the meaning of the DRIVER_MODESET needs to be
redefined.

This series attempts to do so by first renaming DRM_MINOR_LEGACY to
DRM_MINOR_PRIMARY to more accurately reflect its purpose. Legacy and
modesetting are then decoupled by introducing a DRIVER_LEGACY driver
feature that can be set by truly legacy drivers. This allows the old
DRIVER_MODESET feature to advertise support only for modesetting
functionality, without implying that it is a non-legacy driver.

After all the drivers have been updated, the core can be modified to
create the primary minor only when DRIVER_MODESET is available.

The remainder of the series cleans up some drm_core_check_feature()
usage and drop some unused code related to that.

Thierry

Thierry Reding (12):
  drm: Rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY
  drm: Introduce DRIVER_LEGACY feature
  drm/i915: Mark as legacy if KMS is disabled
  drm: Separate DRIVER_MODESET and DRIVER_LEGACY
  drm: Create primary minor only if mode-setting is supported
  drm: Remove gratuituous blank line
  drm: Use drm_core_check_feature() where possible
  drm/exynos: Remove dead code
  drm/gma500: Remove dead code
  drm/i810: Remove dead code
  drm/i915: Remove dead code
  drm/qxl: Remove dead code

 drivers/gpu/drm/drm_bufs.c              | 12 +++++------
 drivers/gpu/drm/drm_crtc.c              |  1 -
 drivers/gpu/drm/drm_dma.c               |  4 ++--
 drivers/gpu/drm/drm_fops.c              | 14 ++++++------
 drivers/gpu/drm/drm_gem.c               |  6 +++---
 drivers/gpu/drm/drm_irq.c               | 12 +++++------
 drivers/gpu/drm/drm_pci.c               | 12 +++++------
 drivers/gpu/drm/drm_scatter.c           |  6 +++---
 drivers/gpu/drm/drm_stub.c              | 24 +++++++++++----------
 drivers/gpu/drm/drm_sysfs.c             |  8 +++----
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 10 ---------
 drivers/gpu/drm/gma500/gem.c            |  3 ---
 drivers/gpu/drm/i810/i810_dma.c         |  7 ------
 drivers/gpu/drm/i810/i810_drv.c         |  3 ++-
 drivers/gpu/drm/i915/i915_dma.c         | 38 ++++++++++++++++-----------------
 drivers/gpu/drm/i915/i915_drv.c         | 18 ++++++++++------
 drivers/gpu/drm/i915/i915_gem.c         | 17 +++++++--------
 drivers/gpu/drm/i915/i915_gem_context.c |  6 ------
 drivers/gpu/drm/i915/i915_irq.c         |  6 +++---
 drivers/gpu/drm/i915/i915_suspend.c     | 15 ++++++-------
 drivers/gpu/drm/i915/intel_ringbuffer.c |  2 +-
 drivers/gpu/drm/mga/mga_drv.c           |  3 ++-
 drivers/gpu/drm/qxl/qxl_kms.c           |  4 ----
 drivers/gpu/drm/radeon/radeon_drv.c     |  3 ++-
 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                      |  3 ++-
 29 files changed, 112 insertions(+), 132 deletions(-)

-- 
1.8.4.2

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

* [RFC 01/12] drm: Rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-21  7:55 ` [RFC 02/12] drm: Introduce DRIVER_LEGACY feature Thierry Reding
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The term "legacy" is overloaded in the context of DRM. DRM_MINOR_LEGACY
doesn't accurately describe the use of the minor. The associated minor
is the primary minor for a device, as reflected by the .primary field of
struct drm_device. For consistency, rename the enumeration value to
DRM_MINOR_PRIMARY.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/drm_stub.c  | 16 ++++++++--------
 drivers/gpu/drm/drm_sysfs.c |  4 ++--
 include/drm/drmP.h          |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 2567ecb5c574..fd2f1758366d 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -319,7 +319,7 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
 					     unsigned int type)
 {
 	switch (type) {
-	case DRM_MINOR_LEGACY:
+	case DRM_MINOR_PRIMARY:
 		return &dev->primary;
 	case DRM_MINOR_RENDER:
 		return &dev->render;
@@ -493,7 +493,7 @@ EXPORT_SYMBOL(drm_put_dev);
 void drm_unplug_dev(struct drm_device *dev)
 {
 	/* for a USB device */
-	drm_minor_unregister(dev, DRM_MINOR_LEGACY);
+	drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
 	drm_minor_unregister(dev, DRM_MINOR_RENDER);
 	drm_minor_unregister(dev, DRM_MINOR_CONTROL);
 
@@ -564,7 +564,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
 			goto err_minors;
 	}
 
-	ret = drm_minor_alloc(dev, DRM_MINOR_LEGACY);
+	ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
 	if (ret)
 		goto err_minors;
 
@@ -592,7 +592,7 @@ err_ctxbitmap:
 err_ht:
 	drm_ht_remove(&dev->map_hash);
 err_minors:
-	drm_minor_free(dev, DRM_MINOR_LEGACY);
+	drm_minor_free(dev, DRM_MINOR_PRIMARY);
 	drm_minor_free(dev, DRM_MINOR_RENDER);
 	drm_minor_free(dev, DRM_MINOR_CONTROL);
 	drm_minor_free_base(dev);
@@ -618,7 +618,7 @@ static void drm_dev_free(struct drm_device *dev)
 	drm_ctxbitmap_cleanup(dev);
 	drm_ht_remove(&dev->map_hash);
 
-	drm_minor_free(dev, DRM_MINOR_LEGACY);
+	drm_minor_free(dev, DRM_MINOR_PRIMARY);
 	drm_minor_free(dev, DRM_MINOR_RENDER);
 	drm_minor_free(dev, DRM_MINOR_CONTROL);
 	drm_minor_free_base(dev);
@@ -692,7 +692,7 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 	if (ret)
 		goto err_minors;
 
-	ret = drm_minor_register(dev, DRM_MINOR_LEGACY);
+	ret = drm_minor_register(dev, DRM_MINOR_PRIMARY);
 	if (ret)
 		goto err_minors;
 
@@ -718,7 +718,7 @@ err_unload:
 	if (dev->driver->unload)
 		dev->driver->unload(dev);
 err_minors:
-	drm_minor_unregister(dev, DRM_MINOR_LEGACY);
+	drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
 	drm_minor_unregister(dev, DRM_MINOR_RENDER);
 	drm_minor_unregister(dev, DRM_MINOR_CONTROL);
 out_unlock:
@@ -752,7 +752,7 @@ void drm_dev_unregister(struct drm_device *dev)
 	list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
 		drm_rmmap(dev, r_list->map);
 
-	drm_minor_unregister(dev, DRM_MINOR_LEGACY);
+	drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
 	drm_minor_unregister(dev, DRM_MINOR_RENDER);
 	drm_minor_unregister(dev, DRM_MINOR_CONTROL);
 }
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 9be02d9a78e8..c3f3d0b6a8fe 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -43,7 +43,7 @@ static int __drm_class_suspend(struct device *dev, pm_message_t state)
 		struct drm_minor *drm_minor = to_drm_minor(dev);
 		struct drm_device *drm_dev = drm_minor->dev;
 
-		if (drm_minor->type == DRM_MINOR_LEGACY &&
+		if (drm_minor->type == DRM_MINOR_PRIMARY &&
 		    !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
 		    drm_dev->driver->suspend)
 			return drm_dev->driver->suspend(drm_dev, state);
@@ -84,7 +84,7 @@ static int drm_class_resume(struct device *dev)
 		struct drm_minor *drm_minor = to_drm_minor(dev);
 		struct drm_device *drm_dev = drm_minor->dev;
 
-		if (drm_minor->type == DRM_MINOR_LEGACY &&
+		if (drm_minor->type == DRM_MINOR_PRIMARY &&
 		    !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
 		    drm_dev->driver->resume)
 			return drm_dev->driver->resume(drm_dev);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index e5f6732f4757..92604c435ecc 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1010,7 +1010,7 @@ struct drm_driver {
 };
 
 enum drm_minor_type {
-	DRM_MINOR_LEGACY,
+	DRM_MINOR_PRIMARY,
 	DRM_MINOR_CONTROL,
 	DRM_MINOR_RENDER,
 	DRM_MINOR_CNT,
-- 
1.8.4.2

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

* [RFC 02/12] drm: Introduce DRIVER_LEGACY feature
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
  2014-02-21  7:55 ` [RFC 01/12] drm: Rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-21  7:55 ` [RFC 03/12] drm/i915: Mark as legacy if KMS is disabled Thierry Reding
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Currently drivers that set the DRIVER_MODESET feature are considered to
be non-legacy drivers. At the same time DRIVER_MODESET implies that the
mode-setting IOCTLs are available. It is therefore not possible to
distinguish between a non-legacy driver with full mode-setting support
and a non-legacy driver without mode-setting functionality.

To separate the meaning of "legacy" and "modeset", a new driver feature
is introduced: DRIVER_LEGACY. The meaning of DRIVER_MODESET can then be
changed to apply to the mode-setting functionality only, irrespective
of whether it is legacy or not.

Mark all legacy drivers appropriately.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/i810/i810_drv.c     | 3 ++-
 drivers/gpu/drm/mga/mga_drv.c       | 3 ++-
 drivers/gpu/drm/radeon/radeon_drv.c | 3 ++-
 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 +
 8 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 441ccf8f5bdc..fb21abfba414 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -58,7 +58,8 @@ static const struct file_operations i810_driver_fops = {
 static struct drm_driver driver = {
 	.driver_features =
 	    DRIVER_USE_AGP |
-	    DRIVER_HAVE_DMA,
+	    DRIVER_HAVE_DMA |
+	    DRIVER_LEGACY,
 	.dev_priv_size = sizeof(drm_i810_buf_priv_t),
 	.load = i810_driver_load,
 	.lastclose = i810_driver_lastclose,
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 6b1a87c8aac5..0bd929e38d99 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -59,7 +59,8 @@ static const struct file_operations mga_driver_fops = {
 static struct drm_driver driver = {
 	.driver_features =
 	    DRIVER_USE_AGP | DRIVER_PCI_DMA |
-	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
+	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
+	    DRIVER_LEGACY,
 	.dev_priv_size = sizeof(drm_mga_buf_priv_t),
 	.load = mga_driver_load,
 	.unload = mga_driver_unload,
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 84a1bbb75f91..5afa997bab00 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -292,7 +292,8 @@ static const struct file_operations radeon_driver_old_fops = {
 static struct drm_driver driver_old = {
 	.driver_features =
 	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
-	    DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED,
+	    DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED |
+	    DRIVER_LEGACY,
 	.dev_priv_size = sizeof(drm_radeon_buf_priv_t),
 	.load = radeon_driver_load,
 	.firstopen = radeon_driver_firstopen,
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 3c030216e888..bedb800eb7d0 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -50,7 +50,7 @@ static const struct file_operations savage_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA,
+	    DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA | DRIVER_LEGACY,
 	.dev_priv_size = sizeof(drm_savage_buf_priv_t),
 	.load = savage_driver_load,
 	.firstopen = savage_driver_firstopen,
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 756f787b7143..402f10b58d57 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -102,7 +102,7 @@ static void sis_driver_postclose(struct drm_device *dev, struct drm_file *file)
 }
 
 static struct drm_driver driver = {
-	.driver_features = DRIVER_USE_AGP,
+	.driver_features = DRIVER_USE_AGP | DRIVER_LEGACY,
 	.load = sis_driver_load,
 	.unload = sis_driver_unload,
 	.open = sis_driver_open,
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index 3492ca5c46d3..fc61c476ff49 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -55,6 +55,7 @@ static const struct file_operations tdfx_driver_fops = {
 };
 
 static struct drm_driver driver = {
+	.features = DRIVER_LEGACY,
 	.fops = &tdfx_driver_fops,
 	.name = DRIVER_NAME,
 	.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 50abc2adfaee..c16ca40b8e07 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -73,7 +73,7 @@ static const struct file_operations via_driver_fops = {
 static struct drm_driver driver = {
 	.driver_features =
 	    DRIVER_USE_AGP | DRIVER_HAVE_IRQ |
-	    DRIVER_IRQ_SHARED,
+	    DRIVER_IRQ_SHARED | DRIVER_LEGACY,
 	.load = via_driver_load,
 	.unload = via_driver_unload,
 	.open = via_driver_open,
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 92604c435ecc..3aafb2d2471a 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -147,6 +147,7 @@ int drm_err(const char *func, const char *format, ...);
 #define DRIVER_MODESET     0x2000
 #define DRIVER_PRIME       0x4000
 #define DRIVER_RENDER      0x8000
+#define DRIVER_LEGACY      0x10000
 
 #define DRIVER_BUS_PCI 0x1
 #define DRIVER_BUS_PLATFORM 0x2
-- 
1.8.4.2

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

* [RFC 03/12] drm/i915: Mark as legacy if KMS is disabled
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
  2014-02-21  7:55 ` [RFC 01/12] drm: Rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY Thierry Reding
  2014-02-21  7:55 ` [RFC 02/12] drm: Introduce DRIVER_LEGACY feature Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-21  8:17   ` Ilia Mirkin
  2014-02-21  7:55 ` [RFC 04/12] drm: Separate DRIVER_MODESET and DRIVER_LEGACY Thierry Reding
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

When kernel mode-setting is disabled, mark the driver as legacy to pick
up the special semantics required for userspace mode-setting.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/i915/i915_drv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 2d05d7ce4c29..ea916e117f01 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -985,13 +985,19 @@ static int __init i915_init(void)
 #if defined(CONFIG_DRM_I915_KMS)
 	if (i915.modeset != 0)
 		driver.driver_features |= DRIVER_MODESET;
+	else
+		driver.driver_features |= DRIVER_LEGACY;
 #endif
 	if (i915.modeset == 1)
 		driver.driver_features |= DRIVER_MODESET;
+	else
+		driver.driver_features |= DRIVER_LEGACY;
 
 #ifdef CONFIG_VGA_CONSOLE
-	if (vgacon_text_force() && i915.modeset == -1)
+	if (vgacon_text_force() && i915.modeset == -1) {
 		driver.driver_features &= ~DRIVER_MODESET;
+		driver.driver_features |= DRIVER_LEGACY;
+	}
 #endif
 
 	if (!(driver.driver_features & DRIVER_MODESET)) {
-- 
1.8.4.2

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

* [RFC 04/12] drm: Separate DRIVER_MODESET and DRIVER_LEGACY
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (2 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 03/12] drm/i915: Mark as legacy if KMS is disabled Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-21  7:55 ` [RFC 05/12] drm: Create primary minor only if mode-setting is supported Thierry Reding
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Support non-legacy drivers without mode-setting functionality by using
the new DRIVER_LEGACY feature to separate out legacy code, rather than
relying on DRIVER_MODESET not being advertised.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/drm_bufs.c              | 12 +++++------
 drivers/gpu/drm/drm_dma.c               |  4 ++--
 drivers/gpu/drm/drm_fops.c              |  6 +++---
 drivers/gpu/drm/drm_irq.c               | 12 +++++------
 drivers/gpu/drm/drm_pci.c               | 12 +++++------
 drivers/gpu/drm/drm_scatter.c           |  6 +++---
 drivers/gpu/drm/drm_sysfs.c             |  4 ++--
 drivers/gpu/drm/i915/i915_dma.c         | 38 ++++++++++++++++-----------------
 drivers/gpu/drm/i915/i915_drv.c         | 10 ++++-----
 drivers/gpu/drm/i915/i915_gem.c         | 17 +++++++--------
 drivers/gpu/drm/i915/i915_irq.c         |  6 +++---
 drivers/gpu/drm/i915/i915_suspend.c     | 15 ++++++-------
 drivers/gpu/drm/i915/intel_ringbuffer.c |  2 +-
 13 files changed, 71 insertions(+), 73 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index edec31fe3fed..362ad21bd0e4 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1141,7 +1141,7 @@ int drm_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))
@@ -1187,7 +1187,7 @@ int drm_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))
@@ -1269,7 +1269,7 @@ int drm_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))
@@ -1317,7 +1317,7 @@ int drm_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))
@@ -1372,7 +1372,7 @@ int drm_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))
@@ -1452,7 +1452,7 @@ int drm_mapbufs(struct drm_device *dev, void *data,
 int drm_dma_ioctl(struct drm_device *dev, void *data,
 		  struct drm_file *file_priv)
 {
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -EINVAL;
 
 	if (dev->driver->dma_ioctl)
diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
index 8a140a953754..bce37007c9c3 100644
--- a/drivers/gpu/drm/drm_dma.c
+++ b/drivers/gpu/drm/drm_dma.c
@@ -49,7 +49,7 @@ 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;
 	}
 
@@ -80,7 +80,7 @@ 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;
 	}
 
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 80e2a6c5ff8a..46eee1da4ad7 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -50,8 +50,8 @@ static int drm_setup(struct drm_device * dev)
 {
 	int ret;
 
-	if (dev->driver->firstopen &&
-	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
+	    dev->driver->firstopen) {
 		ret = dev->driver->firstopen(dev);
 		if (ret != 0)
 			return ret;
@@ -386,7 +386,7 @@ static void drm_events_release(struct drm_file *file_priv)
  */
 static void drm_legacy_dev_reinit(struct drm_device *dev)
 {
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	dev->sigdata.lock = NULL;
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index c2676b5908d9..7040b30973b8 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -321,7 +321,7 @@ int drm_irq_install(struct drm_device *dev)
 		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 */
@@ -332,7 +332,7 @@ int drm_irq_install(struct drm_device *dev)
 		mutex_lock(&dev->struct_mutex);
 		dev->irq_enabled = false;
 		mutex_unlock(&dev->struct_mutex);
-		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(drm_dev_to_irq(dev), dev);
 	}
@@ -381,7 +381,7 @@ int drm_irq_uninstall(struct drm_device *dev)
 
 	DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev));
 
-	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)
@@ -418,7 +418,7 @@ int drm_control(struct drm_device *dev, void *data,
 	case DRM_INST_HANDLER:
 		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;
 		if (dev->if_version < DRM_IF_VERSION(1, 2) &&
 		    ctl->irq != drm_dev_to_irq(dev))
@@ -427,7 +427,7 @@ int drm_control(struct drm_device *dev, void *data,
 	case DRM_UNINST_HANDLER:
 		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;
 		return drm_irq_uninstall(dev);
 	default:
@@ -1048,7 +1048,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;
 
 	crtc = modeset->crtc;
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 4e6f5ea5643c..e4223ccedd9c 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -327,7 +327,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 	dev->hose = pdev->sysdata;
 #endif
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		pci_set_drvdata(pdev, dev);
 
 	drm_pci_agp_init(dev);
@@ -342,7 +342,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;
@@ -378,7 +378,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
 	driver->kdriver.pci = pdriver;
 	driver->bus = &drm_pci_bus;
 
-	if (driver->driver_features & DRIVER_MODESET)
+	if ((driver->driver_features & DRIVER_LEGACY) == 0)
 		return pci_register_driver(pdriver);
 
 	/* If not using KMS, fall back to stealth mode manual scanning. */
@@ -463,14 +463,14 @@ 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) {
-		pci_unregister_driver(pdriver);
-	} else {
+	if (driver->driver_features & DRIVER_LEGACY) {
 		list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
 					 legacy_dev_list) {
 			drm_put_dev(dev);
 			list_del(&dev->legacy_dev_list);
 		}
+	} else {
+		pci_unregister_driver(pdriver);
 	}
 	DRM_INFO("Module unloaded\n");
 }
diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
index 1c78406f6e71..de745ec3d118 100644
--- a/drivers/gpu/drm/drm_scatter.c
+++ b/drivers/gpu/drm/drm_scatter.c
@@ -67,7 +67,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;
 	}
@@ -87,7 +87,7 @@ int drm_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))
@@ -200,7 +200,7 @@ int drm_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))
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index c3f3d0b6a8fe..75157fd8607f 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -44,7 +44,7 @@ static int __drm_class_suspend(struct device *dev, pm_message_t state)
 		struct drm_device *drm_dev = drm_minor->dev;
 
 		if (drm_minor->type == DRM_MINOR_PRIMARY &&
-		    !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
+		    drm_core_check_feature(drm_dev, DRIVER_LEGACY) &&
 		    drm_dev->driver->suspend)
 			return drm_dev->driver->suspend(drm_dev, state);
 	}
@@ -85,7 +85,7 @@ static int drm_class_resume(struct device *dev)
 		struct drm_device *drm_dev = drm_minor->dev;
 
 		if (drm_minor->type == DRM_MINOR_PRIMARY &&
-		    !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
+		    drm_core_check_feature(drm_dev, DRIVER_LEGACY) &&
 		    drm_dev->driver->resume)
 			return drm_dev->driver->resume(drm_dev);
 	}
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 7688abc83fc0..5cbb1cc80c68 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -90,7 +90,7 @@ void i915_update_dri1_breadcrumb(struct drm_device *dev)
 	 * Instead of trying to fix this (this is by far not the only ums issue)
 	 * just don't do the update in kms mode.
 	 */
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	if (dev->primary->master) {
@@ -145,7 +145,7 @@ void i915_kernel_lost_context(struct drm_device * dev)
 	 * We should never lose context on the ring with modesetting
 	 * as we don't expose it to userspace
 	 */
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	ring->head = I915_READ_HEAD(ring) & HEAD_ADDR;
@@ -267,7 +267,7 @@ static int i915_dma_init(struct drm_device *dev, void *data,
 	drm_i915_init_t *init = data;
 	int retcode = 0;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	switch (init->func) {
@@ -610,7 +610,7 @@ static int i915_flush_ioctl(struct drm_device *dev, void *data,
 {
 	int ret;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	RING_LOCK_TEST_WITH_RETURN(dev, file_priv);
@@ -632,7 +632,7 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
 	int ret;
 	struct drm_clip_rect *cliprects = NULL;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	master_priv = dev->primary->master->driver_priv;
@@ -694,7 +694,7 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
 	DRM_DEBUG_DRIVER("i915 cmdbuffer, buf %p sz %d cliprects %d\n",
 			cmdbuf->buf, cmdbuf->sz, cmdbuf->num_cliprects);
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	master_priv = dev->primary->master->driver_priv;
@@ -820,7 +820,7 @@ static int i915_irq_emit(struct drm_device *dev, void *data,
 	drm_i915_irq_emit_t *emit = data;
 	int result;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	if (!dev_priv || !LP_RING(dev_priv)->virtual_start) {
@@ -850,7 +850,7 @@ static int i915_irq_wait(struct drm_device *dev, void *data,
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	drm_i915_irq_wait_t *irqwait = data;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	if (!dev_priv) {
@@ -867,7 +867,7 @@ static int i915_vblank_pipe_get(struct drm_device *dev, void *data,
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	drm_i915_vblank_pipe_t *pipe = data;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	if (!dev_priv) {
@@ -908,7 +908,7 @@ static int i915_flip_bufs(struct drm_device *dev, void *data,
 {
 	int ret;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	DRM_DEBUG_DRIVER("%s\n", __func__);
@@ -1072,7 +1072,7 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
 	drm_i915_hws_addr_t *hws = data;
 	struct intel_ring_buffer *ring;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	if (!I915_NEED_GFX_HWS(dev))
@@ -1083,7 +1083,7 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
 		return -EINVAL;
 	}
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		WARN(1, "tried to set status page when mode setting active\n");
 		return 0;
 	}
@@ -1536,14 +1536,14 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	info = (struct intel_device_info *) flags;
 
 	/* Refuse to load on gen6+ without kms enabled. */
-	if (info->gen >= 6 && !drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (info->gen >= 6 && drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		DRM_INFO("Your hardware requires kernel modesetting (KMS)\n");
 		DRM_INFO("See CONFIG_DRM_I915_KMS, nomodeset, and i915.modeset parameters\n");
 		return -ENODEV;
 	}
 
 	/* UMS needs agp support. */
-	if (!drm_core_check_feature(dev, DRIVER_MODESET) && !dev->agp)
+	if (drm_core_check_feature(dev, DRIVER_LEGACY) && !dev->agp)
 		return -EINVAL;
 
 	dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
@@ -1615,7 +1615,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	if (ret)
 		goto out_regs;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		i915_kick_out_firmware_fb(dev_priv);
 
 	pci_set_master(dev->pdev);
@@ -1704,7 +1704,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
 	intel_power_domains_init(dev);
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		ret = i915_load_modeset_init(dev);
 		if (ret < 0) {
 			DRM_ERROR("failed to init modeset\n");
@@ -1794,7 +1794,7 @@ int i915_driver_unload(struct drm_device *dev)
 
 	acpi_video_unregister();
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		intel_fbdev_fini(dev);
 		intel_modeset_cleanup(dev);
 		cancel_work_sync(&dev_priv->console_resume_work);
@@ -1825,7 +1825,7 @@ int i915_driver_unload(struct drm_device *dev)
 
 	intel_opregion_fini(dev);
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		/* Flush any outstanding unpin_work. */
 		flush_workqueue(dev_priv->wq);
 
@@ -1900,7 +1900,7 @@ void i915_driver_lastclose(struct drm_device * dev)
 	if (!dev_priv)
 		return;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		intel_fbdev_restore_mode(dev);
 		vga_switcheroo_process_delayed_switch();
 		return;
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index ea916e117f01..6afdd75756da 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -549,7 +549,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)
 
 	intel_uncore_sanitize(dev);
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET) &&
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY) &&
 	    restore_gtt_mappings) {
 		mutex_lock(&dev->struct_mutex);
 		i915_gem_restore_gtt_mappings(dev);
@@ -620,7 +620,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)
 
 static int i915_drm_thaw(struct drm_device *dev)
 {
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		i915_check_and_clear_faults(dev);
 
 	return __i915_drm_thaw(dev, true);
@@ -715,7 +715,7 @@ int i915_reset(struct drm_device *dev)
 	 * was running at the time of the reset (i.e. we weren't VT
 	 * switched away).
 	 */
-	if (drm_core_check_feature(dev, DRIVER_MODESET) ||
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY) ||
 			!dev_priv->ums.mm_suspended) {
 		dev_priv->ums.mm_suspended = 0;
 
@@ -1000,7 +1000,7 @@ static int __init i915_init(void)
 	}
 #endif
 
-	if (!(driver.driver_features & DRIVER_MODESET)) {
+	if (driver.driver_features & DRIVER_LEGACY) {
 		driver.get_vblank_timestamp = NULL;
 #ifndef CONFIG_DRM_I915_UMS
 		/* Silently fail loading to not upset userspace. */
@@ -1014,7 +1014,7 @@ static int __init i915_init(void)
 static void __exit i915_exit(void)
 {
 #ifndef CONFIG_DRM_I915_UMS
-	if (!(driver.driver_features & DRIVER_MODESET))
+	if (driver.driver_features & DRIVER_LEGACY)
 		return; /* Never loaded a driver. */
 #endif
 
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 3618bb0cda0a..b066056eadcd 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -166,7 +166,7 @@ i915_gem_init_ioctl(struct drm_device *dev, void *data,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_init *args = data;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return -ENODEV;
 
 	if (args->gtt_start >= args->gtt_end ||
@@ -4234,7 +4234,7 @@ i915_gem_suspend(struct drm_device *dev)
 	i915_gem_retire_requests(dev);
 
 	/* Under UMS, be paranoid and evict. */
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		i915_gem_evict_everything(dev);
 
 	i915_kernel_lost_context(dev);
@@ -4244,8 +4244,7 @@ i915_gem_suspend(struct drm_device *dev)
 	 * We need to replace this with a semaphore, or something.
 	 * And not confound ums.mm_suspended!
 	 */
-	dev_priv->ums.mm_suspended = !drm_core_check_feature(dev,
-							     DRIVER_MODESET);
+	dev_priv->ums.mm_suspended = drm_core_check_feature(dev, DRIVER_LEGACY);
 	mutex_unlock(&dev->struct_mutex);
 
 	del_timer_sync(&dev_priv->gpu_error.hangcheck_timer);
@@ -4466,7 +4465,7 @@ int i915_gem_init(struct drm_device *dev)
 	}
 
 	/* Allow hardware batchbuffers unless told otherwise, but not for KMS. */
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		dev_priv->dri1.allow_batchbuffer = 1;
 	return 0;
 }
@@ -4489,7 +4488,7 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return 0;
 
 	if (i915_reset_in_progress(&dev_priv->gpu_error)) {
@@ -4528,7 +4527,7 @@ int
 i915_gem_leavevt_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 0;
 
 	drm_irq_uninstall(dev);
@@ -4541,7 +4540,7 @@ i915_gem_lastclose(struct drm_device *dev)
 {
 	int ret;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return;
 
 	ret = i915_gem_suspend(dev);
@@ -4606,7 +4605,7 @@ i915_gem_load(struct drm_device *dev)
 	dev_priv->relative_constants_mode = I915_EXEC_CONSTANTS_REL_GENERAL;
 
 	/* Old X drivers will take 0-2 for front, back, depth buffers */
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		dev_priv->fence_reg_start = 3;
 
 	if (INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev))
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index f68aee31e565..6114a0db4a40 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -614,7 +614,7 @@ i915_pipe_enabled(struct drm_device *dev, int pipe)
 {
 	drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		/* Locking is horribly broken here, but whatever. */
 		struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
 		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
@@ -647,7 +647,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
 		return 0;
 	}
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		struct intel_crtc *intel_crtc =
 			to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
 		const struct drm_display_mode *mode =
@@ -3936,7 +3936,7 @@ void intel_irq_init(struct drm_device *dev)
 		dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
 	}
 
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (!drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
 		dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
 	}
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index 56785e8fb2eb..0866cb2018cd 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -199,7 +199,7 @@ static void i915_save_display(struct drm_device *dev)
 
 	/* This is only meaningful in non-KMS mode */
 	/* Don't regfile.save them in KMS mode */
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		i915_save_display_reg(dev);
 
 	/* LVDS state */
@@ -240,7 +240,7 @@ static void i915_save_display(struct drm_device *dev)
 	if (HAS_FBC(dev) && INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev))
 		dev_priv->regfile.saveFBC_CONTROL = I915_READ(FBC_CONTROL);
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		i915_save_vga(dev);
 }
 
@@ -253,10 +253,9 @@ static void i915_restore_display(struct drm_device *dev)
 	if (INTEL_INFO(dev)->gen <= 4)
 		I915_WRITE(DSPARB, dev_priv->regfile.saveDSPARB);
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		i915_restore_display_reg(dev);
-
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
+	else
 		mask = ~LVDS_PORT_EN;
 
 	if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
@@ -295,7 +294,7 @@ static void i915_restore_display(struct drm_device *dev)
 	if (HAS_FBC(dev) && INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev))
 		I915_WRITE(FBC_CONTROL, dev_priv->regfile.saveFBC_CONTROL);
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+	if (drm_core_check_feature(dev, DRIVER_LEGACY))
 		i915_restore_vga(dev);
 	else
 		i915_redisable_vga(dev);
@@ -310,7 +309,7 @@ int i915_save_state(struct drm_device *dev)
 
 	i915_save_display(dev);
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		/* Interrupt state */
 		if (HAS_PCH_SPLIT(dev)) {
 			dev_priv->regfile.saveDEIER = I915_READ(DEIER);
@@ -360,7 +359,7 @@ int i915_restore_state(struct drm_device *dev)
 	i915_gem_restore_fences(dev);
 	i915_restore_display(dev);
 
-	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
+	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
 		/* Interrupt state */
 		if (HAS_PCH_SPLIT(dev)) {
 			I915_WRITE(DEIER, dev_priv->regfile.saveDEIER);
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index b340c7587629..0b2625f6ff9a 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -499,7 +499,7 @@ static int init_ring_common(struct intel_ring_buffer *ring)
 		goto out;
 	}
 
-	if (!drm_core_check_feature(ring->dev, DRIVER_MODESET))
+	if (drm_core_check_feature(ring->dev, DRIVER_LEGACY))
 		i915_kernel_lost_context(ring->dev);
 	else {
 		ring->head = I915_READ_HEAD(ring);
-- 
1.8.4.2

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

* [RFC 05/12] drm: Create primary minor only if mode-setting is supported
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (3 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 04/12] drm: Separate DRIVER_MODESET and DRIVER_LEGACY Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-24 10:39   ` David Herrmann
  2014-02-21  7:55 ` [RFC 06/12] drm: Remove gratuituous blank line Thierry Reding
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Non-legacy devices may not always support mode-setting functionality, so
create the primary minor conditionally.

One setup where this happens is the Tegra K1, where the Tegra DRM driver
exposes the display engine via standard KMS IOCTLs, and nouveau drives
the Kepler-type GPU that has no display capabilities.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/drm_stub.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index fd2f1758366d..839460b774c5 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -564,9 +564,11 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
 			goto err_minors;
 	}
 
-	ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
-	if (ret)
-		goto err_minors;
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
+		if (ret)
+			goto err_minors;
+	}
 
 	if (drm_ht_create(&dev->map_hash, 12))
 		goto err_minors;
-- 
1.8.4.2

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

* [RFC 06/12] drm: Remove gratuituous blank line
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (4 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 05/12] drm: Create primary minor only if mode-setting is supported Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-21  7:55 ` [RFC 07/12] drm: Use drm_core_check_feature() where possible Thierry Reding
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/drm_crtc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 35ea15d5ffff..9f9044a0a3ee 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1426,7 +1426,6 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return -EINVAL;
 
-
 	mutex_lock(&file_priv->fbs_lock);
 	/*
 	 * For the non-control nodes we need to limit the list of resources
-- 
1.8.4.2

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

* [RFC 07/12] drm: Use drm_core_check_feature() where possible
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (5 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 06/12] drm: Remove gratuituous blank line Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-21  7:55 ` [RFC 08/12] drm/exynos: Remove dead code Thierry Reding
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Wherever possible, use drm_core_check_feature() for consistency.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/drm_fops.c              | 8 ++++----
 drivers/gpu/drm/drm_gem.c               | 6 +++---
 drivers/gpu/drm/drm_stub.c              | 2 +-
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 4 ++--
 drivers/gpu/drm/gma500/gem.c            | 2 +-
 drivers/gpu/drm/i915/i915_gem_context.c | 4 ++--
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 46eee1da4ad7..b78ce8eaae81 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -242,7 +242,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
 	init_waitqueue_head(&priv->event_wait);
 	priv->event_space = 4096; /* set aside 4k for event buffer */
 
-	if (dev->driver->driver_features & DRIVER_GEM)
+	if (drm_core_check_feature(dev, DRIVER_GEM))
 		drm_gem_open(dev, priv);
 
 	if (drm_core_check_feature(dev, DRIVER_PRIME))
@@ -333,7 +333,7 @@ out_close:
 out_prime_destroy:
 	if (drm_core_check_feature(dev, DRIVER_PRIME))
 		drm_prime_destroy_file_private(&priv->prime);
-	if (dev->driver->driver_features & DRIVER_GEM)
+	if (drm_core_check_feature(dev, DRIVER_GEM))
 		drm_gem_release(dev, priv);
 	put_pid(priv->pid);
 	kfree(priv);
@@ -490,10 +490,10 @@ int drm_release(struct inode *inode, struct file *filp)
 
 	drm_events_release(file_priv);
 
-	if (dev->driver->driver_features & DRIVER_MODESET)
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		drm_fb_release(file_priv);
 
-	if (dev->driver->driver_features & DRIVER_GEM)
+	if (drm_core_check_feature(dev, DRIVER_GEM))
 		drm_gem_release(dev, file_priv);
 
 	mutex_lock(&dev->ctxlist_mutex);
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 5bbad873c798..44ca82f6a211 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -545,7 +545,7 @@ drm_gem_close_ioctl(struct drm_device *dev, void *data,
 	struct drm_gem_close *args = data;
 	int ret;
 
-	if (!(dev->driver->driver_features & DRIVER_GEM))
+	if (!drm_core_check_feature(dev, DRIVER_GEM))
 		return -ENODEV;
 
 	ret = drm_gem_handle_delete(file_priv, args->handle);
@@ -567,7 +567,7 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
 	struct drm_gem_object *obj;
 	int ret;
 
-	if (!(dev->driver->driver_features & DRIVER_GEM))
+	if (!drm_core_check_feature(dev, DRIVER_GEM))
 		return -ENODEV;
 
 	obj = drm_gem_object_lookup(dev, file_priv, args->handle);
@@ -615,7 +615,7 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data,
 	int ret;
 	u32 handle;
 
-	if (!(dev->driver->driver_features & DRIVER_GEM))
+	if (!drm_core_check_feature(dev, DRIVER_GEM))
 		return -ENODEV;
 
 	mutex_lock(&dev->object_name_lock);
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 839460b774c5..9079a9f90e7b 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -614,7 +614,7 @@ EXPORT_SYMBOL(drm_dev_alloc);
  */
 static void drm_dev_free(struct drm_device *dev)
 {
-	if (dev->driver->driver_features & DRIVER_GEM)
+	if (drm_core_check_feature(dev, DRIVER_GEM))
 		drm_gem_destroy(dev);
 
 	drm_ctxbitmap_cleanup(dev);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 42d2904d88c7..07a4d0f92722 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -329,7 +329,7 @@ int exynos_drm_gem_map_offset_ioctl(struct drm_device *dev, void *data,
 	DRM_DEBUG_KMS("handle = 0x%x, offset = 0x%lx\n",
 			args->handle, (unsigned long)args->offset);
 
-	if (!(dev->driver->driver_features & DRIVER_GEM)) {
+	if (!drm_core_check_feature(dev, DRIVER_GEM)) {
 		DRM_ERROR("does not support GEM.\n");
 		return -ENODEV;
 	}
@@ -396,7 +396,7 @@ int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
 	struct file *anon_filp;
 	unsigned long addr;
 
-	if (!(dev->driver->driver_features & DRIVER_GEM)) {
+	if (!drm_core_check_feature(dev, DRIVER_GEM)) {
 		DRM_ERROR("does not support GEM.\n");
 		return -ENODEV;
 	}
diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c
index e2db48a81ed0..d8426bc31b09 100644
--- a/drivers/gpu/drm/gma500/gem.c
+++ b/drivers/gpu/drm/gma500/gem.c
@@ -62,7 +62,7 @@ int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
 	int ret = 0;
 	struct drm_gem_object *obj;
 
-	if (!(dev->driver->driver_features & DRIVER_GEM))
+	if (!drm_core_check_feature(dev, DRIVER_GEM))
 		return -ENODEV;
 
 	mutex_lock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index f8c21a6dd663..e9bba3c29ec6 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -746,7 +746,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 	struct i915_hw_context *ctx;
 	int ret;
 
-	if (!(dev->driver->driver_features & DRIVER_GEM))
+	if (!drm_core_check_feature(dev, DRIVER_GEM))
 		return -ENODEV;
 
 	if (!HAS_HW_CONTEXTS(dev))
@@ -775,7 +775,7 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
 	struct i915_hw_context *ctx;
 	int ret;
 
-	if (!(dev->driver->driver_features & DRIVER_GEM))
+	if (!drm_core_check_feature(dev, DRIVER_GEM))
 		return -ENODEV;
 
 	if (args->ctx_id == DEFAULT_CONTEXT_ID)
-- 
1.8.4.2

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

* [RFC 08/12] drm/exynos: Remove dead code
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (6 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 07/12] drm: Use drm_core_check_feature() where possible Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-21  7:55 ` [RFC 09/12] drm/gma500: " Thierry Reding
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The Exynos driver always sets DRIVER_GEM, so testing for the absence of
the feature will always fail.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 07a4d0f92722..9230d6f7f964 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -329,11 +329,6 @@ int exynos_drm_gem_map_offset_ioctl(struct drm_device *dev, void *data,
 	DRM_DEBUG_KMS("handle = 0x%x, offset = 0x%lx\n",
 			args->handle, (unsigned long)args->offset);
 
-	if (!drm_core_check_feature(dev, DRIVER_GEM)) {
-		DRM_ERROR("does not support GEM.\n");
-		return -ENODEV;
-	}
-
 	return exynos_drm_gem_dumb_map_offset(file_priv, dev, args->handle,
 			&args->offset);
 }
@@ -396,11 +391,6 @@ int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
 	struct file *anon_filp;
 	unsigned long addr;
 
-	if (!drm_core_check_feature(dev, DRIVER_GEM)) {
-		DRM_ERROR("does not support GEM.\n");
-		return -ENODEV;
-	}
-
 	mutex_lock(&dev->struct_mutex);
 
 	obj = drm_gem_object_lookup(dev, file_priv, args->handle);
-- 
1.8.4.2

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

* [RFC 09/12] drm/gma500: Remove dead code
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (7 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 08/12] drm/exynos: Remove dead code Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-03-11 17:07   ` Patrik Jakobsson
  2014-02-21  7:55 ` [RFC 10/12] drm/i810: " Thierry Reding
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The gma500 driver sets DRIVER_GEM unconditionally, so testing for the
absence of the feature will always fail.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/gma500/gem.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c
index d8426bc31b09..424dda95fbc6 100644
--- a/drivers/gpu/drm/gma500/gem.c
+++ b/drivers/gpu/drm/gma500/gem.c
@@ -62,9 +62,6 @@ int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
 	int ret = 0;
 	struct drm_gem_object *obj;
 
-	if (!drm_core_check_feature(dev, DRIVER_GEM))
-		return -ENODEV;
-
 	mutex_lock(&dev->struct_mutex);
 
 	/* GEM does all our handle to object mapping */
-- 
1.8.4.2

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

* [RFC 10/12] drm/i810: Remove dead code
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (8 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 09/12] drm/gma500: " Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-21  7:55 ` [RFC 11/12] drm/i915: " Thierry Reding
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The i810 driver never sets DRIVER_HAVE_IRQ, so testing for the presence
of the feature will always fail.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/i810/i810_dma.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index aeace37415aa..d12e5132c4bc 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -200,13 +200,6 @@ static int i810_dma_cleanup(struct drm_device *dev)
 {
 	struct drm_device_dma *dma = dev->dma;
 
-	/* Make sure interrupts are disabled here because the uninstall ioctl
-	 * may not have been called from userspace and after dev_private
-	 * is freed, it's too late.
-	 */
-	if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled)
-		drm_irq_uninstall(dev);
-
 	if (dev->dev_private) {
 		int i;
 		drm_i810_private_t *dev_priv =
-- 
1.8.4.2

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

* [RFC 11/12] drm/i915: Remove dead code
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (9 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 10/12] drm/i810: " Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-03-04  8:58   ` Daniel Vetter
  2014-02-21  7:55 ` [RFC 12/12] drm/qxl: " Thierry Reding
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The i915 driver sets DRIVER_GEM unconditionally, so testing for the
feature will always fail.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/i915/i915_gem_context.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index e9bba3c29ec6..da74522f377d 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -746,9 +746,6 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 	struct i915_hw_context *ctx;
 	int ret;
 
-	if (!drm_core_check_feature(dev, DRIVER_GEM))
-		return -ENODEV;
-
 	if (!HAS_HW_CONTEXTS(dev))
 		return -ENODEV;
 
@@ -775,9 +772,6 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
 	struct i915_hw_context *ctx;
 	int ret;
 
-	if (!drm_core_check_feature(dev, DRIVER_GEM))
-		return -ENODEV;
-
 	if (args->ctx_id == DEFAULT_CONTEXT_ID)
 		return -ENOENT;
 
-- 
1.8.4.2

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

* [RFC 12/12] drm/qxl: Remove dead code
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (10 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 11/12] drm/i915: " Thierry Reding
@ 2014-02-21  7:55 ` Thierry Reding
  2014-02-24 10:43 ` [RFC 00/12] Support render-node only drivers David Herrmann
  2014-03-04  8:58 ` Daniel Vetter
  13 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  7:55 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The QXL driver sets DRIVER_MODESET unconditionally, so testing for the
absence of the feature will always fail.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/qxl/qxl_kms.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index fd88eb4a3f79..eec2e983519b 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -310,10 +310,6 @@ int qxl_driver_load(struct drm_device *dev, unsigned long flags)
 	struct qxl_device *qdev;
 	int r;
 
-	/* require kms */
-	if (!drm_core_check_feature(dev, DRIVER_MODESET))
-		return -ENODEV;
-
 	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
 	if (qdev == NULL)
 		return -ENOMEM;
-- 
1.8.4.2

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

* Re: [RFC 03/12] drm/i915: Mark as legacy if KMS is disabled
  2014-02-21  7:55 ` [RFC 03/12] drm/i915: Mark as legacy if KMS is disabled Thierry Reding
@ 2014-02-21  8:17   ` Ilia Mirkin
  2014-02-21  8:28     ` Thierry Reding
  0 siblings, 1 reply; 21+ messages in thread
From: Ilia Mirkin @ 2014-02-21  8:17 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel@lists.freedesktop.org

On Fri, Feb 21, 2014 at 2:55 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> When kernel mode-setting is disabled, mark the driver as legacy to pick
> up the special semantics required for userspace mode-setting.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 2d05d7ce4c29..ea916e117f01 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -985,13 +985,19 @@ static int __init i915_init(void)
>  #if defined(CONFIG_DRM_I915_KMS)
>         if (i915.modeset != 0)
>                 driver.driver_features |= DRIVER_MODESET;
> +       else
> +               driver.driver_features |= DRIVER_LEGACY;
>  #endif
>         if (i915.modeset == 1)
>                 driver.driver_features |= DRIVER_MODESET;
> +       else
> +               driver.driver_features |= DRIVER_LEGACY;

If i915.modeset == -1 (which seems like a legal value as per the hunk
below, and I'm guessing the default), it'll end up with both MODESET
and LEGACY. Is that a legal combination?

>
>  #ifdef CONFIG_VGA_CONSOLE
> -       if (vgacon_text_force() && i915.modeset == -1)
> +       if (vgacon_text_force() && i915.modeset == -1) {
>                 driver.driver_features &= ~DRIVER_MODESET;
> +               driver.driver_features |= DRIVER_LEGACY;
> +       }
>  #endif
>
>         if (!(driver.driver_features & DRIVER_MODESET)) {
> --
> 1.8.4.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [RFC 03/12] drm/i915: Mark as legacy if KMS is disabled
  2014-02-21  8:17   ` Ilia Mirkin
@ 2014-02-21  8:28     ` Thierry Reding
  0 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-21  8:28 UTC (permalink / raw)
  To: Ilia Mirkin; +Cc: dri-devel@lists.freedesktop.org


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

On Fri, Feb 21, 2014 at 03:17:28AM -0500, Ilia Mirkin wrote:
> On Fri, Feb 21, 2014 at 2:55 AM, Thierry Reding
> <thierry.reding@gmail.com> wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > When kernel mode-setting is disabled, mark the driver as legacy to pick
> > up the special semantics required for userspace mode-setting.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> >  drivers/gpu/drm/i915/i915_drv.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> > index 2d05d7ce4c29..ea916e117f01 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.c
> > +++ b/drivers/gpu/drm/i915/i915_drv.c
> > @@ -985,13 +985,19 @@ static int __init i915_init(void)
> >  #if defined(CONFIG_DRM_I915_KMS)
> >         if (i915.modeset != 0)
> >                 driver.driver_features |= DRIVER_MODESET;
> > +       else
> > +               driver.driver_features |= DRIVER_LEGACY;
> >  #endif
> >         if (i915.modeset == 1)
> >                 driver.driver_features |= DRIVER_MODESET;
> > +       else
> > +               driver.driver_features |= DRIVER_LEGACY;
> 
> If i915.modeset == -1 (which seems like a legal value as per the hunk
> below, and I'm guessing the default), it'll end up with both MODESET
> and LEGACY. Is that a legal combination?

I don't see a reason why the combination would be illegal, but it
doesn't make a lot of sense either. So I think the above hunk should be
turned into this instead:

+	if (i915.modeset == 0)
+		driver.driver_features |= DRIVER_LEGACY;

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

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

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

* Re: [RFC 05/12] drm: Create primary minor only if mode-setting is supported
  2014-02-21  7:55 ` [RFC 05/12] drm: Create primary minor only if mode-setting is supported Thierry Reding
@ 2014-02-24 10:39   ` David Herrmann
  2014-02-25 15:36     ` Thierry Reding
  0 siblings, 1 reply; 21+ messages in thread
From: David Herrmann @ 2014-02-24 10:39 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel@lists.freedesktop.org

Hi

On Fri, Feb 21, 2014 at 8:55 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Non-legacy devices may not always support mode-setting functionality, so
> create the primary minor conditionally.
>
> One setup where this happens is the Tegra K1, where the Tegra DRM driver
> exposes the display engine via standard KMS IOCTLs, and nouveau drives
> the Kepler-type GPU that has no display capabilities.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/gpu/drm/drm_stub.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
> index fd2f1758366d..839460b774c5 100644
> --- a/drivers/gpu/drm/drm_stub.c
> +++ b/drivers/gpu/drm/drm_stub.c
> @@ -564,9 +564,11 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
>                         goto err_minors;
>         }
>
> -       ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
> -       if (ret)
> -               goto err_minors;
> +       if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> +               ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
> +               if (ret)
> +                       goto err_minors;
> +       }

There's a lot of code accessing dev->primary for debug messages (to
print stuff like "error on card0: bla"). I just want to make sure you
checked for all that. I tried renaming "->primary" to "->primary2"
locally just to find these and I doubt this is safe for most drivers.
I haven't looked for nouveau in particular, though.
Anyhow, the patch is the right thing to do.

Thanks
David

>
>         if (drm_ht_create(&dev->map_hash, 12))
>                 goto err_minors;
> --
> 1.8.4.2
>

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

* Re: [RFC 00/12] Support render-node only drivers
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (11 preceding siblings ...)
  2014-02-21  7:55 ` [RFC 12/12] drm/qxl: " Thierry Reding
@ 2014-02-24 10:43 ` David Herrmann
  2014-03-04  8:58 ` Daniel Vetter
  13 siblings, 0 replies; 21+ messages in thread
From: David Herrmann @ 2014-02-24 10:43 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel@lists.freedesktop.org

Hi

On Fri, Feb 21, 2014 at 8:55 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> This series builds on top of David's reliable DRM minor series:
>
>         [PATCH 00/13] DRM Reliable Minor-IDs
>
> Tegra K1 has a Kepler-type GPU without any display engine. Instead it
> reuses the Tegra display engine. That means that effectively the GPU
> becomes a render-node only device. In order to reflect that, it would
> be preferable for the associated /dev/dri/cardX node not to show up.
>
> To achieve that, the DRIVER_MODESET feature needs to be removed from
> the GPU driver, but that unfortunately implies activating a bunch of
> legacy behaviour for pre-KMS drivers. To allow for drivers that don't
> support modesetting IOCTLs (because they drive no output) but which
> aren't legacy either, the meaning of the DRIVER_MODESET needs to be
> redefined.
>
> This series attempts to do so by first renaming DRM_MINOR_LEGACY to
> DRM_MINOR_PRIMARY to more accurately reflect its purpose. Legacy and
> modesetting are then decoupled by introducing a DRIVER_LEGACY driver
> feature that can be set by truly legacy drivers. This allows the old
> DRIVER_MODESET feature to advertise support only for modesetting
> functionality, without implying that it is a non-legacy driver.
>
> After all the drivers have been updated, the core can be modified to
> create the primary minor only when DRIVER_MODESET is available.
>
> The remainder of the series cleans up some drm_core_check_feature()
> usage and drop some unused code related to that.

The series looks fine to me. Apart from "drm: Separate DRIVER_MODESET
and DRIVER_LEGACY" (and with Ilja's comment on 04/12):

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

Regarding the DRIVER_ flag splitting, I haven't really checked whether
you caught all places. The patch looks correct, though. I might have
some time this week for a closer look.

Thanks
David

> Thierry
>
> Thierry Reding (12):
>   drm: Rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY
>   drm: Introduce DRIVER_LEGACY feature
>   drm/i915: Mark as legacy if KMS is disabled
>   drm: Separate DRIVER_MODESET and DRIVER_LEGACY
>   drm: Create primary minor only if mode-setting is supported
>   drm: Remove gratuituous blank line
>   drm: Use drm_core_check_feature() where possible
>   drm/exynos: Remove dead code
>   drm/gma500: Remove dead code
>   drm/i810: Remove dead code
>   drm/i915: Remove dead code
>   drm/qxl: Remove dead code
>
>  drivers/gpu/drm/drm_bufs.c              | 12 +++++------
>  drivers/gpu/drm/drm_crtc.c              |  1 -
>  drivers/gpu/drm/drm_dma.c               |  4 ++--
>  drivers/gpu/drm/drm_fops.c              | 14 ++++++------
>  drivers/gpu/drm/drm_gem.c               |  6 +++---
>  drivers/gpu/drm/drm_irq.c               | 12 +++++------
>  drivers/gpu/drm/drm_pci.c               | 12 +++++------
>  drivers/gpu/drm/drm_scatter.c           |  6 +++---
>  drivers/gpu/drm/drm_stub.c              | 24 +++++++++++----------
>  drivers/gpu/drm/drm_sysfs.c             |  8 +++----
>  drivers/gpu/drm/exynos/exynos_drm_gem.c | 10 ---------
>  drivers/gpu/drm/gma500/gem.c            |  3 ---
>  drivers/gpu/drm/i810/i810_dma.c         |  7 ------
>  drivers/gpu/drm/i810/i810_drv.c         |  3 ++-
>  drivers/gpu/drm/i915/i915_dma.c         | 38 ++++++++++++++++-----------------
>  drivers/gpu/drm/i915/i915_drv.c         | 18 ++++++++++------
>  drivers/gpu/drm/i915/i915_gem.c         | 17 +++++++--------
>  drivers/gpu/drm/i915/i915_gem_context.c |  6 ------
>  drivers/gpu/drm/i915/i915_irq.c         |  6 +++---
>  drivers/gpu/drm/i915/i915_suspend.c     | 15 ++++++-------
>  drivers/gpu/drm/i915/intel_ringbuffer.c |  2 +-
>  drivers/gpu/drm/mga/mga_drv.c           |  3 ++-
>  drivers/gpu/drm/qxl/qxl_kms.c           |  4 ----
>  drivers/gpu/drm/radeon/radeon_drv.c     |  3 ++-
>  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                      |  3 ++-
>  29 files changed, 112 insertions(+), 132 deletions(-)
>
> --
> 1.8.4.2
>

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

* Re: [RFC 05/12] drm: Create primary minor only if mode-setting is supported
  2014-02-24 10:39   ` David Herrmann
@ 2014-02-25 15:36     ` Thierry Reding
  0 siblings, 0 replies; 21+ messages in thread
From: Thierry Reding @ 2014-02-25 15:36 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Mon, Feb 24, 2014 at 11:39:33AM +0100, David Herrmann wrote:
> Hi
> 
> On Fri, Feb 21, 2014 at 8:55 AM, Thierry Reding
> <thierry.reding@gmail.com> wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > Non-legacy devices may not always support mode-setting functionality, so
> > create the primary minor conditionally.
> >
> > One setup where this happens is the Tegra K1, where the Tegra DRM driver
> > exposes the display engine via standard KMS IOCTLs, and nouveau drives
> > the Kepler-type GPU that has no display capabilities.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> >  drivers/gpu/drm/drm_stub.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
> > index fd2f1758366d..839460b774c5 100644
> > --- a/drivers/gpu/drm/drm_stub.c
> > +++ b/drivers/gpu/drm/drm_stub.c
> > @@ -564,9 +564,11 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
> >                         goto err_minors;
> >         }
> >
> > -       ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
> > -       if (ret)
> > -               goto err_minors;
> > +       if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > +               ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
> > +               if (ret)
> > +                       goto err_minors;
> > +       }
> 
> There's a lot of code accessing dev->primary for debug messages (to
> print stuff like "error on card0: bla"). I just want to make sure you
> checked for all that. I tried renaming "->primary" to "->primary2"
> locally just to find these and I doubt this is safe for most drivers.
> I haven't looked for nouveau in particular, though.
> Anyhow, the patch is the right thing to do.

I've looked into this a little more to find out where the drm_device's
.primary field is used, with the following results:

1) DRM core:
   - drm_bufs.c: Used in drm_find_matching_map() and drm_addmap_core().
     This code is exclusively used by drivers that advertise the LEGACY
     feature as far as I can tell. So these would be candidates where
     not allocating the primary minor will cause problems. But I don't
     understanding of the legacy code paths well enough to propose a
     solution that could be applied here.

   - drm_fb_helper.c: This is only used by drivers advertising the
     MODESET feature, so shouldn't be an issue.

   - drm_stub.c: All accesses to the primary minor are protected by a
     check for the MODESET feature.

   - drm_sysfs.c: Used primarily for hotplug events, which from what I
     can tell are MODESET only.

     One oddity here is the __drm_class_suspend() function, which checks
     for:

        46		if (drm_minor->type == DRM_MINOR_PRIMARY &&
        47		    drm_core_check_feature(drm_dev, DRIVER_LEGACY) &&
        48		    drm_dev->driver->suspend)

     Which is somewhat confusing to me. drm_class_resume() performs the
     same check.

2) DRM drivers:
   - armada, ast, bochs, cirrus, exynos, i810, imx-drm, mga, mgag200, msm,
     nouveau, omapdrm, r128, rcar-du, savage, shmobile, sis, tdfx, tildc,
     udl, via and vmwgfx don't use the primary directly at all.

   - i915:
     - i915_dma.c and i915_irq.c protect all accesses to the primary
       minor with LEGACY feature checks
     - intel_display.c: uses it for SAREA code, but I think that's
       scheduled to be removed (I do remember some discussion about this
       on IRC not so long ago). Adding Daniel on Cc, maybe he knows more
       about this.
     - intel_ringbuffer.c: This seems to be SAREA related as well.
     - i915_sysfs.c: sysfs code is used by both legacy and non-legacy
       drivers, so this could be problematic.

   - qxl: Uses the primary minor for debugfs support, but the driver is
     unconditonally MODESET so it shouldn't be an issue.

   - radeon: Uses the primary minor for debugfs support but all paths
     that initialize debugfs support are conditionally MODESET.

   - tegra: Uses the primary minor for debugfs support, but the driver
     is unconditionally MODESET so it shouldn't be an issue.

One pretty common pattern, even though it shouldn't be problematic, is
how drivers use the primary minor for debugfs support. That means that
if the primary minor weren't registered, there'd be no place for these
drivers to put their debugfs files. In all the above cases, the driver
uses debugfs only for things that are modesetting related, so I guess
there isn't an immediate problem.

Interestingly nouveau seems to side-step this issue entirely by simply
setting up debugfs for every minor. For other drivers it seems like the
solution wouldn't be as easy, since there are many more files in debugfs
and they can come from subdevices as well.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

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

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

* Re: [RFC 00/12] Support render-node only drivers
  2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
                   ` (12 preceding siblings ...)
  2014-02-24 10:43 ` [RFC 00/12] Support render-node only drivers David Herrmann
@ 2014-03-04  8:58 ` Daniel Vetter
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2014-03-04  8:58 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel

On Fri, Feb 21, 2014 at 08:55:16AM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> This series builds on top of David's reliable DRM minor series:
> 
> 	[PATCH 00/13] DRM Reliable Minor-IDs
> 
> Tegra K1 has a Kepler-type GPU without any display engine. Instead it
> reuses the Tegra display engine. That means that effectively the GPU
> becomes a render-node only device. In order to reflect that, it would
> be preferable for the associated /dev/dri/cardX node not to show up.

Why would it be preferable exactly?

- There's not really a security risk if we have it around as long as you
  sufficiently lock down access rights to it.

- Older userspace would still need the legacy node for e.g. X prime
  support using just dri2.

i915 (and iirc also radeon) can run on hw without any outputs, and simply
not registering any crtcs or other modeset objects is all that's needed
really. Of course userspace could still create kms framebuffer objects,
but those don't really hurt anyone.

> To achieve that, the DRIVER_MODESET feature needs to be removed from
> the GPU driver, but that unfortunately implies activating a bunch of
> legacy behaviour for pre-KMS drivers. To allow for drivers that don't
> support modesetting IOCTLs (because they drive no output) but which
> aren't legacy either, the meaning of the DRIVER_MODESET needs to be
> redefined.
> 
> This series attempts to do so by first renaming DRM_MINOR_LEGACY to
> DRM_MINOR_PRIMARY to more accurately reflect its purpose. Legacy and
> modesetting are then decoupled by introducing a DRIVER_LEGACY driver
> feature that can be set by truly legacy drivers. This allows the old
> DRIVER_MODESET feature to advertise support only for modesetting
> functionality, without implying that it is a non-legacy driver.

I haven't done a full review but the crux with a catch-all DRIVER_LEGACY
is that there's shocking amounts of userspace out there which require a
shocking mix of modeset ioctls and legacy ioctls. At least I've burned my
fingers a few times already trying to sort this stuff out and patches had
to be reverted ...

Cheers, Daniel

> After all the drivers have been updated, the core can be modified to
> create the primary minor only when DRIVER_MODESET is available.
> 
> The remainder of the series cleans up some drm_core_check_feature()
> usage and drop some unused code related to that.
> 
> Thierry
> 
> Thierry Reding (12):
>   drm: Rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY
>   drm: Introduce DRIVER_LEGACY feature
>   drm/i915: Mark as legacy if KMS is disabled
>   drm: Separate DRIVER_MODESET and DRIVER_LEGACY
>   drm: Create primary minor only if mode-setting is supported
>   drm: Remove gratuituous blank line
>   drm: Use drm_core_check_feature() where possible
>   drm/exynos: Remove dead code
>   drm/gma500: Remove dead code
>   drm/i810: Remove dead code
>   drm/i915: Remove dead code
>   drm/qxl: Remove dead code
> 
>  drivers/gpu/drm/drm_bufs.c              | 12 +++++------
>  drivers/gpu/drm/drm_crtc.c              |  1 -
>  drivers/gpu/drm/drm_dma.c               |  4 ++--
>  drivers/gpu/drm/drm_fops.c              | 14 ++++++------
>  drivers/gpu/drm/drm_gem.c               |  6 +++---
>  drivers/gpu/drm/drm_irq.c               | 12 +++++------
>  drivers/gpu/drm/drm_pci.c               | 12 +++++------
>  drivers/gpu/drm/drm_scatter.c           |  6 +++---
>  drivers/gpu/drm/drm_stub.c              | 24 +++++++++++----------
>  drivers/gpu/drm/drm_sysfs.c             |  8 +++----
>  drivers/gpu/drm/exynos/exynos_drm_gem.c | 10 ---------
>  drivers/gpu/drm/gma500/gem.c            |  3 ---
>  drivers/gpu/drm/i810/i810_dma.c         |  7 ------
>  drivers/gpu/drm/i810/i810_drv.c         |  3 ++-
>  drivers/gpu/drm/i915/i915_dma.c         | 38 ++++++++++++++++-----------------
>  drivers/gpu/drm/i915/i915_drv.c         | 18 ++++++++++------
>  drivers/gpu/drm/i915/i915_gem.c         | 17 +++++++--------
>  drivers/gpu/drm/i915/i915_gem_context.c |  6 ------
>  drivers/gpu/drm/i915/i915_irq.c         |  6 +++---
>  drivers/gpu/drm/i915/i915_suspend.c     | 15 ++++++-------
>  drivers/gpu/drm/i915/intel_ringbuffer.c |  2 +-
>  drivers/gpu/drm/mga/mga_drv.c           |  3 ++-
>  drivers/gpu/drm/qxl/qxl_kms.c           |  4 ----
>  drivers/gpu/drm/radeon/radeon_drv.c     |  3 ++-
>  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                      |  3 ++-
>  29 files changed, 112 insertions(+), 132 deletions(-)
> 
> -- 
> 1.8.4.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* Re: [RFC 11/12] drm/i915: Remove dead code
  2014-02-21  7:55 ` [RFC 11/12] drm/i915: " Thierry Reding
@ 2014-03-04  8:58   ` Daniel Vetter
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2014-03-04  8:58 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel

On Fri, Feb 21, 2014 at 08:55:27AM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> The i915 driver sets DRIVER_GEM unconditionally, so testing for the
> feature will always fail.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Queued for -next, thanks for the patch.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_gem_context.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index e9bba3c29ec6..da74522f377d 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -746,9 +746,6 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
>  	struct i915_hw_context *ctx;
>  	int ret;
>  
> -	if (!drm_core_check_feature(dev, DRIVER_GEM))
> -		return -ENODEV;
> -
>  	if (!HAS_HW_CONTEXTS(dev))
>  		return -ENODEV;
>  
> @@ -775,9 +772,6 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
>  	struct i915_hw_context *ctx;
>  	int ret;
>  
> -	if (!drm_core_check_feature(dev, DRIVER_GEM))
> -		return -ENODEV;
> -
>  	if (args->ctx_id == DEFAULT_CONTEXT_ID)
>  		return -ENOENT;
>  
> -- 
> 1.8.4.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* Re: [RFC 09/12] drm/gma500: Remove dead code
  2014-02-21  7:55 ` [RFC 09/12] drm/gma500: " Thierry Reding
@ 2014-03-11 17:07   ` Patrik Jakobsson
  0 siblings, 0 replies; 21+ messages in thread
From: Patrik Jakobsson @ 2014-03-11 17:07 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel

On Fri, Feb 21, 2014 at 8:55 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> The gma500 driver sets DRIVER_GEM unconditionally, so testing for the
> absence of the feature will always fail.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Queued for -next

Thanks
Patrik

> ---
>  drivers/gpu/drm/gma500/gem.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c
> index d8426bc31b09..424dda95fbc6 100644
> --- a/drivers/gpu/drm/gma500/gem.c
> +++ b/drivers/gpu/drm/gma500/gem.c
> @@ -62,9 +62,6 @@ int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
>         int ret = 0;
>         struct drm_gem_object *obj;
>
> -       if (!drm_core_check_feature(dev, DRIVER_GEM))
> -               return -ENODEV;
> -
>         mutex_lock(&dev->struct_mutex);
>
>         /* GEM does all our handle to object mapping */
> --
> 1.8.4.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2014-03-11 17:07 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-21  7:55 [RFC 00/12] Support render-node only drivers Thierry Reding
2014-02-21  7:55 ` [RFC 01/12] drm: Rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY Thierry Reding
2014-02-21  7:55 ` [RFC 02/12] drm: Introduce DRIVER_LEGACY feature Thierry Reding
2014-02-21  7:55 ` [RFC 03/12] drm/i915: Mark as legacy if KMS is disabled Thierry Reding
2014-02-21  8:17   ` Ilia Mirkin
2014-02-21  8:28     ` Thierry Reding
2014-02-21  7:55 ` [RFC 04/12] drm: Separate DRIVER_MODESET and DRIVER_LEGACY Thierry Reding
2014-02-21  7:55 ` [RFC 05/12] drm: Create primary minor only if mode-setting is supported Thierry Reding
2014-02-24 10:39   ` David Herrmann
2014-02-25 15:36     ` Thierry Reding
2014-02-21  7:55 ` [RFC 06/12] drm: Remove gratuituous blank line Thierry Reding
2014-02-21  7:55 ` [RFC 07/12] drm: Use drm_core_check_feature() where possible Thierry Reding
2014-02-21  7:55 ` [RFC 08/12] drm/exynos: Remove dead code Thierry Reding
2014-02-21  7:55 ` [RFC 09/12] drm/gma500: " Thierry Reding
2014-03-11 17:07   ` Patrik Jakobsson
2014-02-21  7:55 ` [RFC 10/12] drm/i810: " Thierry Reding
2014-02-21  7:55 ` [RFC 11/12] drm/i915: " Thierry Reding
2014-03-04  8:58   ` Daniel Vetter
2014-02-21  7:55 ` [RFC 12/12] drm/qxl: " Thierry Reding
2014-02-24 10:43 ` [RFC 00/12] Support render-node only drivers David Herrmann
2014-03-04  8:58 ` Daniel Vetter

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