drm/amd/powerplay: enable Arcturus runtime VCN dpm on/off
authorEvan Quan <evan.quan@amd.com>
Thu, 10 Oct 2019 08:42:31 +0000 (16:42 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 15 Oct 2019 19:50:43 +0000 (15:50 -0400)
Enable runtime VCN DPM on/off on Arcturus.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c

index 0d5c95d73b636153118fca9f7a3dfb61afef9a00..b3623ed3dc42f9f446adb3ce4ef391ce6a9003c7 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "amdgpu.h"
 #include "amdgpu_vcn.h"
+#include "amdgpu_pm.h"
 #include "soc15.h"
 #include "soc15d.h"
 #include "vcn_v2_0.h"
@@ -709,6 +710,9 @@ static int vcn_v2_5_start(struct amdgpu_device *adev)
        uint32_t rb_bufsz, tmp;
        int i, j, k, r;
 
+       if (adev->pm.dpm_enabled)
+               amdgpu_dpm_enable_uvd(adev, true);
+
        for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
                if (adev->vcn.harvest_config & (1 << i))
                        continue;
@@ -939,6 +943,9 @@ static int vcn_v2_5_stop(struct amdgpu_device *adev)
                        ~UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
        }
 
+       if (adev->pm.dpm_enabled)
+               amdgpu_dpm_enable_uvd(adev, false);
+
        return 0;
 }
 
index b9b7b73354a0e9acad7a73784c80efbe0fe3ceac..90d871af8e58c8b2b7213fc091437ea7a4d0b365 100644 (file)
@@ -1898,6 +1898,35 @@ static bool arcturus_is_dpm_running(struct smu_context *smu)
        return !!(feature_enabled & SMC_DPM_FEATURE);
 }
 
+static int arcturus_dpm_set_uvd_enable(struct smu_context *smu, bool enable)
+{
+       struct smu_power_context *smu_power = &smu->smu_power;
+       struct smu_power_gate *power_gate = &smu_power->power_gate;
+       int ret = 0;
+
+       if (enable) {
+               if (!smu_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) {
+                       ret = smu_feature_set_enabled(smu, SMU_FEATURE_VCN_PG_BIT, 1);
+                       if (ret) {
+                               pr_err("[EnableVCNDPM] failed!\n");
+                               return ret;
+                       }
+               }
+               power_gate->vcn_gated = false;
+       } else {
+               if (smu_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) {
+                       ret = smu_feature_set_enabled(smu, SMU_FEATURE_VCN_PG_BIT, 0);
+                       if (ret) {
+                               pr_err("[DisableVCNDPM] failed!\n");
+                               return ret;
+                       }
+               }
+               power_gate->vcn_gated = true;
+       }
+
+       return ret;
+}
+
 static const struct pptable_funcs arcturus_ppt_funcs = {
        /* translate smu index into arcturus specific index */
        .get_smu_msg_index = arcturus_get_smu_msg_index,
@@ -1936,6 +1965,7 @@ static const struct pptable_funcs arcturus_ppt_funcs = {
        .dump_pptable = arcturus_dump_pptable,
        .get_power_limit = arcturus_get_power_limit,
        .is_dpm_running = arcturus_is_dpm_running,
+       .dpm_set_uvd_enable = arcturus_dpm_set_uvd_enable,
 };
 
 void arcturus_set_ppt_funcs(struct smu_context *smu)