Skip to content

Commit c81a3ce

Browse files
committed
drm/amdgpu/pm/swsmu: implement pause workload profile
Add the callback for implementation for swsmu. Reviewed-by: Kenneth Feng <kenneth.feng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 92e511d)
1 parent 7f991dd commit c81a3ce

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,11 @@ static int smu_switch_power_profile(void *handle,
23982398
smu_power_profile_mode_get(smu, type);
23992399
else
24002400
smu_power_profile_mode_put(smu, type);
2401-
ret = smu_bump_power_profile_mode(smu, NULL, 0);
2401+
/* don't switch the active workload when paused */
2402+
if (smu->pause_workload)
2403+
ret = 0;
2404+
else
2405+
ret = smu_bump_power_profile_mode(smu, NULL, 0);
24022406
if (ret) {
24032407
if (enable)
24042408
smu_power_profile_mode_put(smu, type);
@@ -2411,6 +2415,35 @@ static int smu_switch_power_profile(void *handle,
24112415
return 0;
24122416
}
24132417

2418+
static int smu_pause_power_profile(void *handle,
2419+
bool pause)
2420+
{
2421+
struct smu_context *smu = handle;
2422+
struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
2423+
u32 workload_mask = 1 << PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
2424+
int ret;
2425+
2426+
if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2427+
return -EOPNOTSUPP;
2428+
2429+
if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL &&
2430+
smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM) {
2431+
smu->pause_workload = pause;
2432+
2433+
/* force to bootup default profile */
2434+
if (smu->pause_workload && smu->ppt_funcs->set_power_profile_mode)
2435+
ret = smu->ppt_funcs->set_power_profile_mode(smu,
2436+
workload_mask,
2437+
NULL,
2438+
0);
2439+
else
2440+
ret = smu_bump_power_profile_mode(smu, NULL, 0);
2441+
return ret;
2442+
}
2443+
2444+
return 0;
2445+
}
2446+
24142447
static enum amd_dpm_forced_level smu_get_performance_level(void *handle)
24152448
{
24162449
struct smu_context *smu = handle;
@@ -3733,6 +3766,7 @@ static const struct amd_pm_funcs swsmu_pm_funcs = {
37333766
.get_pp_table = smu_sys_get_pp_table,
37343767
.set_pp_table = smu_sys_set_pp_table,
37353768
.switch_power_profile = smu_switch_power_profile,
3769+
.pause_power_profile = smu_pause_power_profile,
37363770
/* export to amdgpu */
37373771
.dispatch_tasks = smu_handle_dpm_task,
37383772
.load_firmware = smu_load_microcode,

drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ struct smu_context {
558558

559559
/* asic agnostic workload mask */
560560
uint32_t workload_mask;
561+
bool pause_workload;
561562
/* default/user workload preference */
562563
uint32_t power_profile_mode;
563564
uint32_t workload_refcount[PP_SMC_POWER_PROFILE_COUNT];

0 commit comments

Comments
 (0)