Skip to content

Commit 58d9b9a

Browse files
Guchun Chenalexdeucher
authored andcommitted
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: eb4900a ("drm/amdgpu: Fix kernel NULL pointer dereference in dpm functions") Suggested-by: Mario Limonciello <[email protected]> Signed-off-by: Guchun Chen <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent af7828f commit 58d9b9a

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

drivers/gpu/drm/amd/pm/amdgpu_dpm.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,15 +1460,21 @@ int amdgpu_dpm_get_smu_prv_buf_details(struct amdgpu_device *adev,
14601460

14611461
int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev)
14621462
{
1463-
struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
1464-
struct smu_context *smu = adev->powerplay.pp_handle;
1463+
if (is_support_sw_smu(adev)) {
1464+
struct smu_context *smu = adev->powerplay.pp_handle;
1465+
1466+
return (smu->od_enabled || smu->is_apu);
1467+
} else {
1468+
struct pp_hwmgr *hwmgr;
14651469

1466-
if ((is_support_sw_smu(adev) && smu->od_enabled) ||
1467-
(is_support_sw_smu(adev) && smu->is_apu) ||
1468-
(!is_support_sw_smu(adev) && hwmgr->od_enabled))
1469-
return true;
1470+
/* SI asic does not carry od_enabled */
1471+
if (adev->family == AMDGPU_FAMILY_SI)
1472+
return false;
14701473

1471-
return false;
1474+
hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;
1475+
1476+
return hwmgr->od_enabled;
1477+
}
14721478
}
14731479

14741480
int amdgpu_dpm_set_pp_table(struct amdgpu_device *adev,

0 commit comments

Comments
 (0)