aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3257-drm-amd-powerplay-support-power-profile-retrieval-an.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3257-drm-amd-powerplay-support-power-profile-retrieval-an.patch')
-rw-r--r--meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3257-drm-amd-powerplay-support-power-profile-retrieval-an.patch110
1 files changed, 110 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3257-drm-amd-powerplay-support-power-profile-retrieval-an.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3257-drm-amd-powerplay-support-power-profile-retrieval-an.patch
new file mode 100644
index 00000000..a7a16404
--- /dev/null
+++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3257-drm-amd-powerplay-support-power-profile-retrieval-an.patch
@@ -0,0 +1,110 @@
+From 4993641cd36b5e471eca37904359b2bbf52867bf Mon Sep 17 00:00:00 2001
+From: Evan Quan <evan.quan@amd.com>
+Date: Mon, 29 Jul 2019 15:17:27 +0800
+Subject: [PATCH 3257/4256] drm/amd/powerplay: support power profile retrieval
+ and setting on arcturus
+
+Enable arcturus power profile retrieval and setting.
+
+Change-Id: I85447ba9ca7de8e197840f76ce3745363c4133a6
+Signed-off-by: Evan Quan <evan.quan@amd.com>
+Reviewed-by: Kevin Wang <kevin1.wang@amd.com>
+---
+ drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 74 ++++++++++++++++++++
+ 1 file changed, 74 insertions(+)
+
+diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
+index c9145c190d9f..bf373d5b0e38 100644
+--- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
++++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
+@@ -1373,6 +1373,78 @@ static int arcturus_get_power_limit(struct smu_context *smu,
+ return 0;
+ }
+
++static int arcturus_get_power_profile_mode(struct smu_context *smu,
++ char *buf)
++{
++ static const char *profile_name[] = {
++ "BOOTUP_DEFAULT",
++ "3D_FULL_SCREEN",
++ "POWER_SAVING",
++ "VIDEO",
++ "VR",
++ "COMPUTE",
++ "CUSTOM"};
++ uint32_t i, size = 0;
++ int16_t workload_type = 0;
++
++ if (!smu->pm_enabled || !buf)
++ return -EINVAL;
++
++ for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) {
++ /*
++ * Conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT
++ * Not all profile modes are supported on arcturus.
++ */
++ workload_type = smu_workload_get_type(smu, i);
++ if (workload_type < 0)
++ continue;
++
++ size += sprintf(buf + size, "%2d %14s%s\n",
++ i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " ");
++ }
++
++ return size;
++}
++
++static int arcturus_set_power_profile_mode(struct smu_context *smu,
++ long *input,
++ uint32_t size)
++{
++ int workload_type = 0;
++ uint32_t profile_mode = input[size];
++ int ret = 0;
++
++ if (!smu->pm_enabled)
++ return -EINVAL;
++
++ if (profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) {
++ pr_err("Invalid power profile mode %d\n", profile_mode);
++ return -EINVAL;
++ }
++
++ /*
++ * Conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT
++ * Not all profile modes are supported on arcturus.
++ */
++ workload_type = smu_workload_get_type(smu, profile_mode);
++ if (workload_type < 0) {
++ pr_err("Unsupported power profile mode %d on arcturus\n", profile_mode);
++ return -EINVAL;
++ }
++
++ ret = smu_send_smc_msg_with_param(smu,
++ SMU_MSG_SetWorkloadMask,
++ 1 << workload_type);
++ if (ret) {
++ pr_err("Fail to set workload type %d\n", workload_type);
++ return ret;
++ }
++
++ smu->power_profile_mode = profile_mode;
++
++ return 0;
++}
++
+ static void arcturus_dump_pptable(struct smu_context *smu)
+ {
+ struct smu_table_context *table_context = &smu->smu_table;
+@@ -1836,6 +1908,8 @@ static const struct pptable_funcs arcturus_ppt_funcs = {
+ .force_dpm_limit_value = arcturus_force_dpm_limit_value,
+ .unforce_dpm_levels = arcturus_unforce_dpm_levels,
+ .get_profiling_clk_mask = arcturus_get_profiling_clk_mask,
++ .get_power_profile_mode = arcturus_get_power_profile_mode,
++ .set_power_profile_mode = arcturus_set_power_profile_mode,
+ /* debug (internal used) */
+ .dump_pptable = arcturus_dump_pptable,
+ .get_power_limit = arcturus_get_power_limit,
+--
+2.17.1
+