diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2025-03-14 09:29:59 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2025-03-19 15:56:04 -0400 |
commit | 9e34d8d1a1abe693a77f8a1083e4ab97ca0362a0 (patch) | |
tree | 5d2b7d81766db8390718a8048e184c705a4e0f89 /drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | |
parent | 5762f9dcf74ae5fb0b0a15afeda9543af38449ef (diff) | |
download | linux-9e34d8d1a1abe693a77f8a1083e4ab97ca0362a0.tar.gz linux-9e34d8d1a1abe693a77f8a1083e4ab97ca0362a0.tar.bz2 linux-9e34d8d1a1abe693a77f8a1083e4ab97ca0362a0.zip |
drm/amdgpu/gfx: adjust workload profile handling
No need to make the workload profile setup dependent
on the results of cancelling the delayed work thread.
We have all of the necessary checking in place for the
workload profile reference counting, so separate the
two. As it is now, we can theoretically end up with
the call from begin_use happening while the worker
thread is executing which would result in the profile
not getting set for that submission. It should not
affect the reference counting.
v2: bail early if the the profile is already active (Lijo)
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c index 099329d15b9f..4beb0609e703 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c @@ -2188,18 +2188,25 @@ void amdgpu_gfx_profile_ring_begin_use(struct amdgpu_ring *ring) atomic_inc(&adev->gfx.total_submission_cnt); - if (!cancel_delayed_work_sync(&adev->gfx.idle_work)) { - mutex_lock(&adev->gfx.workload_profile_mutex); - if (!adev->gfx.workload_profile_active) { - 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, - profile == PP_SMC_POWER_PROFILE_FULLSCREEN3D ? - "fullscreen 3D" : "compute"); - adev->gfx.workload_profile_active = true; - } - mutex_unlock(&adev->gfx.workload_profile_mutex); + cancel_delayed_work_sync(&adev->gfx.idle_work); + + /* We can safely return early here because we've cancelled the + * 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) { + 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, + profile == PP_SMC_POWER_PROFILE_FULLSCREEN3D ? + "fullscreen 3D" : "compute"); + adev->gfx.workload_profile_active = true; } + mutex_unlock(&adev->gfx.workload_profile_mutex); } void amdgpu_gfx_profile_ring_end_use(struct amdgpu_ring *ring) |