drm/amd/display: Fix Null point error if smu ip was disabled
Subsystems (3)
PATCH 1/2 drm/amd/display: Fix Null point error if smu ip was disabled
from AI, SMU Ip is not indispensable to driver and can be disabled by user via module parameter ip_block_mask. so the pp_handle may be NULL.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +11 -5
@@ -101,7 +101,7 @@ bool dm_pp_apply_display_requirements( adev->pm.pm_display_cfg.displays[i].controller_id = dc_cfg->pipe_idx +1 ; } -if (adev->powerplay.pp_funcs->display_configuration_change) +if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->display_configuration_change) adev->powerplay.pp_funcs->display_configuration_change ( adev->powerplay.pp_handle, &adev->pm.pm_display_cfg);
@@ -304,7 +304,7 @@ bool dm_pp_get_clock_levels_by_type(struct amd_pp_simple_clock_info validation_clks = {0 };uint32_t i; -if (adev->powerplay.pp_funcs->get_clock_by_type) { +if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_clock_by_type) {if (adev->powerplay.pp_funcs->get_clock_by_type (pp_handle,dc_to_pp_clock_type (clk_type), &pp_clks)) {/* Error in pplib. Provide default values. */
@@ -315,7 +315,7 @@ bool dm_pp_get_clock_levels_by_type(pp_to_dc_clock_levels (&pp_clks, dc_clks, clk_type); -if (adev->powerplay.pp_funcs->get_display_mode_validation_clocks) { +if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_display_mode_validation_clocks) {if (adev->powerplay.pp_funcs->get_display_mode_validation_clocks ( pp_handle, &validation_clks)) {/* Error in pplib. Provide default values. */
@@ -398,6 +398,9 @@ bool dm_pp_get_clock_levels_by_type_with_voltage(struct pp_clock_levels_with_voltage pp_clk_info = {0 };const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +if (!pp_funcs || !pp_funcs->get_clock_by_type_with_voltage) +return false; +if (pp_funcs->get_clock_by_type_with_voltage (pp_handle,dc_to_pp_clock_type (clk_type), &pp_clk_info))
@@ -438,7 +441,7 @@ bool dm_pp_apply_clock_for_voltage_request(if (!pp_clock_request.clock_type)return false; -if (adev->powerplay.pp_funcs->display_clock_voltage_request) +if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->display_clock_voltage_request) ret = adev->powerplay.pp_funcs->display_clock_voltage_request ( adev->powerplay.pp_handle, &pp_clock_request);
@@ -455,7 +458,7 @@ bool dm_pp_get_static_clocks(struct amd_pp_clock_info pp_clk_info = {0 };int ret =0 ; -if (adev->powerplay.pp_funcs->get_current_clocks) +if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_current_clocks) ret = adev->powerplay.pp_funcs->get_current_clocks ( adev->powerplay.pp_handle, &pp_clk_info);
@@ -505,6 +508,9 @@ void pp_rv_set_wm_ranges(struct pp_smu *pp, wm_with_clock_ranges.num_wm_dmif_sets = ranges->num_reader_wm_sets; wm_with_clock_ranges.num_wm_mcif_sets = ranges->num_writer_wm_sets; +if (!pp_funcs || !pp_funcs->set_watermarks_for_clocks_ranges) +return ; +for (i =0 ; i < wm_with_clock_ranges.num_wm_dmif_sets; i++) {if (ranges->reader_wm_sets[i].wm_inst >3 ) wm_dce_clocks[i].wm_set_id =WM_SET_A ;
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amdgpu: Fix null point errro
In reply to a message not in the archiveneed to check adev->powerplay.pp_funcs first, becasue from AI, the smu ip may be disabled by user, and the pp_handle is null in this case.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 6 ++++-- 5 files changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +4 -2
@@ -135,7 +135,8 @@ static int acp_poweroff(struct generic_pm_domain *genpd)* 2. power off the acp tiles * 3. check and enter ulv state */ -if (adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->set_powergating_by_smu)amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_ACP , true); }return 0 ;
@@ -517,7 +518,8 @@ static int acp_set_powergating_state(void *handle,struct amdgpu_device *adev = (struct amdgpu_device *)handle;bool enable = state ==AMD_PG_STATE_GATE ? true : false; -if (adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->set_powergating_by_smu)amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_ACP , enable);return 0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
@@ -1783,6 +1783,7 @@ static int amdgpu_device_set_pg_state(struct amdgpu_device *adev, enum amd_power adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_VCE || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_VCN || adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_ACP) && + adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_powergating_by_smu) { if (!adev->ip_blocks[i].status.valid) { amdgpu_dpm_set_powergating_by_smu(adev, adev->ip_blocks[i].version->type, state == AMD_PG_STATE_GATE ?
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
@@ -392,7 +392,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable)if (!(adev->powerplay.pp_feature &PP_GFXOFF_MASK ))return ; -if (!adev->powerplay.pp_funcs->set_powergating_by_smu) +if (!adev->powerplay.pp_funcs || !adev->powerplay.pp_funcs->set_powergating_by_smu)return ;
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +1 -1
@@ -280,7 +280,7 @@ void mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,return ;if (enable && adev->pg_flags &AMD_PG_SUPPORT_MMHUB ) { -if (adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_powergating_by_smu)amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GMC , true); }
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +4 -2
@@ -1595,7 +1595,8 @@ static int sdma_v4_0_hw_init(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; -if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->set_powergating_by_smu)amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_SDMA , false);sdma_v4_0_init_golden_registers (adev);
@@ -1615,7 +1616,8 @@ static int sdma_v4_0_hw_fini(void *handle)sdma_v4_0_ctx_switch_enable (adev, false);sdma_v4_0_enable (adev, false); -if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs + && adev->powerplay.pp_funcs->set_powergating_by_smu)amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_SDMA , true);return 0 ;
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 2/2] drm/amdgpu: Fix null point errro
In reply to a message not in the archiveA minor suggestion, not sure if it's proper, Can we insert these callback checking to func? I know these func could be defined as a macro, can we change them to function definition?
David
Quoted 132 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Rex Zhu
Sent: Friday, October 19, 2018 10:51 AM
To: [email protected]
Cc: Zhu, Rex <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: Fix null point errroneed to check
adev->powerplay.pp_funcsfirst, becasue from AI, the smu ip may be disabled by user, and thepp_handleis null in this case.Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 6 ++++-- 5 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +2
-1@@ -135,7 +135,8 @@ static int acp_poweroff(struct generic_pm_domain*genpd) * 2. power off the acp tiles * 3. check and enter ulv state */ -if (adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs- >set_powergating_by_smu) amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_ACP, true);drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +2
-1}return 0 ;@@ -517,7 +518,8 @@ static int acp_set_powergating_state(void *handle,struct amdgpu_device *adev = (struct amdgpu_device *)handle;bool enable = state ==AMD_PG_STATE_GATE ? true : false; -if (adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->set_powergating_by_smu)amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_ACP , enable);drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-0return 0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1783,6 +1783,7 @@ static int amdgpu_device_set_pg_state(struct
amdgpu_device*adev, enumamd_power
adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_VCE||
adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_VCN||
adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_ACP) &&drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_powergating_by_smu) {if (!adev->ip_blocks[i].status.valid) {amdgpu_dpm_set_powergating_by_smu(adev, adev-
Quoted 1 line
ip_blocks[i].version->type, state ==
AMD_PG_STATE_GATE?drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2
-1@@ -392,7 +392,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable)if (!(adev->powerplay.pp_feature &PP_GFXOFF_MASK ))return ; -if (!adev->powerplay.pp_funcs->set_powergating_by_smu) +if (!adev->powerplay.pp_funcs || +!adev->powerplay.pp_funcs->set_powergating_by_smu)return ;drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +2
-1@@ -280,7 +280,7 @@ void mmhub_v1_0_update_power_gating(structamdgpu_device *adev, return;if (enable && adev->pg_flags &AMD_PG_SUPPORT_MMHUB ) { -if (adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->powerplay.pp_funcs && +adev->powerplay.pp_funcs->set_powergating_by_smu) amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_GMC, true);drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +0
-0}drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1
-1@@ -1595,7 +1595,8 @@ static int sdma_v4_0_hw_init(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; -if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs- >set_powergating_by_smu) + if (adev->asic_type == CHIP_RAVEN && adev->powerplay.pp_funcs&&
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1
-0+ adev->powerplay.pp_funcs-Quoted 1 line
set_powergating_by_smu)amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_SDMA, false);drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2
-1sdma_v4_0_init_golden_registers (adev);@@ -1615,7 +1616,8 @@ static int sdma_v4_0_hw_fini(void *handle)sdma_v4_0_ctx_switch_enable (adev, false);sdma_v4_0_enable (adev, false); -if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs- >set_powergating_by_smu) +if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs + && adev->powerplay.pp_funcs- >set_powergating_by_smu) amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_SDMA, true);
Quoted 8 lines
return 0;
--
1.9.1_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
Reviewed-byRe: [PATCH 2/2] drm/amdgpu: Fix null point errro
In reply to a message not in the archiveQuoted 2 lines · David(ChunMing)
A minor suggestion, not sure if it's proper, Can we insert these callback checking to func? I know these func could be defined as a macro, can we change them to function definition?
I think we already do something similar with the other dpm macros. Either way, the series is:
Quoted 139 lines
David
Quoted 136 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Rex Zhu
Sent: Friday, October 19, 2018 10:51 AM
To: [email protected]
Cc: Zhu, Rex <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: Fix null point errroneed to check
adev->powerplay.pp_funcsfirst, becasue from AI, the smu ip may be disabled by user, and thepp_handleis null in this case.Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 6 ++++-- 5 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +2
-1@@ -135,7 +135,8 @@ static int acp_poweroff(struct generic_pm_domain*genpd) * 2. power off the acp tiles * 3. check and enter ulv state */ -if (adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs- >set_powergating_by_smu) amdgpu_dpm_set_powergating_by_smu(adev,AMD_IP_BLOCK_TYPE_ACP, true); } return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +2
-1@@ -517,7 +518,8 @@ static int acp_set_powergating_state(void *handle,struct amdgpu_device *adev = (struct amdgpu_device *)handle;bool enable = state ==AMD_PG_STATE_GATE ? true : false; -if (adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->set_powergating_by_smu)amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_ACP , enable);return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1783,6 +1783,7 @@ static int amdgpu_device_set_pg_state(struct
amdgpu_device*adev, enumamd_poweradev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_VCE || adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_VCN || adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_ACP) && + adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_powergating_by_smu) { if (!adev->ip_blocks[i].status.valid) { amdgpu_dpm_set_powergating_by_smu(adev, adev-Quoted 1 line
ip_blocks[i].version->type, state ==
AMD_PG_STATE_GATE?drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2
-1@@ -392,7 +392,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable)if (!(adev->powerplay.pp_feature &PP_GFXOFF_MASK ))return ; -if (!adev->powerplay.pp_funcs->set_powergating_by_smu) +if (!adev->powerplay.pp_funcs || +!adev->powerplay.pp_funcs->set_powergating_by_smu)return ;drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +2
-1@@ -280,7 +280,7 @@ void mmhub_v1_0_update_power_gating(structamdgpu_device *adev, return;if (enable && adev->pg_flags &AMD_PG_SUPPORT_MMHUB ) { -if (adev->powerplay.pp_funcs->set_powergating_by_smu) +if (adev->powerplay.pp_funcs && +adev->powerplay.pp_funcs->set_powergating_by_smu) amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_GMC, true);}drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1
-1@@ -1595,7 +1595,8 @@ static int sdma_v4_0_hw_init(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; -if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs- >set_powergating_by_smu) + if (adev->asic_type == CHIP_RAVEN && adev->powerplay.pp_funcs&&
+ adev->powerplay.pp_funcs-Quoted 1 line
set_powergating_by_smu)amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_SDMA, false);sdma_v4_0_init_golden_registers(adev);drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2
-1@@ -1615,7 +1616,8 @@ static int sdma_v4_0_hw_fini(void *handle)sdma_v4_0_ctx_switch_enable (adev, false);sdma_v4_0_enable (adev, false); -if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs- >set_powergating_by_smu) +if (adev->asic_type ==CHIP_RAVEN && adev->powerplay.pp_funcs + && adev->powerplay.pp_funcs- >set_powergating_by_smu) amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_SDMA, true);return 0;--
1.9.1
Quoted 8 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx