[RFC 04/12] drm: Separate DRIVER_MODESET and DRIVER_LEGACY

Thierry Reding thierry.reding at gmail.com
Thu Feb 20 23:55:20 PST 2014


From: Thierry Reding <treding at 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 at 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



More information about the dri-devel mailing list