Skip to content

Commit 7a372e2

Browse files
mythilamalexdeucher
authored andcommitted
drm/amd/pm: restore SCLK settings after S0ix resume
User-configured SCLK(GPU core clock)frequencies were not persisting across S0ix suspend/resume cycles on smu v14 hardware. The issue occurred because of the code resetting clock frequency to zero during resume. This patch addresses the problem by: - Preserving user-configured values in driver and sets the clock frequency across resume - Preserved settings are sent to the hardware during resume Signed-off-by: mythilam <mythilam@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Yang Wang <kevinyang.wang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 20ba983)
1 parent 77f7325 commit 7a372e2

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,11 @@ int smu_v14_0_od_edit_dpm_table(struct smu_context *smu,
19391939
dev_err(smu->adev->dev, "Set soft max sclk failed!");
19401940
return ret;
19411941
}
1942+
if (smu->gfx_actual_hard_min_freq != smu->gfx_default_hard_min_freq ||
1943+
smu->gfx_actual_soft_max_freq != smu->gfx_default_soft_max_freq)
1944+
smu->user_dpm_profile.user_od = true;
1945+
else
1946+
smu->user_dpm_profile.user_od = false;
19421947
break;
19431948
default:
19441949
return -ENOSYS;

drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,9 +1514,10 @@ static int smu_v14_0_1_set_fine_grain_gfx_freq_parameters(struct smu_context *sm
15141514

15151515
smu->gfx_default_hard_min_freq = clk_table->MinGfxClk;
15161516
smu->gfx_default_soft_max_freq = clk_table->MaxGfxClk;
1517-
smu->gfx_actual_hard_min_freq = 0;
1518-
smu->gfx_actual_soft_max_freq = 0;
1519-
1517+
if (smu->gfx_actual_hard_min_freq == 0)
1518+
smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq;
1519+
if (smu->gfx_actual_soft_max_freq == 0)
1520+
smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq;
15201521
return 0;
15211522
}
15221523

@@ -1526,8 +1527,10 @@ static int smu_v14_0_0_set_fine_grain_gfx_freq_parameters(struct smu_context *sm
15261527

15271528
smu->gfx_default_hard_min_freq = clk_table->MinGfxClk;
15281529
smu->gfx_default_soft_max_freq = clk_table->MaxGfxClk;
1529-
smu->gfx_actual_hard_min_freq = 0;
1530-
smu->gfx_actual_soft_max_freq = 0;
1530+
if (smu->gfx_actual_hard_min_freq == 0)
1531+
smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq;
1532+
if (smu->gfx_actual_soft_max_freq == 0)
1533+
smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq;
15311534

15321535
return 0;
15331536
}
@@ -1665,6 +1668,29 @@ static int smu_v14_0_common_set_mall_enable(struct smu_context *smu)
16651668
return ret;
16661669
}
16671670

1671+
static int smu_v14_0_0_restore_user_od_settings(struct smu_context *smu)
1672+
{
1673+
int ret;
1674+
1675+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinGfxClk,
1676+
smu->gfx_actual_hard_min_freq,
1677+
NULL);
1678+
if (ret) {
1679+
dev_err(smu->adev->dev, "Failed to restore hard min sclk!\n");
1680+
return ret;
1681+
}
1682+
1683+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxGfxClk,
1684+
smu->gfx_actual_soft_max_freq,
1685+
NULL);
1686+
if (ret) {
1687+
dev_err(smu->adev->dev, "Failed to restore soft max sclk!\n");
1688+
return ret;
1689+
}
1690+
1691+
return 0;
1692+
}
1693+
16681694
static const struct pptable_funcs smu_v14_0_0_ppt_funcs = {
16691695
.check_fw_status = smu_v14_0_check_fw_status,
16701696
.check_fw_version = smu_v14_0_check_fw_version,
@@ -1688,6 +1714,7 @@ static const struct pptable_funcs smu_v14_0_0_ppt_funcs = {
16881714
.mode2_reset = smu_v14_0_0_mode2_reset,
16891715
.get_dpm_ultimate_freq = smu_v14_0_common_get_dpm_ultimate_freq,
16901716
.set_soft_freq_limited_range = smu_v14_0_0_set_soft_freq_limited_range,
1717+
.restore_user_od_settings = smu_v14_0_0_restore_user_od_settings,
16911718
.od_edit_dpm_table = smu_v14_0_od_edit_dpm_table,
16921719
.print_clk_levels = smu_v14_0_0_print_clk_levels,
16931720
.force_clk_levels = smu_v14_0_0_force_clk_levels,

0 commit comments

Comments
 (0)