the gfx driver need to hold lock (adev->gfx.workload_profile_mutex) before
access "adev->gfx.workload_profile_active" varible.

Fixes: 9e34d8d1a1abe ("drm/amdgpu/gfx: adjust workload profile handling")

Signed-off-by: Yang Wang <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 7f02e36ccc1e..59329e8ffb86 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -2249,11 +2249,10 @@ void amdgpu_gfx_profile_ring_begin_use(struct 
amdgpu_ring *ring)
         * the delayed work so there is no one else to set it to false
         * and we don't care if someone else sets it to true.
         */
-       if (adev->gfx.workload_profile_active)
-               return;
-
        mutex_lock(&adev->gfx.workload_profile_mutex);
-       if (!adev->gfx.workload_profile_active) {
+       if (adev->gfx.workload_profile_active) {
+               goto out_unlock;
+       } else {
                r = amdgpu_dpm_switch_power_profile(adev, profile, true);
                if (r)
                        dev_warn(adev->dev, "(%d) failed to disable %s power 
profile mode\n", r,
@@ -2261,6 +2260,8 @@ void amdgpu_gfx_profile_ring_begin_use(struct amdgpu_ring 
*ring)
                                 "fullscreen 3D" : "compute");
                adev->gfx.workload_profile_active = true;
        }
+
+out_unlock:
        mutex_unlock(&adev->gfx.workload_profile_mutex);
 }
 
-- 
2.34.1

Reply via email to