Commit e95a14a9 authored by Tom St Denis's avatar Tom St Denis Committed by Alex Deucher

drm/amd/amdgpu: add mutex locking for both DPM and PP based powergating for UVD/VCE

This adds a mutex lock for both DPM/PP around the changes in
power gating state so that userspace can poll registers without
a race condition on power state.
Signed-off-by: default avatarTom St Denis <tom.stdenis@amd.com>
Reviewed-by: default avatarRex Zhu <Rex.Zhu@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 70bb2461
...@@ -1106,54 +1106,46 @@ static void amdgpu_dpm_change_power_state_locked(struct amdgpu_device *adev) ...@@ -1106,54 +1106,46 @@ static void amdgpu_dpm_change_power_state_locked(struct amdgpu_device *adev)
void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable) void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable)
{ {
if (adev->pp_enabled) if (adev->pp_enabled || adev->pm.funcs->powergate_uvd) {
/* enable/disable UVD */
mutex_lock(&adev->pm.mutex);
amdgpu_dpm_powergate_uvd(adev, !enable); amdgpu_dpm_powergate_uvd(adev, !enable);
else { mutex_unlock(&adev->pm.mutex);
if (adev->pm.funcs->powergate_uvd) { } else {
if (enable) {
mutex_lock(&adev->pm.mutex); mutex_lock(&adev->pm.mutex);
/* enable/disable UVD */ adev->pm.dpm.uvd_active = true;
amdgpu_dpm_powergate_uvd(adev, !enable); adev->pm.dpm.state = POWER_STATE_TYPE_INTERNAL_UVD;
mutex_unlock(&adev->pm.mutex); mutex_unlock(&adev->pm.mutex);
} else { } else {
if (enable) { mutex_lock(&adev->pm.mutex);
mutex_lock(&adev->pm.mutex); adev->pm.dpm.uvd_active = false;
adev->pm.dpm.uvd_active = true; mutex_unlock(&adev->pm.mutex);
adev->pm.dpm.state = POWER_STATE_TYPE_INTERNAL_UVD;
mutex_unlock(&adev->pm.mutex);
} else {
mutex_lock(&adev->pm.mutex);
adev->pm.dpm.uvd_active = false;
mutex_unlock(&adev->pm.mutex);
}
amdgpu_pm_compute_clocks(adev);
} }
amdgpu_pm_compute_clocks(adev);
} }
} }
void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable) void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)
{ {
if (adev->pp_enabled) if (adev->pp_enabled || adev->pm.funcs->powergate_vce) {
/* enable/disable VCE */
mutex_lock(&adev->pm.mutex);
amdgpu_dpm_powergate_vce(adev, !enable); amdgpu_dpm_powergate_vce(adev, !enable);
else { mutex_unlock(&adev->pm.mutex);
if (adev->pm.funcs->powergate_vce) { } else {
if (enable) {
mutex_lock(&adev->pm.mutex); mutex_lock(&adev->pm.mutex);
amdgpu_dpm_powergate_vce(adev, !enable); adev->pm.dpm.vce_active = true;
/* XXX select vce level based on ring/task */
adev->pm.dpm.vce_level = AMDGPU_VCE_LEVEL_AC_ALL;
mutex_unlock(&adev->pm.mutex); mutex_unlock(&adev->pm.mutex);
} else { } else {
if (enable) { mutex_lock(&adev->pm.mutex);
mutex_lock(&adev->pm.mutex); adev->pm.dpm.vce_active = false;
adev->pm.dpm.vce_active = true; mutex_unlock(&adev->pm.mutex);
/* XXX select vce level based on ring/task */
adev->pm.dpm.vce_level = AMDGPU_VCE_LEVEL_AC_ALL;
mutex_unlock(&adev->pm.mutex);
} else {
mutex_lock(&adev->pm.mutex);
adev->pm.dpm.vce_active = false;
mutex_unlock(&adev->pm.mutex);
}
amdgpu_pm_compute_clocks(adev);
} }
amdgpu_pm_compute_clocks(adev);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment