<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:11pt;color:#0078D7;margin:5pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Kevin Wang <kevin1.wang@amd.com><br>
<b>Sent:</b> Wednesday, February 3, 2021 4:29 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Wang, Kevin(Yang) <Kevin1.Wang@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/pm/swsmu: unify the init soft gpu metrics function</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">the soft gpu metrics is not asic related data structure.<br>
unify them to reduce duplicate code.<br>
<br>
Signed-off-by: Kevin Wang <kevin1.wang@amd.com><br>
---<br>
drivers/gpu/drm/amd/pm/inc/smu_v11_0.h | 4 ---<br>
drivers/gpu/drm/amd/pm/inc/smu_v12_0.h | 2 --<br>
.../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 4 ++-<br>
.../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 4 ++-<br>
.../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 4 ++-<br>
.../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 24 ------------------<br>
.../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 4 ++-<br>
.../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c | 4 ++-<br>
.../gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c | 12 ---------<br>
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 25 +++++++++++++++++++<br>
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 2 ++<br>
11 files changed, 42 insertions(+), 47 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h<br>
index c7d57e9555cc..e49c2d08a983 100644<br>
--- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h<br>
+++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h<br>
@@ -272,10 +272,6 @@ int smu_v11_0_get_current_pcie_link_speed_level(struct smu_context *smu);<br>
<br>
int smu_v11_0_get_current_pcie_link_speed(struct smu_context *smu);<br>
<br>
-void smu_v11_0_init_gpu_metrics_v1_0(struct gpu_metrics_v1_0 *gpu_metrics);<br>
-<br>
-void smu_v11_0_init_gpu_metrics_v2_0(struct gpu_metrics_v2_0 *gpu_metrics);<br>
-<br>
int smu_v11_0_gfx_ulv_control(struct smu_context *smu,<br>
bool enablement);<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v12_0.h b/drivers/gpu/drm/amd/pm/inc/smu_v12_0.h<br>
index fa2e8cb07967..02de3b6199e5 100644<br>
--- a/drivers/gpu/drm/amd/pm/inc/smu_v12_0.h<br>
+++ b/drivers/gpu/drm/amd/pm/inc/smu_v12_0.h<br>
@@ -60,7 +60,5 @@ int smu_v12_0_set_soft_freq_limited_range(struct smu_context *smu, enum smu_clk_<br>
<br>
int smu_v12_0_set_driver_table_location(struct smu_context *smu);<br>
<br>
-void smu_v12_0_init_gpu_metrics_v2_0(struct gpu_metrics_v2_0 *gpu_metrics);<br>
-<br>
#endif<br>
#endif<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c<br>
index f0cc4de9ced5..45564a776e9b 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c<br>
@@ -2239,7 +2239,7 @@ static ssize_t arcturus_get_gpu_metrics(struct smu_context *smu,<br>
if (ret)<br>
return ret;<br>
<br>
- smu_v11_0_init_gpu_metrics_v1_0(gpu_metrics);<br>
+ smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 0);<br>
<br>
gpu_metrics->temperature_edge = metrics.TemperatureEdge;<br>
gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;<br>
@@ -2276,6 +2276,8 @@ static ssize_t arcturus_get_gpu_metrics(struct smu_context *smu,<br>
gpu_metrics->pcie_link_speed =<br>
arcturus_get_current_pcie_link_speed(smu);<br>
<br>
+ gpu_metrics->system_clock_counter = ktime_get_boottime_ns();<br>
+<br>
*table = (void *)gpu_metrics;<br>
<br>
return sizeof(struct gpu_metrics_v1_0);<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c<br>
index f7f78daffd27..6e641f1513d8 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c<br>
@@ -2314,7 +2314,7 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,<br>
<br>
mutex_unlock(&smu->metrics_lock);<br>
<br>
- smu_v11_0_init_gpu_metrics_v1_0(gpu_metrics);<br>
+ smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 0);<br>
<br>
gpu_metrics->temperature_edge = metrics.TemperatureEdge;<br>
gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;<br>
@@ -2354,6 +2354,8 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,<br>
gpu_metrics->pcie_link_speed =<br>
smu_v11_0_get_current_pcie_link_speed(smu);<br>
<br>
+ gpu_metrics->system_clock_counter = ktime_get_boottime_ns();<br>
+<br>
*table = (void *)gpu_metrics;<br>
<br>
return sizeof(struct gpu_metrics_v1_0);<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c<br>
index e3ba40d9f83f..34add528d83c 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c<br>
@@ -2950,7 +2950,7 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,<br>
if (ret)<br>
return ret;<br>
<br>
- smu_v11_0_init_gpu_metrics_v1_0(gpu_metrics);<br>
+ smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 0);<br>
<br>
gpu_metrics->temperature_edge = metrics->TemperatureEdge;<br>
gpu_metrics->temperature_hotspot = metrics->TemperatureHotspot;<br>
@@ -2993,6 +2993,8 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,<br>
gpu_metrics->pcie_link_speed =<br>
smu_v11_0_get_current_pcie_link_speed(smu);<br>
<br>
+ gpu_metrics->system_clock_counter = ktime_get_boottime_ns();<br>
+<br>
*table = (void *)gpu_metrics;<br>
<br>
return sizeof(struct gpu_metrics_v1_0);<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c<br>
index cf6176afd4d5..36d651342a76 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c<br>
@@ -2021,30 +2021,6 @@ int smu_v11_0_get_current_pcie_link_speed(struct smu_context *smu)<br>
return link_speed[speed_level];<br>
}<br>
<br>
-void smu_v11_0_init_gpu_metrics_v1_0(struct gpu_metrics_v1_0 *gpu_metrics)<br>
-{<br>
- memset(gpu_metrics, 0xFF, sizeof(struct gpu_metrics_v1_0));<br>
-<br>
- gpu_metrics->common_header.structure_size =<br>
- sizeof(struct gpu_metrics_v1_0);<br>
- gpu_metrics->common_header.format_revision = 1;<br>
- gpu_metrics->common_header.content_revision = 0;<br>
-<br>
- gpu_metrics->system_clock_counter = ktime_get_boottime_ns();<br>
-}<br>
-<br>
-void smu_v11_0_init_gpu_metrics_v2_0(struct gpu_metrics_v2_0 *gpu_metrics)<br>
-{<br>
- memset(gpu_metrics, 0xFF, sizeof(struct gpu_metrics_v2_0));<br>
-<br>
- gpu_metrics->common_header.structure_size =<br>
- sizeof(struct gpu_metrics_v2_0);<br>
- gpu_metrics->common_header.format_revision = 2;<br>
- gpu_metrics->common_header.content_revision = 0;<br>
-<br>
- gpu_metrics->system_clock_counter = ktime_get_boottime_ns();<br>
-}<br>
-<br>
int smu_v11_0_gfx_ulv_control(struct smu_context *smu,<br>
bool enablement)<br>
{<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c<br>
index f0f06ef47b9e..42271e80c0b4 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c<br>
@@ -1406,7 +1406,7 @@ static ssize_t vangogh_get_gpu_metrics(struct smu_context *smu,<br>
if (ret)<br>
return ret;<br>
<br>
- smu_v11_0_init_gpu_metrics_v2_0(gpu_metrics);<br>
+ smu_cmn_init_soft_gpu_metrics(gpu_metrics, 2, 0);<br>
<br>
gpu_metrics->temperature_gfx = metrics.GfxTemperature;<br>
gpu_metrics->temperature_soc = metrics.SocTemperature;<br>
@@ -1442,6 +1442,8 @@ static ssize_t vangogh_get_gpu_metrics(struct smu_context *smu,<br>
<br>
gpu_metrics->throttle_status = metrics.ThrottlerStatus;<br>
<br>
+ gpu_metrics->system_clock_counter = ktime_get_boottime_ns();<br>
+<br>
*table = (void *)gpu_metrics;<br>
<br>
return sizeof(struct gpu_metrics_v2_0);<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c<br>
index ab15570305f7..f2d57900e93e 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c<br>
@@ -1257,7 +1257,7 @@ static ssize_t renoir_get_gpu_metrics(struct smu_context *smu,<br>
if (ret)<br>
return ret;<br>
<br>
- smu_v12_0_init_gpu_metrics_v2_0(gpu_metrics);<br>
+ smu_cmn_init_soft_gpu_metrics(gpu_metrics, 2, 0);<br>
<br>
gpu_metrics->temperature_gfx = metrics.GfxTemperature;<br>
gpu_metrics->temperature_soc = metrics.SocTemperature;<br>
@@ -1298,6 +1298,8 @@ static ssize_t renoir_get_gpu_metrics(struct smu_context *smu,<br>
<br>
gpu_metrics->fan_pwm = metrics.FanPwm;<br>
<br>
+ gpu_metrics->system_clock_counter = ktime_get_boottime_ns();<br>
+<br>
*table = (void *)gpu_metrics;<br>
<br>
return sizeof(struct gpu_metrics_v2_0);<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c<br>
index 06abf2a7ce9e..6cc4855c8a37 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c<br>
@@ -278,15 +278,3 @@ int smu_v12_0_set_driver_table_location(struct smu_context *smu)<br>
<br>
return ret;<br>
}<br>
-<br>
-void smu_v12_0_init_gpu_metrics_v2_0(struct gpu_metrics_v2_0 *gpu_metrics)<br>
-{<br>
- memset(gpu_metrics, 0xFF, sizeof(struct gpu_metrics_v2_0));<br>
-<br>
- gpu_metrics->common_header.structure_size =<br>
- sizeof(struct gpu_metrics_v2_0);<br>
- gpu_metrics->common_header.format_revision = 2;<br>
- gpu_metrics->common_header.content_revision = 0;<br>
-<br>
- gpu_metrics->system_clock_counter = ktime_get_boottime_ns();<br>
-}<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c<br>
index d9ecaa04d14e..38bcbe46e809 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c<br>
@@ -746,3 +746,28 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,<br>
<br>
return ret;<br>
}<br>
+<br>
+void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev)<br>
+{<br>
+ struct metrics_table_header *header = (struct metrics_table_header *)table;<br>
+<br>
+ header->format_revision = frev;<br>
+ header->content_revision = crev;<br>
+<br>
+#define METRICS_VERSION(a, b) ((a << 16) | b )<br>
+<br>
+ switch (METRICS_VERSION(frev, crev)) {<br>
+ case METRICS_VERSION(1, 0):<br>
+ header->structure_size = sizeof(struct gpu_metrics_v1_0);<br>
+ break;<br>
+ case METRICS_VERSION(2, 0):<br>
+ header->structure_size = sizeof(struct gpu_metrics_v2_0);<br>
+ break;<br>
+ default:<br>
+ break;<br>
+ }<br>
+<br>
+#undef METRICS_VERSION<br>
+<br>
+ memset(header, 0xFF, header->structure_size);<br>
+}<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h<br>
index 08ccf2d3257c..c69250185575 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h<br>
@@ -97,5 +97,7 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,<br>
void *metrics_table,<br>
bool bypass_cache);<br>
<br>
+void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev);<br>
+<br>
#endif<br>
#endif<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Calexander.deucher%40amd.com%7Ce8c80bc1d7f845d896b808d8c826513f%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637479414187156203%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jZYPEDDsNnX4cznjfDlgGaXBIDsyqOLZCkIg%2FKAUNpE%3D&reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Calexander.deucher%40amd.com%7Ce8c80bc1d7f845d896b808d8c826513f%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637479414187156203%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jZYPEDDsNnX4cznjfDlgGaXBIDsyqOLZCkIg%2FKAUNpE%3D&reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>