<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>
<div>
<div>
<div>Can we hold on the code optimizations or code refactor until arcturus and renior stablized? The current code is already a little in chaos. We should not introduce more.</div>
<div><br>
</div>
<div style="direction:ltr">Regards,</div>
<div style="direction:ltr">Evan</div>
</div>
<div><br>
</div>
<div class="x_ms-outlook-ios-signature"></div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>发件人:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Wang, Kevin(Yang) <Kevin1.Wang@amd.com><br>
<b>发送时间:</b> Tuesday, August 20, 2019 3:55:01 PM<br>
<b>收件人:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>抄送:</b> Huang, Ray <Ray.Huang@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com><br>
<b>主题:</b> [PATCH] drm/amd/powerplay: add smu_map_helper function to unified map function</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:11pt;">
<div class="PlainText">1. add smu_map to replace old smu_11_0_cmn2aisc_mapping.<br>
(next generation of smu ip also need this logic, eg: smu12 13 14...)<br>
2. use smu_map_helper function to unified map code logic in smu<br>
<br>
Signed-off-by: Kevin Wang <kevin1.wang@amd.com><br>
---<br>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 19 ++++<br>
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 102 ++++--------------<br>
.../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 7 ++<br>
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 15 +--<br>
drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 97 ++++-------------<br>
drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 96 ++++-------------<br>
6 files changed, 86 insertions(+), 250 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
index 4df7fb6eaf3c..9e2a45ff23c4 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
@@ -56,6 +56,25 @@ const char *smu_get_feature_name(struct smu_context *smu, enum smu_feature_mask<br>
return __smu_feature_names[feature];<br>
}<br>
<br>
+int smu_map_helper(struct smu_context *smu, struct smu_map *map_src,<br>
+ uint32_t max_index, uint32_t index)<br>
+{<br>
+ struct smu_map *map = NULL;<br>
+<br>
+ if (!map_src)<br>
+ return -EINVAL;<br>
+<br>
+ if (index >= max_index)<br>
+ return -EINVAL;<br>
+<br>
+ map = &map_src[index];<br>
+ if (!map->valid)<br>
+ return -EINVAL;<br>
+<br>
+ return map->value;<br>
+}<br>
+<br>
+<br>
size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf)<br>
{<br>
size_t size = 0;<br>
diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
index 04a26072cf40..3416dcb5f40f 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
@@ -42,9 +42,9 @@<br>
#define CTF_OFFSET_HBM 5<br>
<br>
#define MSG_MAP(msg, index) \<br>
- [SMU_MSG_##msg] = {1, (index)}<br>
+ [SMU_MSG_##msg] = {true, (index)}<br>
#define ARCTURUS_FEA_MAP(smu_feature, arcturus_feature) \<br>
- [smu_feature] = {1, (arcturus_feature)}<br>
+ [smu_feature] = {true, (arcturus_feature)}<br>
<br>
#define SMU_FEATURES_LOW_MASK 0x00000000FFFFFFFF<br>
#define SMU_FEATURES_LOW_SHIFT 0<br>
@@ -63,7 +63,7 @@<br>
/* possible frequency drift (1Mhz) */<br>
#define EPSILON 1<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping arcturus_message_map[SMU_MSG_MAX_COUNT] = {<br>
+static struct smu_map arcturus_message_map[SMU_MSG_MAX_COUNT] = {<br>
MSG_MAP(TestMessage, PPSMC_MSG_TestMessage),<br>
MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion),<br>
MSG_MAP(GetDriverIfVersion, PPSMC_MSG_GetDriverIfVersion),<br>
@@ -123,7 +123,7 @@ static struct smu_11_0_cmn2aisc_mapping arcturus_message_map[SMU_MSG_MAX_COUNT]<br>
MSG_MAP(SetMemoryChannelEnable, PPSMC_MSG_SetMemoryChannelEnable),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping arcturus_clk_map[SMU_CLK_COUNT] = {<br>
+static struct smu_map arcturus_clk_map[SMU_CLK_COUNT] = {<br>
CLK_MAP(GFXCLK, PPCLK_GFXCLK),<br>
CLK_MAP(SCLK, PPCLK_GFXCLK),<br>
CLK_MAP(SOCCLK, PPCLK_SOCCLK),<br>
@@ -134,7 +134,7 @@ static struct smu_11_0_cmn2aisc_mapping arcturus_clk_map[SMU_CLK_COUNT] = {<br>
CLK_MAP(VCLK, PPCLK_VCLK),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping arcturus_feature_mask_map[SMU_FEATURE_COUNT] = {<br>
+static struct smu_map arcturus_feature_mask_map[SMU_FEATURE_COUNT] = {<br>
FEA_MAP(DPM_PREFETCHER),<br>
FEA_MAP(DPM_GFXCLK),<br>
FEA_MAP(DPM_UCLK),<br>
@@ -161,7 +161,7 @@ static struct smu_11_0_cmn2aisc_mapping arcturus_feature_mask_map[SMU_FEATURE_CO<br>
FEA_MAP(TEMP_DEPENDENT_VMIN),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping arcturus_table_map[SMU_TABLE_COUNT] = {<br>
+static struct smu_map arcturus_table_map[SMU_TABLE_COUNT] = {<br>
TAB_MAP(PPTABLE),<br>
TAB_MAP(AVFS),<br>
TAB_MAP(AVFS_PSM_DEBUG),<br>
@@ -172,12 +172,12 @@ static struct smu_11_0_cmn2aisc_mapping arcturus_table_map[SMU_TABLE_COUNT] = {<br>
TAB_MAP(OVERDRIVE),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping arcturus_pwr_src_map[SMU_POWER_SOURCE_COUNT] = {<br>
+static struct smu_map arcturus_pwr_src_map[SMU_POWER_SOURCE_COUNT] = {<br>
PWR_MAP(AC),<br>
PWR_MAP(DC),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping arcturus_workload_map[PP_SMC_POWER_PROFILE_COUNT] = {<br>
+static struct smu_map arcturus_workload_map[PP_SMC_POWER_PROFILE_COUNT] = {<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT, WORKLOAD_PPLIB_DEFAULT_BIT),<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_POWERSAVING, WORKLOAD_PPLIB_POWER_SAVING_BIT),<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_VIDEO, WORKLOAD_PPLIB_VIDEO_BIT),<br>
@@ -185,98 +185,34 @@ static struct smu_11_0_cmn2aisc_mapping arcturus_workload_map[PP_SMC_POWER_PROFI<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_CUSTOM, WORKLOAD_PPLIB_CUSTOM_BIT),<br>
};<br>
<br>
-static int arcturus_get_smu_msg_index(struct smu_context *smc, uint32_t index)<br>
+static int arcturus_get_smu_msg_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_MSG_MAX_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = arcturus_message_map[index];<br>
- if (!(mapping.valid_mapping))<br>
- return -EINVAL;<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, arcturus_message_map, SMU_MSG_MAX_COUNT, index);<br>
}<br>
<br>
-static int arcturus_get_smu_clk_index(struct smu_context *smc, uint32_t index)<br>
+static int arcturus_get_smu_clk_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_CLK_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = arcturus_clk_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- pr_warn("Unsupported SMU clk: %d\n", index);<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, arcturus_clk_map, SMU_CLK_COUNT, index);<br>
}<br>
<br>
-static int arcturus_get_smu_feature_index(struct smu_context *smc, uint32_t index)<br>
+static int arcturus_get_smu_feature_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_FEATURE_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = arcturus_feature_mask_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, arcturus_feature_mask_map, SMU_FEATURE_COUNT, index);<br>
}<br>
<br>
-static int arcturus_get_smu_table_index(struct smu_context *smc, uint32_t index)<br>
+static int arcturus_get_smu_table_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_TABLE_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = arcturus_table_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- pr_warn("Unsupported SMU table: %d\n", index);<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, arcturus_table_map, SMU_TABLE_COUNT, index);<br>
}<br>
<br>
-static int arcturus_get_pwr_src_index(struct smu_context *smc, uint32_t index)<br>
+static int arcturus_get_pwr_src_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_POWER_SOURCE_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = arcturus_pwr_src_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- pr_warn("Unsupported SMU power source: %d\n", index);<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, arcturus_pwr_src_map, SMU_POWER_SOURCE_COUNT, index);<br>
}<br>
<br>
-<br>
static int arcturus_get_workload_type(struct smu_context *smu, enum PP_SMC_POWER_PROFILE profile)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (profile > PP_SMC_POWER_PROFILE_CUSTOM)<br>
- return -EINVAL;<br>
-<br>
- mapping = arcturus_workload_map[profile];<br>
- if (!(mapping.valid_mapping)) {<br>
- pr_warn("Unsupported SMU power source: %d\n", profile);<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, arcturus_workload_map, PP_SMC_POWER_PROFILE_COUNT, (uint32_t)profile);<br>
}<br>
<br>
static int arcturus_tables_init(struct smu_context *smu, struct smu_table *tables)<br>
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
index fc59d9686e61..6404ad5249d4 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
@@ -206,6 +206,11 @@ struct smu_clock_info {<br>
uint32_t max_bus_bandwidth;<br>
};<br>
<br>
+struct smu_map {<br>
+ bool valid;<br>
+ int value;<br>
+};<br>
+<br>
struct smu_bios_boot_up_values<br>
{<br>
uint32_t revision;<br>
@@ -809,5 +814,7 @@ const char *smu_get_message_name(struct smu_context *smu, enum smu_message_type<br>
const char *smu_get_feature_name(struct smu_context *smu, enum smu_feature_mask feature);<br>
size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf);<br>
int smu_sys_set_pp_feature_mask(struct smu_context *smu, uint64_t new_mask);<br>
+int smu_map_helper(struct smu_context *smu, struct smu_map *map_src,<br>
+ uint32_t max_index, uint32_t index);<br>
<br>
#endif<br>
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h<br>
index acbb83d179be..ef59850b3fef 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h<br>
@@ -49,24 +49,19 @@<br>
#define SMU11_TOOL_SIZE 0x19000<br>
<br>
#define CLK_MAP(clk, index) \<br>
- [SMU_##clk] = {1, (index)}<br>
+ [SMU_##clk] = {true, (index)}<br>
<br>
#define FEA_MAP(fea) \<br>
- [SMU_FEATURE_##fea##_BIT] = {1, FEATURE_##fea##_BIT}<br>
+ [SMU_FEATURE_##fea##_BIT] = {true, FEATURE_##fea##_BIT}<br>
<br>
#define TAB_MAP(tab) \<br>
- [SMU_TABLE_##tab] = {1, TABLE_##tab}<br>
+ [SMU_TABLE_##tab] = {true, TABLE_##tab}<br>
<br>
#define PWR_MAP(tab) \<br>
- [SMU_POWER_SOURCE_##tab] = {1, POWER_SOURCE_##tab}<br>
+ [SMU_POWER_SOURCE_##tab] = {true, POWER_SOURCE_##tab}<br>
<br>
#define WORKLOAD_MAP(profile, workload) \<br>
- [profile] = {1, (workload)}<br>
-<br>
-struct smu_11_0_cmn2aisc_mapping {<br>
- int valid_mapping;<br>
- int map_to;<br>
-};<br>
+ [profile] = {true, (workload)}<br>
<br>
struct smu_11_0_max_sustainable_clocks {<br>
uint32_t display_clock;<br>
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
index 920156e9fb9d..9838beecec2e 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
@@ -49,9 +49,9 @@<br>
FEATURE_MASK(FEATURE_DPM_DCEFCLK_BIT))<br>
<br>
#define MSG_MAP(msg, index) \<br>
- [SMU_MSG_##msg] = {1, (index)}<br>
+ [SMU_MSG_##msg] = {true, (index)}<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping navi10_message_map[SMU_MSG_MAX_COUNT] = {<br>
+static struct smu_map navi10_message_map[SMU_MSG_MAX_COUNT] = {<br>
MSG_MAP(TestMessage, PPSMC_MSG_TestMessage),<br>
MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion),<br>
MSG_MAP(GetDriverIfVersion, PPSMC_MSG_GetDriverIfVersion),<br>
@@ -118,7 +118,7 @@ static struct smu_11_0_cmn2aisc_mapping navi10_message_map[SMU_MSG_MAX_COUNT] =<br>
MSG_MAP(ArmD3, PPSMC_MSG_ArmD3),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping navi10_clk_map[SMU_CLK_COUNT] = {<br>
+static struct smu_map navi10_clk_map[SMU_CLK_COUNT] = {<br>
CLK_MAP(GFXCLK, PPCLK_GFXCLK),<br>
CLK_MAP(SCLK, PPCLK_GFXCLK),<br>
CLK_MAP(SOCCLK, PPCLK_SOCCLK),<br>
@@ -133,7 +133,7 @@ static struct smu_11_0_cmn2aisc_mapping navi10_clk_map[SMU_CLK_COUNT] = {<br>
CLK_MAP(PHYCLK, PPCLK_PHYCLK),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping navi10_feature_mask_map[SMU_FEATURE_COUNT] = {<br>
+static struct smu_map navi10_feature_mask_map[SMU_FEATURE_COUNT] = {<br>
FEA_MAP(DPM_PREFETCHER),<br>
FEA_MAP(DPM_GFXCLK),<br>
FEA_MAP(DPM_GFX_PACE),<br>
@@ -178,7 +178,7 @@ static struct smu_11_0_cmn2aisc_mapping navi10_feature_mask_map[SMU_FEATURE_COUN<br>
FEA_MAP(ATHUB_PG),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping navi10_table_map[SMU_TABLE_COUNT] = {<br>
+static struct smu_map navi10_table_map[SMU_TABLE_COUNT] = {<br>
TAB_MAP(PPTABLE),<br>
TAB_MAP(WATERMARKS),<br>
TAB_MAP(AVFS),<br>
@@ -193,12 +193,12 @@ static struct smu_11_0_cmn2aisc_mapping navi10_table_map[SMU_TABLE_COUNT] = {<br>
TAB_MAP(PACE),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping navi10_pwr_src_map[SMU_POWER_SOURCE_COUNT] = {<br>
+static struct smu_map navi10_pwr_src_map[SMU_POWER_SOURCE_COUNT] = {<br>
PWR_MAP(AC),<br>
PWR_MAP(DC),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping navi10_workload_map[PP_SMC_POWER_PROFILE_COUNT] = {<br>
+static struct smu_map navi10_workload_map[PP_SMC_POWER_PROFILE_COUNT] = {<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT, WORKLOAD_PPLIB_DEFAULT_BIT),<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_FULLSCREEN3D, WORKLOAD_PPLIB_FULL_SCREEN_3D_BIT),<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_POWERSAVING, WORKLOAD_PPLIB_POWER_SAVING_BIT),<br>
@@ -208,95 +208,34 @@ static struct smu_11_0_cmn2aisc_mapping navi10_workload_map[PP_SMC_POWER_PROFILE<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_CUSTOM, WORKLOAD_PPLIB_CUSTOM_BIT),<br>
};<br>
<br>
-static int navi10_get_smu_msg_index(struct smu_context *smc, uint32_t index)<br>
+static int navi10_get_smu_msg_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index > SMU_MSG_MAX_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = navi10_message_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, navi10_message_map, SMU_MSG_MAX_COUNT, index);<br>
}<br>
<br>
-static int navi10_get_smu_clk_index(struct smu_context *smc, uint32_t index)<br>
+static int navi10_get_smu_clk_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_CLK_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = navi10_clk_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, navi10_clk_map, SMU_CLK_COUNT, index);<br>
}<br>
<br>
-static int navi10_get_smu_feature_index(struct smu_context *smc, uint32_t index)<br>
+static int navi10_get_smu_feature_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_FEATURE_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = navi10_feature_mask_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, navi10_feature_mask_map, SMU_FEATURE_COUNT, index);<br>
}<br>
<br>
-static int navi10_get_smu_table_index(struct smu_context *smc, uint32_t index)<br>
+static int navi10_get_smu_table_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_TABLE_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = navi10_table_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, navi10_table_map, SMU_TABLE_COUNT, index);<br>
}<br>
<br>
-static int navi10_get_pwr_src_index(struct smu_context *smc, uint32_t index)<br>
+static int navi10_get_pwr_src_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_POWER_SOURCE_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = navi10_pwr_src_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, navi10_pwr_src_map, SMU_POWER_SOURCE_COUNT, index);<br>
}<br>
<br>
-<br>
static int navi10_get_workload_type(struct smu_context *smu, enum PP_SMC_POWER_PROFILE profile)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (profile > PP_SMC_POWER_PROFILE_CUSTOM)<br>
- return -EINVAL;<br>
-<br>
- mapping = navi10_workload_map[profile];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, navi10_workload_map, PP_SMC_POWER_PROFILE_COUNT, (uint32_t)profile);<br>
}<br>
<br>
static bool is_asic_secure(struct smu_context *smu)<br>
diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c<br>
index acf075393c13..6162be25b6d2 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c<br>
@@ -47,7 +47,7 @@<br>
#define CTF_OFFSET_HBM 5<br>
<br>
#define MSG_MAP(msg) \<br>
- [SMU_MSG_##msg] = {1, PPSMC_MSG_##msg}<br>
+ [SMU_MSG_##msg] = {true, PPSMC_MSG_##msg}<br>
<br>
#define SMC_DPM_FEATURE (FEATURE_DPM_PREFETCHER_MASK | \<br>
FEATURE_DPM_GFXCLK_MASK | \<br>
@@ -59,7 +59,7 @@<br>
FEATURE_DPM_LINK_MASK | \<br>
FEATURE_DPM_DCEFCLK_MASK)<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping vega20_message_map[SMU_MSG_MAX_COUNT] = {<br>
+static struct smu_map vega20_message_map[SMU_MSG_MAX_COUNT] = {<br>
MSG_MAP(TestMessage),<br>
MSG_MAP(GetSmuVersion),<br>
MSG_MAP(GetDriverIfVersion),<br>
@@ -145,7 +145,7 @@ static struct smu_11_0_cmn2aisc_mapping vega20_message_map[SMU_MSG_MAX_COUNT] =<br>
MSG_MAP(GetAVFSVoltageByDpm),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping vega20_clk_map[SMU_CLK_COUNT] = {<br>
+static struct smu_map vega20_clk_map[SMU_CLK_COUNT] = {<br>
CLK_MAP(GFXCLK, PPCLK_GFXCLK),<br>
CLK_MAP(VCLK, PPCLK_VCLK),<br>
CLK_MAP(DCLK, PPCLK_DCLK),<br>
@@ -159,7 +159,7 @@ static struct smu_11_0_cmn2aisc_mapping vega20_clk_map[SMU_CLK_COUNT] = {<br>
CLK_MAP(FCLK, PPCLK_FCLK),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping vega20_feature_mask_map[SMU_FEATURE_COUNT] = {<br>
+static struct smu_map vega20_feature_mask_map[SMU_FEATURE_COUNT] = {<br>
FEA_MAP(DPM_PREFETCHER),<br>
FEA_MAP(DPM_GFXCLK),<br>
FEA_MAP(DPM_UCLK),<br>
@@ -195,7 +195,7 @@ static struct smu_11_0_cmn2aisc_mapping vega20_feature_mask_map[SMU_FEATURE_COUN<br>
FEA_MAP(XGMI),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping vega20_table_map[SMU_TABLE_COUNT] = {<br>
+static struct smu_map vega20_table_map[SMU_TABLE_COUNT] = {<br>
TAB_MAP(PPTABLE),<br>
TAB_MAP(WATERMARKS),<br>
TAB_MAP(AVFS),<br>
@@ -208,12 +208,12 @@ static struct smu_11_0_cmn2aisc_mapping vega20_table_map[SMU_TABLE_COUNT] = {<br>
TAB_MAP(OVERDRIVE),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping vega20_pwr_src_map[SMU_POWER_SOURCE_COUNT] = {<br>
+static struct smu_map vega20_pwr_src_map[SMU_POWER_SOURCE_COUNT] = {<br>
PWR_MAP(AC),<br>
PWR_MAP(DC),<br>
};<br>
<br>
-static struct smu_11_0_cmn2aisc_mapping vega20_workload_map[PP_SMC_POWER_PROFILE_COUNT] = {<br>
+static struct smu_map vega20_workload_map[PP_SMC_POWER_PROFILE_COUNT] = {<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT, WORKLOAD_DEFAULT_BIT),<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_FULLSCREEN3D, WORKLOAD_PPLIB_FULL_SCREEN_3D_BIT),<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_POWERSAVING, WORKLOAD_PPLIB_POWER_SAVING_BIT),<br>
@@ -223,94 +223,34 @@ static struct smu_11_0_cmn2aisc_mapping vega20_workload_map[PP_SMC_POWER_PROFILE<br>
WORKLOAD_MAP(PP_SMC_POWER_PROFILE_CUSTOM, WORKLOAD_PPLIB_CUSTOM_BIT),<br>
};<br>
<br>
-static int vega20_get_smu_table_index(struct smu_context *smc, uint32_t index)<br>
+static int vega20_get_smu_table_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_TABLE_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = vega20_table_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, vega20_table_map, SMU_TABLE_COUNT, index);<br>
}<br>
<br>
-static int vega20_get_pwr_src_index(struct smu_context *smc, uint32_t index)<br>
+static int vega20_get_pwr_src_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_POWER_SOURCE_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = vega20_pwr_src_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, vega20_pwr_src_map, SMU_POWER_SOURCE_COUNT, index);<br>
}<br>
<br>
-static int vega20_get_smu_feature_index(struct smu_context *smc, uint32_t index)<br>
+static int vega20_get_smu_feature_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_FEATURE_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = vega20_feature_mask_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, vega20_feature_mask_map, SMU_FEATURE_COUNT, index);<br>
}<br>
<br>
-static int vega20_get_smu_clk_index(struct smu_context *smc, uint32_t index)<br>
+static int vega20_get_smu_clk_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_CLK_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = vega20_clk_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, vega20_clk_map, SMU_CLK_COUNT, index);<br>
}<br>
<br>
-static int vega20_get_smu_msg_index(struct smu_context *smc, uint32_t index)<br>
+static int vega20_get_smu_msg_index(struct smu_context *smu, uint32_t index)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (index >= SMU_MSG_MAX_COUNT)<br>
- return -EINVAL;<br>
-<br>
- mapping = vega20_message_map[index];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, vega20_message_map, SMU_MSG_MAX_COUNT, index);<br>
}<br>
<br>
static int vega20_get_workload_type(struct smu_context *smu, enum PP_SMC_POWER_PROFILE profile)<br>
{<br>
- struct smu_11_0_cmn2aisc_mapping mapping;<br>
-<br>
- if (profile > PP_SMC_POWER_PROFILE_CUSTOM)<br>
- return -EINVAL;<br>
-<br>
- mapping = vega20_workload_map[profile];<br>
- if (!(mapping.valid_mapping)) {<br>
- return -EINVAL;<br>
- }<br>
-<br>
- return mapping.map_to;<br>
+ return smu_map_helper(smu, vega20_workload_map, PP_SMC_POWER_PROFILE_COUNT, (uint32_t)profile);<br>
}<br>
<br>
static int vega20_tables_init(struct smu_context *smu, struct smu_table *tables)<br>
-- <br>
2.22.0<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></div>
</span></font>
</body>
</html>