Skip to contentSkip to conversation

drm/amd/powerplay: add smu_map_helper function to unified map function

PATCH In review Wang, Kevin(Yang) 2 participants 2 messages Aug 20, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/powerplay: add smu_map_helper function to unified map function

1. add smu_map to replace old smu_11_0_cmn2aisc_mapping. (next generation of smu ip also need this logic, eg: smu12 13 14...)
2. use smu_map_helper function to unified map code logic in smu

---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c    |  19 ++++
 drivers/gpu/drm/amd/powerplay/arcturus_ppt.c  | 102 ++++--------------
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |   7 ++
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h |  15 +--
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  97 ++++-------------
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c    |  96 ++++-------------
 6 files changed, 86 insertions(+), 250 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +19 -0
index 4df7fb6eaf3c..9e2a45ff23c4 100644
@@ -56,6 +56,25 @@ const char *smu_get_feature_name(struct smu_context *smu, enum smu_feature_mask
 	return __smu_feature_names[feature];
 }
 
+int smu_map_helper(struct smu_context *smu, struct smu_map *map_src,
+		   uint32_t max_index, uint32_t index)
+{
+	struct smu_map *map = NULL;
+
+	if (!map_src)
+		return -EINVAL;
+
+	if (index >= max_index)
+		return -EINVAL;
+
+	map = &map_src[index];
+	if (!map->valid)
+		return -EINVAL;
+
+	return map->value;
+}
+
+
 size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf)
 {
 	size_t size = 0;
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c +19 -83

166 lines not on this page · raw message

drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +7 -0
index fc59d9686e61..6404ad5249d4 100644
@@ -206,6 +206,11 @@ struct smu_clock_info {
 	uint32_t max_bus_bandwidth;
 };
 
+struct smu_map {
+	bool valid;
+	int value;
+};
+
 struct smu_bios_boot_up_values
 {
 	uint32_t			revision;
@@ -809,5 +814,7 @@ const char *smu_get_message_name(struct smu_context *smu, enum smu_message_type
 const char *smu_get_feature_name(struct smu_context *smu, enum smu_feature_mask feature);
 size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf);
 int smu_sys_set_pp_feature_mask(struct smu_context *smu, uint64_t new_mask);
+int smu_map_helper(struct smu_context *smu, struct smu_map *map_src,
+		   uint32_t max_index, uint32_t index);
 
 #endif
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +5 -10
index acbb83d179be..ef59850b3fef 100644
@@ -49,24 +49,19 @@
 #define SMU11_TOOL_SIZE			0x19000
 
 #define CLK_MAP(clk, index) \
-	[SMU_##clk] = {1, (index)}
+	[SMU_##clk] = {true, (index)}
 
 #define FEA_MAP(fea) \
-	[SMU_FEATURE_##fea##_BIT] = {1, FEATURE_##fea##_BIT}
+	[SMU_FEATURE_##fea##_BIT] = {true, FEATURE_##fea##_BIT}
 
 #define TAB_MAP(tab) \
-	[SMU_TABLE_##tab] = {1, TABLE_##tab}
+	[SMU_TABLE_##tab] = {true, TABLE_##tab}
 
 #define PWR_MAP(tab) \
-	[SMU_POWER_SOURCE_##tab] = {1, POWER_SOURCE_##tab}
+	[SMU_POWER_SOURCE_##tab] = {true, POWER_SOURCE_##tab}
 
 #define WORKLOAD_MAP(profile, workload) \
-	[profile] = {1, (workload)}
-
-struct smu_11_0_cmn2aisc_mapping {
-	int	valid_mapping;
-	int	map_to;
-};
+	[profile] = {true, (workload)}
 
 struct smu_11_0_max_sustainable_clocks {
 	uint32_t display_clock;
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +18 -79

155 lines not on this page · raw message

drivers/gpu/drm/amd/powerplay/vega20_ppt.c +18 -78

159 lines not on this page · raw message

Signature · 6 lines
2.22.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

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.

Regards,
Evan

________________________________
发件人: amd-gfx <[email protected]> 代表 Wang, Kevin(Yang) <[email protected]> 发送时间: Tuesday, August 20, 2019 3:55:01 PM
收件人: [email protected] <[email protected]>
抄送: Huang, Ray <[email protected]>; Wang, Kevin(Yang) <[email protected]>
主题: [PATCH] drm/amd/powerplay: add smu_map_helper function to unified map function

1. add smu_map to replace old smu_11_0_cmn2aisc_mapping. (next generation of smu ip also need this logic, eg: smu12 13 14...)
2. use smu_map_helper function to unified map code logic in smu

---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c    |  19 ++++
 drivers/gpu/drm/amd/powerplay/arcturus_ppt.c  | 102 ++++--------------
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |   7 ++
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h |  15 +--
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  97 ++++-------------
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c    |  96 ++++-------------
 6 files changed, 86 insertions(+), 250 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +19 -0
index 4df7fb6eaf3c..9e2a45ff23c4 100644
@@ -56,6 +56,25 @@ const char *smu_get_feature_name(struct smu_context *smu, enum smu_feature_mask
         return __smu_feature_names[feature];
 }
 
+int smu_map_helper(struct smu_context *smu, struct smu_map *map_src,
+                  uint32_t max_index, uint32_t index)
+{
+       struct smu_map *map = NULL;
+
+       if (!map_src)
+               return -EINVAL;
+
+       if (index >= max_index)
+               return -EINVAL;
+
+       map = &map_src[index];
+       if (!map->valid)
+               return -EINVAL;
+
+       return map->value;
+}
+
+
 size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf)
 {
         size_t size = 0;
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c +19 -83

166 lines not on this page · raw message

drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +7 -0
index fc59d9686e61..6404ad5249d4 100644
@@ -206,6 +206,11 @@ struct smu_clock_info {
         uint32_t max_bus_bandwidth;
 };
 
+struct smu_map {
+       bool valid;
+       int value;
+};
+
 struct smu_bios_boot_up_values
 {
         uint32_t                        revision;
@@ -809,5 +814,7 @@ const char *smu_get_message_name(struct smu_context *smu, enum smu_message_type
 const char *smu_get_feature_name(struct smu_context *smu, enum smu_feature_mask feature);
 size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf);
 int smu_sys_set_pp_feature_mask(struct smu_context *smu, uint64_t new_mask);
+int smu_map_helper(struct smu_context *smu, struct smu_map *map_src,
+                  uint32_t max_index, uint32_t index);
 
 #endif
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +5 -10
index acbb83d179be..ef59850b3fef 100644
@@ -49,24 +49,19 @@
 #define SMU11_TOOL_SIZE                 0x19000
 
 #define CLK_MAP(clk, index) \
-       [SMU_##clk] = {1, (index)}
+       [SMU_##clk] = {true, (index)}
 
 #define FEA_MAP(fea) \
-       [SMU_FEATURE_##fea##_BIT] = {1, FEATURE_##fea##_BIT}
+       [SMU_FEATURE_##fea##_BIT] = {true, FEATURE_##fea##_BIT}
 
 #define TAB_MAP(tab) \
-       [SMU_TABLE_##tab] = {1, TABLE_##tab}
+       [SMU_TABLE_##tab] = {true, TABLE_##tab}
 
 #define PWR_MAP(tab) \
-       [SMU_POWER_SOURCE_##tab] = {1, POWER_SOURCE_##tab}
+       [SMU_POWER_SOURCE_##tab] = {true, POWER_SOURCE_##tab}
 
 #define WORKLOAD_MAP(profile, workload) \
-       [profile] = {1, (workload)}
-
-struct smu_11_0_cmn2aisc_mapping {
-       int     valid_mapping;
-       int     map_to;
-};
+       [profile] = {true, (workload)}
 
 struct smu_11_0_max_sustainable_clocks {
         uint32_t display_clock;
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +18 -79

155 lines not on this page · raw message

drivers/gpu/drm/amd/powerplay/vega20_ppt.c +18 -78

159 lines not on this page · raw message

--
2.22.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx