Skip to content

Commit 9644bf5

Browse files
committed
drm/amdgpu/swSMU: handle manual AC/DC notifications
For boards that do not support automatic AC/DC transitions in firmware, manually tell the firmware when the status changes. Bug: https://gitlab.freedesktop.org/drm/amd/issues/1043 Reviewed-by: Evan Quan <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent f5cdd2b commit 9644bf5

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
9292
if (adev->powerplay.pp_funcs->enable_bapm)
9393
amdgpu_dpm_enable_bapm(adev, adev->pm.ac_power);
9494
mutex_unlock(&adev->pm.mutex);
95+
96+
if (is_support_sw_smu(adev))
97+
smu_set_ac_dc(&adev->smu);
9598
}
9699
}
97100

drivers/gpu/drm/amd/powerplay/amdgpu_smu.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,29 @@ int smu_set_watermarks_for_clock_ranges(struct smu_context *smu,
20872087
return 0;
20882088
}
20892089

2090+
int smu_set_ac_dc(struct smu_context *smu)
2091+
{
2092+
int ret = 0;
2093+
2094+
/* controlled by firmware */
2095+
if (smu->dc_controlled_by_gpio)
2096+
return 0;
2097+
2098+
mutex_lock(&smu->mutex);
2099+
if (smu->ppt_funcs->set_power_source) {
2100+
if (smu->adev->pm.ac_power)
2101+
ret = smu_set_power_source(smu, SMU_POWER_SOURCE_AC);
2102+
else
2103+
ret = smu_set_power_source(smu, SMU_POWER_SOURCE_DC);
2104+
if (ret)
2105+
pr_err("Failed to switch to %s mode!\n",
2106+
smu->adev->pm.ac_power ? "AC" : "DC");
2107+
}
2108+
mutex_unlock(&smu->mutex);
2109+
2110+
return ret;
2111+
}
2112+
20902113
const struct amd_ip_funcs smu_ip_funcs = {
20912114
.name = "smu",
20922115
.early_init = smu_early_init,

drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ int smu_get_dpm_level_range(struct smu_context *smu, enum smu_clk_type clk_type,
720720
enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu);
721721
int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_level level);
722722
int smu_set_display_count(struct smu_context *smu, uint32_t count);
723+
int smu_set_ac_dc(struct smu_context *smu);
723724
bool smu_clk_dpm_is_enabled(struct smu_context *smu, enum smu_clk_type clk_type);
724725
const char *smu_get_message_name(struct smu_context *smu, enum smu_message_type type);
725726
const char *smu_get_feature_name(struct smu_context *smu, enum smu_feature_mask feature);

0 commit comments

Comments
 (0)