<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);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Xiaomeng Hou <Xiaomeng.Hou@amd.com><br>
<b>Sent:</b> Tuesday, December 8, 2020 7:19 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Huang, Ray <Ray.Huang@amd.com>; Hou, Xiaomeng (Matthew) <Xiaomeng.Hou@amd.com>; Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH 2/3] drm/amd/pm: add interface to notify RLC status for vangogh</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Add this interface to notify PMFW the status (Normal/Off) of RLC engine.<br>
<br>
Before notify RLC status normal, need check its current status first. Send the<br>
message only when current status is still off.<br>
<br>
Signed-off-by: Xiaomeng Hou <Xiaomeng.Hou@amd.com><br>
Change-Id: I2f1a7de23df7315a7b220ba6d0a4bcaa75c93fea<br>
---<br>
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  1 +<br>
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 24 ++++++++++++++++++-<br>
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.h  |  4 ++++<br>
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 13 ++++++++++<br>
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  2 ++<br>
 drivers/gpu/drm/amd/pm/swsmu/smu_internal.h   |  1 +<br>
 6 files changed, 44 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h<br>
index 89be49a43500..0da00a92b478 100644<br>
--- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h<br>
+++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h<br>
@@ -583,6 +583,7 @@ struct pptable_funcs {<br>
         int (*gpo_control)(struct smu_context *smu, bool enablement);<br>
         int (*gfx_state_change_set)(struct smu_context *smu, uint32_t state);<br>
         int (*set_fine_grain_gfx_freq_parameters)(struct smu_context *smu);<br>
+       int (*notify_rlc_status)(struct smu_context *smu, uint32_t status);<br>
 };<br>
 <br>
 typedef enum {<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 ddaa6a705fa6..03c2cd7a52a9 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>
@@ -64,7 +64,7 @@ static struct cmn2asic_msg_mapping vangogh_message_map[SMU_MSG_MAX_COUNT] = {<br>
         MSG_MAP(PowerUpIspByTile,               PPSMC_MSG_PowerUpIspByTile,             0),<br>
         MSG_MAP(PowerDownVcn,                   PPSMC_MSG_PowerDownVcn,                 0),<br>
         MSG_MAP(PowerUpVcn,                     PPSMC_MSG_PowerUpVcn,                   0),<br>
-       MSG_MAP(Spare,                          PPSMC_MSG_spare,                                0),<br>
+       MSG_MAP(RlcPowerNotify,                 PPSMC_MSG_RlcPowerNotify,               0),<br>
         MSG_MAP(SetHardMinVcn,                  PPSMC_MSG_SetHardMinVcn,                0),<br>
         MSG_MAP(SetSoftMinGfxclk,               PPSMC_MSG_SetSoftMinGfxclk,             0),<br>
         MSG_MAP(ActiveProcessNotify,            PPSMC_MSG_ActiveProcessNotify,          0),<br>
@@ -722,6 +722,27 @@ static int vangogh_set_fine_grain_gfx_freq_parameters(struct smu_context *smu)<br>
         return 0;<br>
 }<br>
 <br>
+static int vangogh_notify_rlc_status(struct smu_context *smu, uint32_t status)<br>
+{<br>
+       int ret = 0;<br>
+<br>
+       switch (status)<br>
+       {<br>
+       case RLC_STATUS_OFF:<br>
+               ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_RlcPowerNotify, status, NULL);<br>
+               break;<br>
+       case RLC_STATUS_NORMAL:<br>
+               if (smu_cmn_get_rlc_status(smu) == 0)<br>
+                       ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_RlcPowerNotify, status, NULL);<br>
+               break;<br>
+       default:<br>
+               dev_err(smu->adev->dev, "Unknown rlc status\n");<br>
+               return -EINVAL;<br>
+       }<br>
+<br>
+       return ret;<br>
+}<br>
+<br>
 static const struct pptable_funcs vangogh_ppt_funcs = {<br>
 <br>
         .check_fw_status = smu_v11_0_check_fw_status,<br>
@@ -750,6 +771,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = {<br>
         .print_clk_levels = vangogh_print_fine_grain_clk,<br>
         .set_default_dpm_table = vangogh_set_default_dpm_tables,<br>
         .set_fine_grain_gfx_freq_parameters = vangogh_set_fine_grain_gfx_freq_parameters,<br>
+       .notify_rlc_status = vangogh_notify_rlc_status,<br>
 };<br>
 <br>
 void vangogh_set_ppt_funcs(struct smu_context *smu)<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.h b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.h<br>
index 8756766296cd..eab455493076 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.h<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.h<br>
@@ -32,4 +32,8 @@ extern void vangogh_set_ppt_funcs(struct smu_context *smu);<br>
 #define VANGOGH_UMD_PSTATE_SOCCLK       678<br>
 #define VANGOGH_UMD_PSTATE_FCLK         800<br>
 <br>
+/* RLC Power Status */<br>
+#define RLC_STATUS_OFF          0<br>
+#define RLC_STATUS_NORMAL       1<br>
+<br>
 #endif<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 f8260769061c..2f3e66b03dd2 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c<br>
@@ -42,6 +42,9 @@<br>
  * They share the same definitions and values. That makes common<br>
  * APIs for SMC messages issuing for all ASICs possible.<br>
  */<br>
+#define mmMP1_SMN_C2PMSG_63                                                                            0x027f<br>
+#define mmMP1_SMN_C2PMSG_63_BASE_IDX                                                                   0<br>
+<br>
 #define mmMP1_SMN_C2PMSG_66                                                                            0x0282<br>
 #define mmMP1_SMN_C2PMSG_66_BASE_IDX                                                                   0<br>
 <br>
@@ -731,3 +734,13 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,<br>
 <br>
         return ret;<br>
 }<br>
+<br>
+int smu_cmn_get_rlc_status(struct smu_context *smu)<br>
+{<br>
+       struct amdgpu_device *adev = smu->adev;<br>
+       uint32_t val;<br>
+<br>
+       val = RREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_63);<br>
+<br>
+       return val;<br>
+}</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">[kevin]:</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">these are not common code for whole smu driver, please move it to ppt.c file.</div>
<div class="PlainText"><br>
\ No newline at end of file<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 01e825d83d8d..7584089ef15f 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h<br>
@@ -95,5 +95,7 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,<br>
                               void *metrics_table,<br>
                               bool bypass_cache);<br>
 <br>
+int smu_cmn_get_rlc_status(struct smu_context *smu);<br>
+<br>
 #endif<br>
 #endif<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h<br>
index 68d9464ababc..8ef3713f7f3c 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h<br>
@@ -91,6 +91,7 @@<br>
 #define smu_post_init(smu)                                              smu_ppt_funcs(post_init, 0, smu)<br>
 #define smu_gpo_control(smu, enablement)                                smu_ppt_funcs(gpo_control, 0, smu, enablement)<br>
 #define smu_set_fine_grain_gfx_freq_parameters(smu)                                     smu_ppt_funcs(set_fine_grain_gfx_freq_parameters, 0, smu)<br>
+#define smu_notify_rlc_status(smu, status)                                     smu_ppt_funcs(notify_rlc_status, 0, smu, status)<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&amp;data=04%7C01%7CKevin1.Wang%40amd.com%7Cf740746f29d14d4777e808d89b6b4971%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637430232414406734%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=VPGv9GuTb22ZkzKp98iG3ibpG7BSwKaw%2FBT%2F6DFDnSs%3D&amp;reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7CKevin1.Wang%40amd.com%7Cf740746f29d14d4777e808d89b6b4971%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637430232414406734%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=VPGv9GuTb22ZkzKp98iG3ibpG7BSwKaw%2FBT%2F6DFDnSs%3D&amp;reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>