Skip to content

Commit 8b9242e

Browse files
Rex Zhualexdeucher
authored andcommitted
drm/amd/powerplay: implement stop dpm task for vega10.
Add functions to disable dpm for S3/S4. Signed-off-by: Rex Zhu <Rex.Zhu@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent f8dc947 commit 8b9242e

File tree

5 files changed

+123
-1
lines changed

5 files changed

+123
-1
lines changed

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,6 +2420,26 @@ static int vega10_enable_thermal_protection(struct pp_hwmgr *hwmgr)
24202420
return 0;
24212421
}
24222422

2423+
static int vega10_disable_thermal_protection(struct pp_hwmgr *hwmgr)
2424+
{
2425+
struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
2426+
2427+
if (data->smu_features[GNLD_THERMAL].supported) {
2428+
if (!data->smu_features[GNLD_THERMAL].enabled)
2429+
pr_info("THERMAL Feature Already disabled!");
2430+
2431+
PP_ASSERT_WITH_CODE(
2432+
!vega10_enable_smc_features(hwmgr->smumgr,
2433+
false,
2434+
data->smu_features[GNLD_THERMAL].smu_feature_bitmap),
2435+
"disable THERMAL Feature Failed!",
2436+
return -1);
2437+
data->smu_features[GNLD_THERMAL].enabled = false;
2438+
}
2439+
2440+
return 0;
2441+
}
2442+
24232443
static int vega10_enable_vrhot_feature(struct pp_hwmgr *hwmgr)
24242444
{
24252445
struct vega10_hwmgr *data =
@@ -2498,6 +2518,37 @@ static int vega10_enable_deep_sleep_master_switch(struct pp_hwmgr *hwmgr)
24982518
return 0;
24992519
}
25002520

2521+
static int vega10_stop_dpm(struct pp_hwmgr *hwmgr, uint32_t bitmap)
2522+
{
2523+
struct vega10_hwmgr *data =
2524+
(struct vega10_hwmgr *)(hwmgr->backend);
2525+
uint32_t i, feature_mask = 0;
2526+
2527+
2528+
if(data->smu_features[GNLD_LED_DISPLAY].supported == true){
2529+
PP_ASSERT_WITH_CODE(!vega10_enable_smc_features(hwmgr->smumgr,
2530+
true, data->smu_features[GNLD_LED_DISPLAY].smu_feature_bitmap),
2531+
"Attempt to Enable LED DPM feature Failed!", return -EINVAL);
2532+
data->smu_features[GNLD_LED_DISPLAY].enabled = true;
2533+
}
2534+
2535+
for (i = 0; i < GNLD_DPM_MAX; i++) {
2536+
if (data->smu_features[i].smu_feature_bitmap & bitmap) {
2537+
if (data->smu_features[i].supported) {
2538+
if (data->smu_features[i].enabled) {
2539+
feature_mask |= data->smu_features[i].
2540+
smu_feature_bitmap;
2541+
data->smu_features[i].enabled = false;
2542+
}
2543+
}
2544+
}
2545+
}
2546+
2547+
vega10_enable_smc_features(hwmgr->smumgr, false, feature_mask);
2548+
2549+
return 0;
2550+
}
2551+
25012552
/**
25022553
* @brief Tell SMC to enabled the supported DPMs.
25032554
*
@@ -4356,11 +4407,55 @@ vega10_check_smc_update_required_for_display_configuration(struct pp_hwmgr *hwmg
43564407
return is_update_required;
43574408
}
43584409

4410+
static int vega10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
4411+
{
4412+
int tmp_result, result = 0;
4413+
4414+
tmp_result = (vega10_is_dpm_running(hwmgr)) ? 0 : -1;
4415+
PP_ASSERT_WITH_CODE(tmp_result == 0,
4416+
"DPM is not running right now, no need to disable DPM!",
4417+
return 0);
4418+
4419+
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
4420+
PHM_PlatformCaps_ThermalController))
4421+
vega10_disable_thermal_protection(hwmgr);
4422+
4423+
tmp_result = vega10_disable_power_containment(hwmgr);
4424+
PP_ASSERT_WITH_CODE((tmp_result == 0),
4425+
"Failed to disable power containment!", result = tmp_result);
4426+
4427+
tmp_result = vega10_avfs_enable(hwmgr, false);
4428+
PP_ASSERT_WITH_CODE((tmp_result == 0),
4429+
"Failed to disable AVFS!", result = tmp_result);
4430+
4431+
tmp_result = vega10_stop_dpm(hwmgr, SMC_DPM_FEATURES);
4432+
PP_ASSERT_WITH_CODE((tmp_result == 0),
4433+
"Failed to stop DPM!", result = tmp_result);
4434+
4435+
return result;
4436+
}
4437+
4438+
static int vega10_power_off_asic(struct pp_hwmgr *hwmgr)
4439+
{
4440+
struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
4441+
int result;
4442+
4443+
result = vega10_disable_dpm_tasks(hwmgr);
4444+
PP_ASSERT_WITH_CODE((0 == result),
4445+
"[disable_dpm_tasks] Failed to disable DPM!",
4446+
);
4447+
data->water_marks_bitmap &= ~(WaterMarksLoaded);
4448+
4449+
return result;
4450+
}
4451+
4452+
43594453
static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
43604454
.backend_init = vega10_hwmgr_backend_init,
43614455
.backend_fini = vega10_hwmgr_backend_fini,
43624456
.asic_setup = vega10_setup_asic_task,
43634457
.dynamic_state_management_enable = vega10_enable_dpm_tasks,
4458+
.dynamic_state_management_disable = vega10_disable_dpm_tasks,
43644459
.get_num_of_pp_table_entries =
43654460
vega10_get_number_of_powerplay_table_entries,
43664461
.get_power_state_size = vega10_get_power_state_size,
@@ -4400,6 +4495,8 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
44004495
.check_states_equal = vega10_check_states_equal,
44014496
.check_smc_update_required_for_display_configuration =
44024497
vega10_check_smc_update_required_for_display_configuration,
4498+
.power_off_asic = vega10_power_off_asic,
4499+
.disable_smc_firmware_ctf = vega10_thermal_disable_alert,
44034500
};
44044501

44054502
int vega10_hwmgr_init(struct pp_hwmgr *hwmgr)

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,29 @@ int vega10_enable_power_containment(struct pp_hwmgr *hwmgr)
113113
return result;
114114
}
115115

116+
int vega10_disable_power_containment(struct pp_hwmgr *hwmgr)
117+
{
118+
struct vega10_hwmgr *data =
119+
(struct vega10_hwmgr *)(hwmgr->backend);
120+
121+
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
122+
PHM_PlatformCaps_PowerContainment)) {
123+
if (data->smu_features[GNLD_PPT].supported)
124+
PP_ASSERT_WITH_CODE(!vega10_enable_smc_features(hwmgr->smumgr,
125+
false, data->smu_features[GNLD_PPT].smu_feature_bitmap),
126+
"Attempt to disable PPT feature Failed!",
127+
data->smu_features[GNLD_PPT].supported = false);
128+
129+
if (data->smu_features[GNLD_TDC].supported)
130+
PP_ASSERT_WITH_CODE(!vega10_enable_smc_features(hwmgr->smumgr,
131+
false, data->smu_features[GNLD_TDC].smu_feature_bitmap),
132+
"Attempt to disable PPT feature Failed!",
133+
data->smu_features[GNLD_TDC].supported = false);
134+
}
135+
136+
return 0;
137+
}
138+
116139
static int vega10_set_overdrive_target_percentage(struct pp_hwmgr *hwmgr,
117140
uint32_t adjust_percent)
118141
{

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ int vega10_enable_smc_cac(struct pp_hwmgr *hwmgr);
6060
int vega10_enable_power_containment(struct pp_hwmgr *hwmgr);
6161
int vega10_set_power_limit(struct pp_hwmgr *hwmgr, uint32_t n);
6262
int vega10_power_control_set_level(struct pp_hwmgr *hwmgr);
63+
int vega10_disable_power_containment(struct pp_hwmgr *hwmgr);
6364

6465
#endif /* _VEGA10_POWERTUNE_H_ */
6566

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static int vega10_thermal_enable_alert(struct pp_hwmgr *hwmgr)
501501
* Disable thermal alerts on the RV770 thermal controller.
502502
* @param hwmgr The address of the hardware manager.
503503
*/
504-
static int vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr)
504+
int vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr)
505505
{
506506
struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
507507

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ extern int vega10_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr,
7878
uint32_t *speed);
7979
extern int vega10_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr);
8080
extern uint32_t smu7_get_xclk(struct pp_hwmgr *hwmgr);
81+
extern int vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr);
8182

8283
#endif
8384

0 commit comments

Comments
 (0)