summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuchun Chen <guchun.chen@amd.com>2023-05-05 13:20:11 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-17 14:02:02 +0200
commiteb0b3f7cc1e27535f2ae77ebff74dde0fa23ddad (patch)
tree98350f77c5cd2f232006a4bd4c038a5a0fb48e5d
parentec7b8e4fe6ff070b0d9af2bcb9018bec6d3393ce (diff)
downloadlinux-stable-eb0b3f7cc1e27535f2ae77ebff74dde0fa23ddad.tar.gz
linux-stable-eb0b3f7cc1e27535f2ae77ebff74dde0fa23ddad.tar.bz2
linux-stable-eb0b3f7cc1e27535f2ae77ebff74dde0fa23ddad.zip
drm/amd/pm: parse pp_handle under appropriate conditions
commit 58d9b9a14b47c2a3da6effcbb01607ad7edc0275 upstream. 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: eb4900aa4c49 ("drm/amdgpu: Fix kernel NULL pointer dereference in dpm functions") Suggested-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Guchun Chen <guchun.chen@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/gpu/drm/amd/pm/amdgpu_dpm.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index 6e79d3352d0b..29720d0b0544 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
@@ -1432,15 +1432,21 @@ int amdgpu_dpm_get_smu_prv_buf_details(struct amdgpu_device *adev,
int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev)
{
- struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
- struct smu_context *smu = adev->powerplay.pp_handle;
+ if (is_support_sw_smu(adev)) {
+ 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) ||
- (is_support_sw_smu(adev) && smu->is_apu) ||
- (!is_support_sw_smu(adev) && hwmgr->od_enabled))
- return true;
+ /* SI asic does not carry od_enabled */
+ if (adev->family == AMDGPU_FAMILY_SI)
+ return false;
- return false;
+ hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;
+
+ return hwmgr->od_enabled;
+ }
}
int amdgpu_dpm_set_pp_table(struct amdgpu_device *adev,