Skip to content

Commit 5525c28

Browse files
alexdeuchergregkh
authored andcommitted
drm/amd/pm/smu7: move variables to where they are used
commit 63a9ab2 upstream. Move variable declarations to where they are used. Fixes a segfault on smu7 V0 structures where some tables don't exist. Cc: Evan Quan <evan.quan@amd.com> Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2388 Fixes: b1a9557 ("drm/amd/pm: fulfill powerplay peak profiling mode shader/memory clock settings") Reviewed-by: Evan Quan <evan.quan@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4346a66 commit 5525c28

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,12 +1505,6 @@ static void smu7_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
15051505
{
15061506
struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
15071507
struct smu7_dpm_table *golden_dpm_table = &data->golden_dpm_table;
1508-
struct phm_clock_voltage_dependency_table *vddc_dependency_on_sclk =
1509-
hwmgr->dyn_state.vddc_dependency_on_sclk;
1510-
struct phm_ppt_v1_information *table_info =
1511-
(struct phm_ppt_v1_information *)(hwmgr->pptable);
1512-
struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_sclk =
1513-
table_info->vdd_dep_on_sclk;
15141508
int32_t tmp_sclk, count, percentage;
15151509

15161510
if (golden_dpm_table->mclk_table.count == 1) {
@@ -1525,6 +1519,9 @@ static void smu7_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
15251519
tmp_sclk = hwmgr->pstate_mclk * percentage / 100;
15261520

15271521
if (hwmgr->pp_table_version == PP_TABLE_V0) {
1522+
struct phm_clock_voltage_dependency_table *vddc_dependency_on_sclk =
1523+
hwmgr->dyn_state.vddc_dependency_on_sclk;
1524+
15281525
for (count = vddc_dependency_on_sclk->count - 1; count >= 0; count--) {
15291526
if (tmp_sclk >= vddc_dependency_on_sclk->entries[count].clk) {
15301527
hwmgr->pstate_sclk = vddc_dependency_on_sclk->entries[count].clk;
@@ -1537,6 +1534,11 @@ static void smu7_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
15371534
hwmgr->pstate_sclk_peak =
15381535
vddc_dependency_on_sclk->entries[vddc_dependency_on_sclk->count - 1].clk;
15391536
} else if (hwmgr->pp_table_version == PP_TABLE_V1) {
1537+
struct phm_ppt_v1_information *table_info =
1538+
(struct phm_ppt_v1_information *)(hwmgr->pptable);
1539+
struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_sclk =
1540+
table_info->vdd_dep_on_sclk;
1541+
15401542
for (count = vdd_dep_on_sclk->count - 1; count >= 0; count--) {
15411543
if (tmp_sclk >= vdd_dep_on_sclk->entries[count].clk) {
15421544
hwmgr->pstate_sclk = vdd_dep_on_sclk->entries[count].clk;

0 commit comments

Comments
 (0)