]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu/jpeg: Hold pg_lock before jpeg poweroff
authorSathishkumar S <sathishkumar.sundararaju@amd.com>
Tue, 5 Aug 2025 15:58:25 +0000 (21:28 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:10 +0000 (15:34 -0500)
[ Upstream commit 0e7581eda8c76d1ca4cf519631a4d4eb9f82b94c ]

Acquire jpeg_pg_lock before changes to jpeg power state
and release it after power off from idle work handler.

Signed-off-by: Sathishkumar S <sathishkumar.sundararaju@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c

index 6df99cb00d9a54d3b6e762b8e3058257208a1204..f96a79a4d53970f1418d737a0a68dad6df820b10 100644 (file)
@@ -117,10 +117,12 @@ static void amdgpu_jpeg_idle_work_handler(struct work_struct *work)
                        fences += amdgpu_fence_count_emitted(&adev->jpeg.inst[i].ring_dec[j]);
        }
 
-       if (!fences && !atomic_read(&adev->jpeg.total_submission_cnt))
+       if (!fences && !atomic_read(&adev->jpeg.total_submission_cnt)) {
+               mutex_lock(&adev->jpeg.jpeg_pg_lock);
                amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_JPEG,
                                                       AMD_PG_STATE_GATE);
-       else
+               mutex_unlock(&adev->jpeg.jpeg_pg_lock);
+       } else
                schedule_delayed_work(&adev->jpeg.idle_work, JPEG_IDLE_TIMEOUT);
 }