drm/legacy: move lock cleanup for master into lock file (v2)
authorDave Airlie <airlied@redhat.com>
Mon, 22 Apr 2019 23:36:54 +0000 (09:36 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 24 Apr 2019 02:32:15 +0000 (12:32 +1000)
This makes it easier to remove legacy code later.

v2: move check into lock file as well.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_auth.c
drivers/gpu/drm/drm_legacy.h
drivers/gpu/drm/drm_lock.c

index 1669c42c40ed3537cb9240de83a1128e38b816c5..ee969e9de47231668fe2c8d9fb4274c8ff56f261 100644 (file)
@@ -274,21 +274,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_LEGACY)) {
-               /*
-                * Since the master is disappearing, so is the
-                * possibility to lock.
-                */
-               mutex_lock(&dev->struct_mutex);
-               if (master->lock.hw_lock) {
-                       if (dev->sigdata.lock == master->lock.hw_lock)
-                               dev->sigdata.lock = NULL;
-                       master->lock.hw_lock = NULL;
-                       master->lock.file_priv = NULL;
-                       wake_up_interruptible_all(&master->lock.lock_queue);
-               }
-               mutex_unlock(&dev->struct_mutex);
-       }
+       drm_legacy_lock_master_cleanup(dev, master);
 
        if (dev->master == file_priv->master)
                drm_drop_master(dev, file_priv);
index 3dc626090fcbe4fdc7ba7230302a6685c9c09b15..974c2be6bcd57e4367cb74da45f9f98fb55eb088 100644 (file)
@@ -126,4 +126,5 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 int drm_legacy_sg_free(struct drm_device *dev, void *data,
                       struct drm_file *file_priv);
 
+void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
 #endif /* __DRM_LEGACY_H__ */
index 67a1a2ca717457ff01b42a0e8114c3f9d531e8da..b70058e77a284d8146b42d4325706b896a6c34d0 100644 (file)
@@ -347,3 +347,22 @@ void drm_legacy_lock_release(struct drm_device *dev, struct file *filp)
                                     _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
        }
 }
+
+void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master)
+{
+       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
+               return;
+
+       /*
+        * Since the master is disappearing, so is the
+        * possibility to lock.
+        */     mutex_lock(&dev->struct_mutex);
+       if (master->lock.hw_lock) {
+               if (dev->sigdata.lock == master->lock.hw_lock)
+                       dev->sigdata.lock = NULL;
+               master->lock.hw_lock = NULL;
+               master->lock.file_priv = NULL;
+               wake_up_interruptible_all(&master->lock.lock_queue);
+       }
+       mutex_unlock(&dev->struct_mutex);
+}