drm/amd/pm: parse pp_handle under appropriate conditions
Subsystems (3)
PATCH 1/1 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.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +9 -7
@@ -1455,13 +1455,15 @@ 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) && smu->od_enabled) || - (is_support_sw_smu (adev) && smu->is_apu) || - (!is_support_sw_smu (adev) && hwmgr->od_enabled)) -return true; +if (is_support_sw_smu (adev)) { +struct smu_context *smu = adev->powerplay.pp_handle; +if (smu->od_enabled || smu->is_apu) +return true; + }else { +struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; +if (hwmgr->od_enabled) +return true; + }return false; }
Signature · 1 line
2.25.1
Quoted 20 lines · Guchun Chen
amdgpu_dpm_is_overdrive_supportedis a common API across all asics, so we should castpp_handleinto correct structure under different power frameworks.Fixes ebfc253335af("drm/amd/pm: do not expose the smu_context structure used internally in power")Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1@@ -1455,13 +1455,15 @@ 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;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_smu_prv_buf_details(struct amdgpu_device *adev, · line 1461
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-6-struct smu_context *smu = adev->powerplay.pp_handle; - -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; +if (is_support_sw_smu (adev)) { +struct smu_context *smu = adev->powerplay.pp_handle; +if (smu->od_enabled || smu->is_apu) +
Minor change - return (smu->od_enabled || smu->is_apu); and similar below for the other check also.
Anyway,
Thanks,
Lijo
return true;
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+ }else { +struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; +if (hwmgr->od_enabled) +return true; + }return false; }
Quoted 37 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, May 5, 2023 5:00 PM
To: Chen, Guchun <[email protected]>; amd- [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Quan, Evan <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: parsepp_handleunder appropriate conditionsdrivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 18 lines · Guchun Chen
amdgpu_dpm_is_overdrive_supportedis a common API across all asics, so we should castpp_handleinto correct structure under different power frameworks.Fixes ebfc253335af("drm/amd/pm: do not expose the smu_contextstructure used internally in power")
Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1455,13 +1455,15 @@ intamdgpu_dpm_get_smu_prv_buf_details(struct
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0amdgpu_device *adev,
Quoted 16 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_smu_prv_buf_details(struct amdgpu_device *adev,
Quoted 13 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-7int 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) && smu->od_enabled) || - (is_support_sw_smu (adev) && smu->is_apu) || - (!is_support_sw_smu (adev) && hwmgr->od_enabled)) -return true; +if (is_support_sw_smu (adev)) { +struct smu_context *smu = adev->powerplay.pp_handle; +if (smu->od_enabled || smu->is_apu) +Minor change - return (
smu->od_enabled||smu->is_apu); and similar below for the other check also.
Make sense, will update in v2 with your RB.
Regards,
Guchun
Quoted 16 lines
Anyway,
Reviewed-by Lijo Lazar <[email protected]>Thanks,
Lijoreturn true;Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+ }else { +struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; +if (hwmgr->od_enabled) +return true; + }return false;}
[AMD Official Use Only - General]
+Mario
I believe the comment below from Mario points the right direction to suppress the "UBSAN: invalid-load..." warnings.
https://gitlab.freedesktop.org/drm/amd/-/issues/2541#note_1898035
However, it might be not right to simply drop the line below since the adev->powerplay.pp_handle pointer is still needed for those APIs like amdgpu_dpm_read_sensor().
- adev->powerplay.pp_handle = adev;
BR
Evan
Quoted 55 lines
-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Friday, May 5, 2023 4:24 PM
To: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>
Cc: Chen, Guchun <[email protected]>
Subject: [PATCH] drm/amd/pm: parsepp_handleunder appropriate conditions
amdgpu_dpm_is_overdrive_supportedis a common API across all asics, so we should castpp_handleinto correct structure under different power frameworks.Fixes ebfc253335af("drm/amd/pm: do not expose the smu_contextstructure used internally in power")
Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +9
-7@@ -1455,13 +1455,15 @@ 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) && smu->od_enabled) || - (is_support_sw_smu (adev) && smu->is_apu) || - (!is_support_sw_smu (adev) && hwmgr->od_enabled)) -return true; + if (is_support_sw_smu(adev)) { + struct smu_context *smu = adev->powerplay.pp_handle; +if (smu->od_enabled || smu->is_apu) +return true; + } else { +struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; +if (hwmgr->od_enabled) +return true; + }return false;}
--
2.25.1
[AMD Official Use Only - General]
Quoted 16 lines
-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Saturday, May 6, 2023 9:51 AM
To: Chen, Guchun <[email protected]>; amd- [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>
Cc: Limonciello, Mario <[email protected]>
Subject: RE: [PATCH] drm/amd/pm: parsepp_handleunder appropriate conditions[AMD Official Use Only - General]
+Mario
Quoted 7 lines
I believe the comment below from Mario points the right direction to suppress the "UBSAN: invalid-load..." warnings.
https://gitlab.freedesktop.org/drm/amd/-/issues/2541#note_1898035
However, it might be not right to simply drop the line below since the adev-Quoted 1 line
powerplay.pp_handle pointer is still needed for those APIs like
amdgpu_dpm_read_sensor().
-adev->powerplay.pp_handle= adev;
Thanks Mario and Evan. I think the new patch set v3 should fix that problem. I will ask reporter to have a try as well.
Regards,
Guchun
Quoted 57 lines
BR
EvanQuoted 5 lines
-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Friday, May 5, 2023 4:24 PM
To: [email protected]; Deucher, Alexander <[email protected]>; Zhang, HawkingQuoted 49 lines
Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>
Cc: Chen, Guchun <[email protected]>
Subject: [PATCH] drm/amd/pm: parsepp_handleunder appropriate conditions
amdgpu_dpm_is_overdrive_supportedis a common API across all asics, so we should castpp_handleinto correct structure under different power frameworks.Fixes ebfc253335af("drm/amd/pm: do not expose the smu_contextstructure used internally in power")
Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +9
-8@@ -1455,13 +1455,15 @@ 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) && smu->od_enabled) || - (is_support_sw_smu (adev) && smu->is_apu) || - (!is_support_sw_smu (adev) && hwmgr->od_enabled)) -return true; + if (is_support_sw_smu(adev)) { + struct smu_context *smu = adev->powerplay.pp_handle; +if (smu->od_enabled || smu->is_apu) +return true; + } else { +struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; +if (hwmgr->od_enabled) +return true; + }return false; } --2.25.1