drm/amdgpu/pm: Drop redundant setting code for pcie lanes
Subsystems (3)
PATCH 1/3 drm/amdgpu/pm: Drop redundant setting code for pcie lanes
Drop redundant setting code for pcie.lanes. It overwrites the value get from pptable
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c +0 -2
@@ -702,8 +702,6 @@ static int init_non_clock_fields(struct pp_hwmgr *hwmgr, ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1; - ps->pcie.lanes =0 ; - ps->display.disableFrameModulation = false; rrr_index = (le32_to_cpu(pnon_clock_info->ulCapsAndSettings) &
Signature · 1 line
2.34.1
PATCH 2/3 drm/amdgpu/pm: Fix the null pointer dereference to pcurrent
Check pcurrent pointer before using it to fix
the null pointer dereference
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +9 -3
@@ -254,10 +254,16 @@ static void power_state_management(struct pp_hwmgr *hwmgr, pcurrent = hwmgr->current_ps; -phm_apply_state_adjust_rules (hwmgr, requested, pcurrent); -if (pcurrent ==NULL || (0 !=phm_check_states_equal (hwmgr, - &pcurrent->hardware, &requested->hardware, &equal))) +if (pcurrent) { +phm_apply_state_adjust_rules (hwmgr, requested, pcurrent); +if (phm_check_states_equal (hwmgr, + &pcurrent->hardware, &requested->hardware, &equal)) + equal = false; +else + equal = true; + }else { equal = false; + }if (!equal ||phm_check_smc_update_required_for_display_configuration (hwmgr)) {phm_set_power_state (hwmgr, &pcurrent->hardware, &requested->hardware);
Signature · 1 line
2.34.1
PATCH 3/3 drm/amdgpu/pm: Fix the null pointer dereference in apply_state_adjust_rules
In reply to Ma JunCheck the pointer value to fix potential null pointer dereference
--- .../gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 7 +++++-- .../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 14 ++++++++------ .../gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 7 +++++-- 3 files changed, 18 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +5 -2
@@ -3314,8 +3314,7 @@ static int smu7_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, const struct pp_power_state *current_ps) {struct amdgpu_device *adev = hwmgr->adev; -struct smu7_power_state *smu7_ps = -cast_phw_smu7_power_state (&request_ps->hardware); +struct smu7_power_state *smu7_ps;uint32_t sclk;uint32_t mclk;struct PP_Clocks minimum_clocks = {0 };
@@ -3332,6 +3331,10 @@ static int smu7_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,uint32_t latency;bool latency_allowed = false; + smu7_ps =cast_phw_smu7_power_state (&request_ps->hardware); +if (!smu7_ps) +return -EINVAL ; + data->battery_state = (PP_StateUILabel_Battery == request_ps->classification.ui_label); data->mclk_ignore_signal = false;
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +8 -6
@@ -1074,16 +1074,18 @@ static int smu8_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,struct pp_power_state *prequest_ps, const struct pp_power_state *pcurrent_ps) { - struct smu8_power_state *smu8_ps = -cast_smu8_power_state (&prequest_ps->hardware); - -const struct smu8_power_state *smu8_current_ps = -cast_const_smu8_power_state (&pcurrent_ps->hardware); - + struct smu8_power_state *smu8_ps; +const struct smu8_power_state *smu8_current_ps;struct smu8_hwmgr *data = hwmgr->backend;struct PP_Clocks clocks = {0 ,0 ,0 ,0 };bool force_high; + smu8_ps =cast_smu8_power_state (&prequest_ps->hardware); + smu8_current_ps =cast_const_smu8_power_state (&pcurrent_ps->hardware); + +if (!smu8_ps || !smu8_current_ps) +return -EINVAL ; + smu8_ps->need_dfs_bypass = true; data->battery_state = (PP_StateUILabel_Battery == prequest_ps->classification.ui_label);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +5 -2
@@ -3280,8 +3280,7 @@ static int vega10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, const struct pp_power_state *current_ps) {struct amdgpu_device *adev = hwmgr->adev; -struct vega10_power_state *vega10_ps = -cast_phw_vega10_power_state (&request_ps->hardware); +struct vega10_power_state *vega10_ps;uint32_t sclk;uint32_t mclk;struct PP_Clocks minimum_clocks = {0 };
@@ -3299,6 +3298,10 @@ static int vega10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,uint32_t stable_pstate_sclk =0 , stable_pstate_mclk =0 ;uint32_t latency; + vega10_ps =cast_phw_vega10_power_state (&request_ps->hardware); +if (!vega10_ps) +return -EINVAL ; + data->battery_state = (PP_StateUILabel_Battery == request_ps->classification.ui_label);
Signature · 1 line
2.34.1
Re: [PATCH 3/3] drm/amdgpu/pm: Fix the null pointer dereference in apply_state_adjust_rules
[AMD Official Use Only - General]
Series is
Best Regards,
Kevin
________________________________
From: Ma, Jun <[email protected]>
Sent: Friday, May 10, 2024 17:42
To: [email protected] <[email protected]>
Cc: Feng, Kenneth <[email protected]>; Deucher, Alexander <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Koenig, Christian <[email protected]>; Ma, Jun <[email protected]>
Subject: [PATCH 3/3] drm/amdgpu/pm: Fix the null pointer dereference in apply_state_adjust_rules
Check the pointer value to fix potential null pointer dereference
--- .../gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 7 +++++-- .../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 14 ++++++++------ .../gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 7 +++++-- 3 files changed, 18 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +5 -2
@@ -3314,8 +3314,7 @@ static int smu7_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, const struct pp_power_state *current_ps) {struct amdgpu_device *adev = hwmgr->adev; -struct smu7_power_state *smu7_ps = -cast_phw_smu7_power_state (&request_ps->hardware); +struct smu7_power_state *smu7_ps;uint32_t sclk;uint32_t mclk;struct PP_Clocks minimum_clocks = {0 };
@@ -3332,6 +3331,10 @@ static int smu7_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,uint32_t latency;bool latency_allowed = false; + smu7_ps =cast_phw_smu7_power_state (&request_ps->hardware); +if (!smu7_ps) +return -EINVAL ; + data->battery_state = (PP_StateUILabel_Battery == request_ps->classification.ui_label); data->mclk_ignore_signal = false;
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +8 -6
@@ -1074,16 +1074,18 @@ static int smu8_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,struct pp_power_state *prequest_ps, const struct pp_power_state *pcurrent_ps) { - struct smu8_power_state *smu8_ps = -cast_smu8_power_state (&prequest_ps->hardware); - -const struct smu8_power_state *smu8_current_ps = -cast_const_smu8_power_state (&pcurrent_ps->hardware); - + struct smu8_power_state *smu8_ps; +const struct smu8_power_state *smu8_current_ps;struct smu8_hwmgr *data = hwmgr->backend;struct PP_Clocks clocks = {0 ,0 ,0 ,0 };bool force_high; + smu8_ps =cast_smu8_power_state (&prequest_ps->hardware); + smu8_current_ps =cast_const_smu8_power_state (&pcurrent_ps->hardware); + +if (!smu8_ps || !smu8_current_ps) +return -EINVAL ; + smu8_ps->need_dfs_bypass = true; data->battery_state = (PP_StateUILabel_Battery == prequest_ps->classification.ui_label);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +5 -2
@@ -3280,8 +3280,7 @@ static int vega10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, const struct pp_power_state *current_ps) {struct amdgpu_device *adev = hwmgr->adev; -struct vega10_power_state *vega10_ps = -cast_phw_vega10_power_state (&request_ps->hardware); +struct vega10_power_state *vega10_ps;uint32_t sclk;uint32_t mclk;struct PP_Clocks minimum_clocks = {0 };
@@ -3299,6 +3298,10 @@ static int vega10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,uint32_t stable_pstate_sclk =0 , stable_pstate_mclk =0 ;uint32_t latency; + vega10_ps =cast_phw_vega10_power_state (&request_ps->hardware); +if (!vega10_ps) +return -EINVAL ; + data->battery_state = (PP_StateUILabel_Battery == request_ps->classification.ui_label);
--
2.34.1