v2: cancel or wait current work finish before restart auto wattman. Disable auto wattman feature in manual mode if feature is enabled Signed-off-by: Rex Zhu <Rex.Zhu at amd.com> Change-Id: I4361d16df27d2666dd978c3e33e05c020d65fe6a --- drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c index b89b530..937b30a 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c @@ -82,6 +82,7 @@ #define TCLK (PCIE_BUS_CLK / 10) #define WATTMAM_SAMPLE_PERIOD msecs_to_jiffies(1000) +static int smu7_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uint32_t size); static const struct profile_mode_setting smu7_profiling[5] = {{1, 0, 100, 30, 1, 0, 100, 10}, {1, 10, 0, 30, 0, 0, 0, 0}, @@ -2792,6 +2793,19 @@ static int smu7_force_dpm_level(struct pp_hwmgr *hwmgr, ret = smu7_force_dpm_lowest(hwmgr); break; case AMD_DPM_FORCED_LEVEL_AUTO: + if (hwmgr->autowattman_enabled) { + if (hwmgr->hwmgr_func->start_auto_wattman != NULL) { + if (!cancel_delayed_work_sync(&hwmgr->wattman_update_work)) + hwmgr->hwmgr_func->start_auto_wattman(hwmgr, true); + } + } else { + if (hwmgr->default_power_profile_mode != hwmgr->power_profile_mode) { + long mode = hwmgr->default_power_profile_mode; + + smu7_set_power_profile_mode(hwmgr, &mode, 0); + } + + } ret = smu7_unforce_dpm_levels(hwmgr); break; case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD: @@ -2806,6 +2820,11 @@ static int smu7_force_dpm_level(struct pp_hwmgr *hwmgr, smu7_force_clock_level(hwmgr, PP_PCIE, 1<<pcie_mask); break; case AMD_DPM_FORCED_LEVEL_MANUAL: + if (hwmgr->autowattman_enabled) { + if (hwmgr->hwmgr_func->start_auto_wattman != NULL) + hwmgr->hwmgr_func->start_auto_wattman(hwmgr, false); + } + break; case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT: default: break; -- 1.9.1