drm/amd/powerplay: fix deadlock on setting power_dpm_force_performance_level
Subsystems (2)
PATCH 1/1 drm/amd/powerplay: fix deadlock on setting power_dpm_force_performance_level
smu_enable_umd_pstate() will try to get the smu->mutex which was already hold by its parent API smu_force_performance_level() on the call path. Thus deadlock happens.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +14 -5
@@ -383,14 +383,25 @@ bool smu_clk_dpm_is_enabled(struct smu_context *smu, enum smu_clk_type clk_type)return true; } - +/** +* smu_dpm_set_power_gate - power gate/ungate the specific IP block +* +* @smu: smu_context pointer +* @block_type: the IP block to power gate/ungate +* @gate: to power gate if true, ungate otherwise +* +* This API uses no smu->mutex lock protection due to: +* 1. It is either called by other IP block(gfx/sdma/vcn/uvd/vce). +* This is guarded to be race condition free by the caller. +* 2. Or get called on user setting request of power_dpm_force_performance_level. +* Under this case, the smu->mutex lock protection is already enforced on +* the parent API smu_force_performance_level of the call path. +*/ int smu_dpm_set_power_gate (struct smu_context *smu,uint32_t block_type,bool gate) {int ret =0 ; -mutex_lock (&smu->mutex); -switch (block_type) {case AMD_IP_BLOCK_TYPE_UVD : ret =smu_dpm_set_uvd_enable (smu, gate);
@@ -408,8 +419,6 @@ int smu_dpm_set_power_gate(struct smu_context *smu, uint32_t block_type,break ; } -mutex_unlock (&smu->mutex); -return ret; }
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Xu, Feifei
Reviewed-by Feifei Xu-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Quan, Evan
Sent: Wednesday, November 6, 2019 2:57 PM
To: [email protected]
Cc: Quan, Evan <[email protected]>
Subject: [PATCH] drm/amd/powerplay: fix deadlock on setting power_dpm_force_performance_level
smu_enable_umd_pstate() will try to get the smu->mutex which was already hold by its parent API smu_force_performance_level() on the call path. Thus deadlock happens.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +14 -3
@@ -383,14 +383,25 @@ bool smu_clk_dpm_is_enabled(struct smu_context *smu, enum smu_clk_type clk_type)return true; } - +/** +* smu_dpm_set_power_gate - power gate/ungate the specific IP block +* +* @smu: smu_context pointer +* @block_type: the IP block to power gate/ungate +* @gate: to power gate if true, ungate otherwise +* +* This API uses no smu->mutex lock protection due to: +* 1. It is either called by other IP block(gfx/sdma/vcn/uvd/vce). +* This is guarded to be race condition free by the caller. +* 2. Or get called on user setting request of power_dpm_force_performance_level. +* Under this case, the smu->mutex lock protection is already enforced on +* the parent API smu_force_performance_level of the call path. +*/ int smu_dpm_set_power_gate (struct smu_context *smu,uint32_t block_type,bool gate) {int ret =0 ; -mutex_lock (&smu->mutex); -switch (block_type) {case AMD_IP_BLOCK_TYPE_UVD : ret = smu_dpm_set_uvd_enable(smu, gate); @@ -408,8 +419,6 @@ int smu_dpm_set_power_gate(struct smu_context *smu, uint32_t block_type,
break;
}
- mutex_unlock(&smu->mutex);
-
return ret;
}
--
2.23.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx