diff mbox series

[05/12] drm/legacy: move lock cleanup for master into lock file

Message ID 20190423020041.32702-6-airlied@gmail.com (mailing list archive)
State New, archived
Headers show
Series [01/12] drm/nouveau: add kconfig option to turn off nouveau legacy contexts. (v2) | expand

Commit Message

Dave Airlie April 23, 2019, 2 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

This makes it easier to remove legacy code later.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_auth.c   | 14 +-------------
 drivers/gpu/drm/drm_legacy.h |  1 +
 drivers/gpu/drm/drm_lock.c   | 16 ++++++++++++++++
 3 files changed, 18 insertions(+), 13 deletions(-)

Comments

Daniel Vetter April 23, 2019, 6:44 p.m. UTC | #1
On Tue, Apr 23, 2019 at 12:00:34PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This makes it easier to remove legacy code later.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_auth.c   | 14 +-------------
>  drivers/gpu/drm/drm_legacy.h |  1 +
>  drivers/gpu/drm/drm_lock.c   | 16 ++++++++++++++++
>  3 files changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
> index 1669c42c40ed..ef8c4353829b 100644
> --- a/drivers/gpu/drm/drm_auth.c
> +++ b/drivers/gpu/drm/drm_auth.c
> @@ -275,19 +275,7 @@ void drm_master_release(struct drm_file *file_priv)
>  		goto out;
>  
>  	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {

Bikeshed (aka feel free to ignore): I'd also move the DRIVER_LEGACY check
into the helper, the drm_legacy_ function prefix is kinda clear enough.

Also, drop the {} to appease checkpatch.

Whatever, I like so Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> -		/*
> -		 * 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)
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 3dc626090fcb..974c2be6bcd5 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -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__ */
> diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
> index 67a1a2ca7174..b37874a15e23 100644
> --- a/drivers/gpu/drm/drm_lock.c
> +++ b/drivers/gpu/drm/drm_lock.c
> @@ -347,3 +347,19 @@ 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)
> +{
> +	/*
> +	 * 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);
> +}
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 1669c42c40ed..ef8c4353829b 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -275,19 +275,7 @@  void drm_master_release(struct drm_file *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)
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 3dc626090fcb..974c2be6bcd5 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -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__ */
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index 67a1a2ca7174..b37874a15e23 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -347,3 +347,19 @@  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)
+{
+	/*
+	 * 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);
+}