summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/pm
diff options
context:
space:
mode:
authorGuchun Chen <guchun.chen@amd.com>2023-05-09 09:36:49 +0800
committerAlex Deucher <alexander.deucher@amd.com>2023-06-09 09:36:34 -0400
commit936e95a461c2606ac2ffae3bb0d991e7081eafd8 (patch)
treeba42687372976b44f4b49dbf2d5e350175a232ad /drivers/gpu/drm/amd/pm
parenteb4f01784ec1d589629dd8c85044b7c07e5f6993 (diff)
downloadlinux-stable-936e95a461c2606ac2ffae3bb0d991e7081eafd8.tar.gz
linux-stable-936e95a461c2606ac2ffae3bb0d991e7081eafd8.tar.bz2
linux-stable-936e95a461c2606ac2ffae3bb0d991e7081eafd8.zip
drm/amd/pm: avoid potential UBSAN issue on legacy asics
Prevent further dpm casting on legacy asics without od_enabled in amdgpu_dpm_is_overdrive_supported. This can avoid UBSAN complain in init sequence. v2: add a macro to check legacy dpm instead of checking asic family/type v3: refine macro name for naming consistency Suggested-by: Evan Quan <evan.quan@amd.com> Signed-off-by: Guchun Chen <guchun.chen@amd.com> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/pm')
-rw-r--r--drivers/gpu/drm/amd/pm/amdgpu_dpm.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index 86246f69dbe1..078aaaa53162 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
@@ -36,6 +36,8 @@
#define amdgpu_dpm_enable_bapm(adev, e) \
((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e)))
+#define amdgpu_dpm_is_legacy_dpm(adev) ((adev)->powerplay.pp_handle == (adev))
+
int amdgpu_dpm_get_sclk(struct amdgpu_device *adev, bool low)
{
const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
@@ -1467,8 +1469,11 @@ int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev)
} else {
struct pp_hwmgr *hwmgr;
- /* SI asic does not carry od_enabled */
- if (adev->family == AMDGPU_FAMILY_SI)
+ /*
+ * dpm on some legacy asics don't carry od_enabled member
+ * as its pp_handle is casted directly from adev.
+ */
+ if (amdgpu_dpm_is_legacy_dpm(adev))
return false;
hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;