drm/amdgpu/swSMU: handle manual AC/DC notifications
authorAlex Deucher <alexander.deucher@amd.com>
Fri, 20 Mar 2020 17:03:12 +0000 (13:03 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 25 Mar 2020 21:00:11 +0000 (17:00 -0400)
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 <evan.quan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h

index bc3cf04a1a94a7813c300dc855ce309166b73f6e..f197f1be0969045743a2198d7fb79d70a7d437bc 100644 (file)
@@ -92,6 +92,9 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
                if (adev->powerplay.pp_funcs->enable_bapm)
                        amdgpu_dpm_enable_bapm(adev, adev->pm.ac_power);
                mutex_unlock(&adev->pm.mutex);
+
+               if (is_support_sw_smu(adev))
+                       smu_set_ac_dc(&adev->smu);
        }
 }
 
index 9a9eb23d8540377304ae41737fae75868d1cb9f5..e8b27fab6aa1d3eb66aa470942910c807e1fa22f 100644 (file)
@@ -2087,6 +2087,29 @@ int smu_set_watermarks_for_clock_ranges(struct smu_context *smu,
        return 0;
 }
 
+int smu_set_ac_dc(struct smu_context *smu)
+{
+       int ret = 0;
+
+       /* controlled by firmware */
+       if (smu->dc_controlled_by_gpio)
+               return 0;
+
+       mutex_lock(&smu->mutex);
+       if (smu->ppt_funcs->set_power_source) {
+               if (smu->adev->pm.ac_power)
+                       ret = smu_set_power_source(smu, SMU_POWER_SOURCE_AC);
+               else
+                       ret = smu_set_power_source(smu, SMU_POWER_SOURCE_DC);
+               if (ret)
+                       pr_err("Failed to switch to %s mode!\n",
+                              smu->adev->pm.ac_power ? "AC" : "DC");
+       }
+       mutex_unlock(&smu->mutex);
+
+       return ret;
+}
+
 const struct amd_ip_funcs smu_ip_funcs = {
        .name = "smu",
        .early_init = smu_early_init,
index 18172dfec947cf76f2ce2fc773e17162fac73143..ae2c318dd6fac4d8b6fb5de077d6f5d7b33778dd 100644 (file)
@@ -720,6 +720,7 @@ int smu_get_dpm_level_range(struct smu_context *smu, enum smu_clk_type clk_type,
 enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu);
 int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_level level);
 int smu_set_display_count(struct smu_context *smu, uint32_t count);
+int smu_set_ac_dc(struct smu_context *smu);
 bool smu_clk_dpm_is_enabled(struct smu_context *smu, enum smu_clk_type clk_type);
 const char *smu_get_message_name(struct smu_context *smu, enum smu_message_type type);
 const char *smu_get_feature_name(struct smu_context *smu, enum smu_feature_mask feature);