<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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:10pt;color:#317100;margin:15pt;" align="Left">
[AMD Public Use]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Series is:</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>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Quan, Evan <Evan.Quan@amd.com><br>
<b>Sent:</b> Thursday, December 10, 2020 2:10 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH 2/2] drm/amd/pm: update the data strucutre for SMU metrics exchange</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">This is needed for Sienna Cichlid.<br>
<br>
Change-Id: I57aa099cd1b2020cf0c8b05d8463239ec33790cf<br>
Signed-off-by: Evan Quan <evan.quan@amd.com><br>
---<br>
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   | 75 ++++++++++---------<br>
 1 file changed, 39 insertions(+), 36 deletions(-)<br>
<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 acbf6e97ffd0..0c4885273291 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>
@@ -515,7 +515,7 @@ static int sienna_cichlid_tables_init(struct smu_context *smu)<br>
                        PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);<br>
         SMU_TABLE_INIT(tables, SMU_TABLE_WATERMARKS, sizeof(Watermarks_t),<br>
                        PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);<br>
-       SMU_TABLE_INIT(tables, SMU_TABLE_SMU_METRICS, sizeof(SmuMetrics_t),<br>
+       SMU_TABLE_INIT(tables, SMU_TABLE_SMU_METRICS, sizeof(SmuMetricsExternal_t),<br>
                        PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);<br>
         SMU_TABLE_INIT(tables, SMU_TABLE_I2C_COMMANDS, sizeof(SwI2cRequest_t),<br>
                        PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);<br>
@@ -527,7 +527,7 @@ static int sienna_cichlid_tables_init(struct smu_context *smu)<br>
                        sizeof(DpmActivityMonitorCoeffIntExternal_t), PAGE_SIZE,<br>
                        AMDGPU_GEM_DOMAIN_VRAM);<br>
 <br>
-       smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);<br>
+       smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL);<br>
         if (!smu_table->metrics_table)<br>
                 goto err0_out;<br>
         smu_table->metrics_time = 0;<br>
@@ -556,7 +556,8 @@ static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu,<br>
                                                uint32_t *value)<br>
 {<br>
         struct smu_table_context *smu_table= &smu->smu_table;<br>
-       SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;<br>
+       SmuMetrics_t *metrics =<br>
+               &(((SmuMetricsExternal_t *)(smu_table->metrics_table))->SmuMetrics);<br>
         int ret = 0;<br>
 <br>
         mutex_lock(&smu->metrics_lock);<br>
@@ -3152,52 +3153,54 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,<br>
         struct smu_table_context *smu_table = &smu->smu_table;<br>
         struct gpu_metrics_v1_0 *gpu_metrics =<br>
                 (struct gpu_metrics_v1_0 *)smu_table->gpu_metrics_table;<br>
-       SmuMetrics_t metrics;<br>
+       SmuMetricsExternal_t metrics_external;<br>
+       SmuMetrics_t *metrics =<br>
+               &(metrics_external.SmuMetrics);<br>
         int ret = 0;<br>
 <br>
         ret = smu_cmn_get_metrics_table(smu,<br>
-                                       &metrics,<br>
+                                       &metrics_external,<br>
                                         true);<br>
         if (ret)<br>
                 return ret;<br>
 <br>
         smu_v11_0_init_gpu_metrics_v1_0(gpu_metrics);<br>
 <br>
-       gpu_metrics->temperature_edge = metrics.TemperatureEdge;<br>
-       gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;<br>
-       gpu_metrics->temperature_mem = metrics.TemperatureMem;<br>
-       gpu_metrics->temperature_vrgfx = metrics.TemperatureVrGfx;<br>
-       gpu_metrics->temperature_vrsoc = metrics.TemperatureVrSoc;<br>
-       gpu_metrics->temperature_vrmem = metrics.TemperatureVrMem0;<br>
+       gpu_metrics->temperature_edge = metrics->TemperatureEdge;<br>
+       gpu_metrics->temperature_hotspot = metrics->TemperatureHotspot;<br>
+       gpu_metrics->temperature_mem = metrics->TemperatureMem;<br>
+       gpu_metrics->temperature_vrgfx = metrics->TemperatureVrGfx;<br>
+       gpu_metrics->temperature_vrsoc = metrics->TemperatureVrSoc;<br>
+       gpu_metrics->temperature_vrmem = metrics->TemperatureVrMem0;<br>
 <br>
-       gpu_metrics->average_gfx_activity = metrics.AverageGfxActivity;<br>
-       gpu_metrics->average_umc_activity = metrics.AverageUclkActivity;<br>
-       gpu_metrics->average_mm_activity = metrics.VcnActivityPercentage;<br>
+       gpu_metrics->average_gfx_activity = metrics->AverageGfxActivity;<br>
+       gpu_metrics->average_umc_activity = metrics->AverageUclkActivity;<br>
+       gpu_metrics->average_mm_activity = metrics->VcnActivityPercentage;<br>
 <br>
-       gpu_metrics->average_socket_power = metrics.AverageSocketPower;<br>
-       gpu_metrics->energy_accumulator = metrics.EnergyAccumulator;<br>
+       gpu_metrics->average_socket_power = metrics->AverageSocketPower;<br>
+       gpu_metrics->energy_accumulator = metrics->EnergyAccumulator;<br>
 <br>
-       if (metrics.AverageGfxActivity <= SMU_11_0_7_GFX_BUSY_THRESHOLD)<br>
-               gpu_metrics->average_gfxclk_frequency = metrics.AverageGfxclkFrequencyPostDs;<br>
+       if (metrics->AverageGfxActivity <= SMU_11_0_7_GFX_BUSY_THRESHOLD)<br>
+               gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPostDs;<br>
         else<br>
-               gpu_metrics->average_gfxclk_frequency = metrics.AverageGfxclkFrequencyPreDs;<br>
-       gpu_metrics->average_uclk_frequency = metrics.AverageUclkFrequencyPostDs;<br>
-       gpu_metrics->average_vclk0_frequency = metrics.AverageVclk0Frequency;<br>
-       gpu_metrics->average_dclk0_frequency = metrics.AverageDclk0Frequency;<br>
-       gpu_metrics->average_vclk1_frequency = metrics.AverageVclk1Frequency;<br>
-       gpu_metrics->average_dclk1_frequency = metrics.AverageDclk1Frequency;<br>
-<br>
-       gpu_metrics->current_gfxclk = metrics.CurrClock[PPCLK_GFXCLK];<br>
-       gpu_metrics->current_socclk = metrics.CurrClock[PPCLK_SOCCLK];<br>
-       gpu_metrics->current_uclk = metrics.CurrClock[PPCLK_UCLK];<br>
-       gpu_metrics->current_vclk0 = metrics.CurrClock[PPCLK_VCLK_0];<br>
-       gpu_metrics->current_dclk0 = metrics.CurrClock[PPCLK_DCLK_0];<br>
-       gpu_metrics->current_vclk1 = metrics.CurrClock[PPCLK_VCLK_1];<br>
-       gpu_metrics->current_dclk1 = metrics.CurrClock[PPCLK_DCLK_1];<br>
-<br>
-       gpu_metrics->throttle_status = metrics.ThrottlerStatus;<br>
-<br>
-       gpu_metrics->current_fan_speed = metrics.CurrFanSpeed;<br>
+               gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPreDs;<br>
+       gpu_metrics->average_uclk_frequency = metrics->AverageUclkFrequencyPostDs;<br>
+       gpu_metrics->average_vclk0_frequency = metrics->AverageVclk0Frequency;<br>
+       gpu_metrics->average_dclk0_frequency = metrics->AverageDclk0Frequency;<br>
+       gpu_metrics->average_vclk1_frequency = metrics->AverageVclk1Frequency;<br>
+       gpu_metrics->average_dclk1_frequency = metrics->AverageDclk1Frequency;<br>
+<br>
+       gpu_metrics->current_gfxclk = metrics->CurrClock[PPCLK_GFXCLK];<br>
+       gpu_metrics->current_socclk = metrics->CurrClock[PPCLK_SOCCLK];<br>
+       gpu_metrics->current_uclk = metrics->CurrClock[PPCLK_UCLK];<br>
+       gpu_metrics->current_vclk0 = metrics->CurrClock[PPCLK_VCLK_0];<br>
+       gpu_metrics->current_dclk0 = metrics->CurrClock[PPCLK_DCLK_0];<br>
+       gpu_metrics->current_vclk1 = metrics->CurrClock[PPCLK_VCLK_1];<br>
+       gpu_metrics->current_dclk1 = metrics->CurrClock[PPCLK_DCLK_1];<br>
+<br>
+       gpu_metrics->throttle_status = metrics->ThrottlerStatus;<br>
+<br>
+       gpu_metrics->current_fan_speed = metrics->CurrFanSpeed;<br>
 <br>
         gpu_metrics->pcie_link_width =<br>
                         smu_v11_0_get_current_pcie_link_width(smu);<br>
-- <br>
2.29.0<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>