drm: Used DRM_LEGACY for all legacy functions
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 3 Aug 2016 19:11:10 +0000 (21:11 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 8 Aug 2016 08:05:23 +0000 (10:05 +0200)
Except for nouveau, only legacy drivers need this really. And nouveau
is already marked up with DRIVER_KMS_LEGACY_CONTEXT as the special
case.

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

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1470251470-30830-2-git-send-email-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_agpsupport.c
drivers/gpu/drm/drm_auth.c
drivers/gpu/drm/drm_bufs.c
drivers/gpu/drm/drm_context.c
drivers/gpu/drm/drm_dma.c
drivers/gpu/drm/drm_fops.c
drivers/gpu/drm/drm_ioctl.c
drivers/gpu/drm/drm_irq.c
drivers/gpu/drm/drm_lock.c
drivers/gpu/drm/drm_pci.c
drivers/gpu/drm/drm_scatter.c

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