]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/radeon: Use rdev->gem.mutex to protect hyperz/cmask owners
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 15 Oct 2015 07:36:34 +0000 (09:36 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 15 Oct 2015 14:22:52 +0000 (10:22 -0400)
This removes the last depency of radeon for dev->struct_mutex!

Also the locking scheme for hyperz/cmask owners seems a bit unsound,
there's no protection in the preclose handler (and that never did hold
dev->struct_mutex while being called). So grab the same lock there,
too.

There's also all the checks in the cs checker, but since the overall
design seems to never stall for the previous owner I figured it's ok
if I leave this racy. It was racy even before I touched it after all
too.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_kms.c

index 977f1a5e11a52c90fb9f044a5b8a7e9266f642f4..0a68e8d711a1aa8de476a01ec3af1661be86492d 100644 (file)
@@ -181,7 +181,9 @@ static void radeon_set_filp_rights(struct drm_device *dev,
                                   struct drm_file *applier,
                                   uint32_t *value)
 {
-       mutex_lock(&dev->struct_mutex);
+       struct radeon_device *rdev = dev->dev_private;
+
+       mutex_lock(&rdev->gem.mutex);
        if (*value == 1) {
                /* wants rights */
                if (!*owner)
@@ -192,7 +194,7 @@ static void radeon_set_filp_rights(struct drm_device *dev,
                        *owner = NULL;
        }
        *value = *owner == applier ? 1 : 0;
-       mutex_unlock(&dev->struct_mutex);
+       mutex_unlock(&rdev->gem.mutex);
 }
 
 /*
@@ -724,10 +726,14 @@ void radeon_driver_preclose_kms(struct drm_device *dev,
                                struct drm_file *file_priv)
 {
        struct radeon_device *rdev = dev->dev_private;
+
+       mutex_lock(&rdev->gem.mutex);
        if (rdev->hyperz_filp == file_priv)
                rdev->hyperz_filp = NULL;
        if (rdev->cmask_filp == file_priv)
                rdev->cmask_filp = NULL;
+       mutex_unlock(&rdev->gem.mutex);
+
        radeon_uvd_free_handles(rdev, file_priv);
        radeon_vce_free_handles(rdev, file_priv);
 }