Skip to content

Commit 277b080

Browse files
Evan Quanalexdeucher
authored andcommitted
drm/amd/pm: perform SMC reset on suspend/hibernation
So that the succeeding resume can be performed based on a clean state. Signed-off-by: Evan Quan <evan.quan@amd.com> Tested-by: Sandeep Raghuraman <sandy.8925@gmail.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 2a4776a commit 277b080

5 files changed

Lines changed: 39 additions & 0 deletions

File tree

drivers/gpu/drm/amd/pm/inc/hwmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ struct pp_smumgr_func {
229229
bool (*is_hw_avfs_present)(struct pp_hwmgr *hwmgr);
230230
int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void *profile_setting);
231231
int (*smc_table_manager)(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t table_id, bool rw); /*rw: true for read, false for write */
232+
int (*stop_smc)(struct pp_hwmgr *hwmgr);
232233
};
233234

234235
struct pp_hwmgr_func {

drivers/gpu/drm/amd/pm/inc/smumgr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,6 @@ extern int smum_update_dpm_settings(struct pp_hwmgr *hwmgr, void *profile_settin
113113

114114
extern int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t table_id, bool rw);
115115

116+
extern int smum_stop_smc(struct pp_hwmgr *hwmgr);
117+
116118
#endif

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,10 @@ static int smu7_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
15411541
PP_ASSERT_WITH_CODE((tmp_result == 0),
15421542
"Failed to reset to default!", result = tmp_result);
15431543

1544+
tmp_result = smum_stop_smc(hwmgr);
1545+
PP_ASSERT_WITH_CODE((tmp_result == 0),
1546+
"Failed to stop smc!", result = tmp_result);
1547+
15441548
tmp_result = smu7_force_switch_to_arbf0(hwmgr);
15451549
PP_ASSERT_WITH_CODE((tmp_result == 0),
15461550
"Failed to force to switch arbf0!", result = tmp_result);

drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,6 +2939,29 @@ static int ci_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type)
29392939
return 0;
29402940
}
29412941

2942+
static void ci_reset_smc(struct pp_hwmgr *hwmgr)
2943+
{
2944+
PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
2945+
SMC_SYSCON_RESET_CNTL,
2946+
rst_reg, 1);
2947+
}
2948+
2949+
2950+
static void ci_stop_smc_clock(struct pp_hwmgr *hwmgr)
2951+
{
2952+
PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
2953+
SMC_SYSCON_CLOCK_CNTL_0,
2954+
ck_disable, 1);
2955+
}
2956+
2957+
static int ci_stop_smc(struct pp_hwmgr *hwmgr)
2958+
{
2959+
ci_reset_smc(hwmgr);
2960+
ci_stop_smc_clock(hwmgr);
2961+
2962+
return 0;
2963+
}
2964+
29422965
const struct pp_smumgr_func ci_smu_funcs = {
29432966
.name = "ci_smu",
29442967
.smu_init = ci_smu_init,
@@ -2964,4 +2987,5 @@ const struct pp_smumgr_func ci_smu_funcs = {
29642987
.is_dpm_running = ci_is_dpm_running,
29652988
.update_dpm_settings = ci_update_dpm_settings,
29662989
.update_smc_table = ci_update_smc_table,
2990+
.stop_smc = ci_stop_smc,
29672991
};

drivers/gpu/drm/amd/pm/powerplay/smumgr/smumgr.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,11 @@ int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t tabl
245245

246246
return -EINVAL;
247247
}
248+
249+
int smum_stop_smc(struct pp_hwmgr *hwmgr)
250+
{
251+
if (hwmgr->smumgr_funcs->stop_smc)
252+
return hwmgr->smumgr_funcs->stop_smc(hwmgr);
253+
254+
return 0;
255+
}

0 commit comments

Comments
 (0)