Commit 9d7a348d authored by Guchun Chen's avatar Guchun Chen Committed by Alex Deucher

drm/amd/pm: parse pp_handle under appropriate conditions

amdgpu_dpm_is_overdrive_supported is a common API across all
asics, so we should cast pp_handle into correct structure
under different power frameworks.

v2: using return directly to simplify code
v3: SI asic does not carry od_enabled member in pp_handle, and update Fixes tag

Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2541
Fixes: eb4900aa ("drm/amdgpu: Fix kernel NULL pointer dereference in dpm functions")
Suggested-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarGuchun Chen <guchun.chen@amd.com>
Reviewed-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 187916e6
...@@ -1460,15 +1460,21 @@ int amdgpu_dpm_get_smu_prv_buf_details(struct amdgpu_device *adev, ...@@ -1460,15 +1460,21 @@ int amdgpu_dpm_get_smu_prv_buf_details(struct amdgpu_device *adev,
int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev) int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev)
{ {
struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; if (is_support_sw_smu(adev)) {
struct smu_context *smu = adev->powerplay.pp_handle; struct smu_context *smu = adev->powerplay.pp_handle;
return (smu->od_enabled || smu->is_apu);
} else {
struct pp_hwmgr *hwmgr;
if ((is_support_sw_smu(adev) && smu->od_enabled) || /* SI asic does not carry od_enabled */
(is_support_sw_smu(adev) && smu->is_apu) || if (adev->family == AMDGPU_FAMILY_SI)
(!is_support_sw_smu(adev) && hwmgr->od_enabled)) return false;
return true;
return false; hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;
return hwmgr->od_enabled;
}
} }
int amdgpu_dpm_set_pp_table(struct amdgpu_device *adev, int amdgpu_dpm_set_pp_table(struct amdgpu_device *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