<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div dir="auto" style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);">
<div dir="auto" style="color:rgb(0, 0, 0);font-size:14.6667px;background-color:rgb(255, 255, 255)">
a typo issue in commit message:  "msu",<br>
</div>
<div dir="auto" style="color:rgb(0, 0, 0);font-size:14.6667px;background-color:rgb(255, 255, 255)">
and one comment inline.<br>
</div>
<div dir="auto" style="color:rgb(0, 0, 0);font-size:14.6667px;background-color:rgb(255, 255, 255)">
<br>
</div>
<div dir="auto" style="color:rgb(0, 0, 0);font-size:14.6667px;background-color:rgb(255, 255, 255)">
<div dir="auto" style="background-color:rgb(255, 255, 255)">Reviewed-by: Yang Wang <kevinyang.wang@amd.com></div>
<div dir="auto" style="background-color:rgb(255, 255, 255)"><br>
</div>
<div dir="auto" style="background-color:rgb(255, 255, 255)">Best Regards</div>
<div dir="auto" style="background-color:rgb(255, 255, 255)">Kevin</div>
</div>
</div>
<div id="ms-outlook-mobile-signature" dir="auto">
<div dir="auto" id="mail-editor-reference-message-container">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg"><strong>发件人:</strong> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Kenneth Feng <kenneth.feng@amd.com><br>
<strong>发送时间:</strong> 2022年11月8日星期二 上午8:36<br>
<strong>收件人:</strong> amd-gfx@lists.freedesktop.org<br>
<strong>抄送:</strong> Feng, Kenneth<br>
<strong>主题:</strong> [PATCH v2] drm/amd/pm: enable mode1 reset on smu_v13_0_10<br>
</div>
<br>
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><font size="2"><span style="font-size:11pt;">
<div class="PlainText" dir="auto">enable mode1 reset and prioritize debug port on msu_v13_0_10<br>
as a more reliable message processing<br>
<br>
v2 - move mode1 reset callback to smu_v13_0_0_ppt.c<br>
<br>
Signed-off-by: Kenneth Feng <kenneth.feng@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/soc21.c            |  1 +<br>
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  4 ++<br>
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 53 ++++++++++++++++++-<br>
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 18 +++++++<br>
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 ++<br>
 5 files changed, 77 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/soc21.c b/drivers/gpu/drm/amd/amdgpu/soc21.c<br>
index 1d4013ed0d10..b258e9aa0558 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/soc21.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/soc21.c<br>
@@ -322,6 +322,7 @@ soc21_asic_reset_method(struct amdgpu_device *adev)<br>
         switch (adev->ip_versions[MP1_HWIP][0]) {<br>
         case IP_VERSION(13, 0, 0):<br>
         case IP_VERSION(13, 0, 7):<br>
+       case IP_VERSION(13, 0, 10):<br>
                 return AMD_RESET_METHOD_MODE1;<br>
         case IP_VERSION(13, 0, 4):<br>
                 return AMD_RESET_METHOD_MODE2;<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h<br>
index e2fa3b066b96..1bc26e93a83c 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h<br>
@@ -568,6 +568,10 @@ struct smu_context<br>
         u32 param_reg;<br>
         u32 msg_reg;<br>
         u32 resp_reg;<br>
+<br>
+       u32 debug_param_reg;<br>
+       u32 debug_msg_reg;<br>
+       u32 debug_resp_reg;<br>
 };<br>
 <br>
 struct i2c_adapter;<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c<br>
index 29529328152d..588527310188 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c<br>
@@ -70,6 +70,26 @@<br>
 <br>
 #define MP0_MP1_DATA_REGION_SIZE_COMBOPPTABLE   0x4000<br>
 <br>
+#define mmMP1_SMN_C2PMSG_66                                                                            0x0282<br>
+#define mmMP1_SMN_C2PMSG_66_BASE_IDX                                                                   0<br>
+<br>
+#define mmMP1_SMN_C2PMSG_82                                                                            0x0292<br>
+#define mmMP1_SMN_C2PMSG_82_BASE_IDX                                                                   0<br>
+<br>
+#define mmMP1_SMN_C2PMSG_90                                                                            0x029a<br>
+#define mmMP1_SMN_C2PMSG_90_BASE_IDX                                                                   0<br>
+<br>
+#define mmMP1_SMN_C2PMSG_75                                                                            0x028b<br>
+#define mmMP1_SMN_C2PMSG_75_BASE_IDX                                                                   0<br>
+<br>
+#define mmMP1_SMN_C2PMSG_53                                                                            0x0275<br>
+#define mmMP1_SMN_C2PMSG_53_BASE_IDX                                                                   0<br>
+<br>
+#define mmMP1_SMN_C2PMSG_54                                                                            0x0276<br>
+#define mmMP1_SMN_C2PMSG_54_BASE_IDX                                                                   0<br>
+<br>
+#define DEBUGSMC_MSG_Mode1Reset        2<br>
+<br>
 static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] = {<br>
         MSG_MAP(TestMessage,                    PPSMC_MSG_TestMessage,                 1),<br>
         MSG_MAP(GetSmuVersion,                  PPSMC_MSG_GetSmuVersion,               1),<br>
@@ -1763,6 +1783,35 @@ static int smu_v13_0_0_set_df_cstate(struct smu_context *smu,<br>
                                                NULL);<br>
 }<br>
 <br>
+static int smu_v13_0_0_mode1_reset(struct smu_context *smu)<br>
+{<br>
+       int ret = 0;</div>
<div class="PlainText" dir="auto">kevin:</div>
<div class="PlainText" dir="auto"><span style="font-size: 11pt;">No initialization required</span><br>
</div>
<div class="PlainText" dir="auto"><br>
</div>
<div class="PlainText" dir="auto">+       struct amdgpu_device *adev = smu->adev;<br>
+<br>
+       if (adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 10))<br>
+               ret = smu_cmn_send_debug_smc_msg(smu, DEBUGSMC_MSG_Mode1Reset);<br>
+       else<br>
+               ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset, NULL);<br>
+<br>
+       if (!ret)<br>
+               msleep(SMU13_MODE1_RESET_WAIT_TIME_IN_MS);<br>
+<br>
+       return ret;<br>
+}<br>
+<br>
+static void smu_v13_0_0_set_smu_mailbox_registers(struct smu_context *smu)<br>
+{<br>
+       struct amdgpu_device *adev = smu->adev;<br>
+<br>
+       smu->param_reg = SOC15_REG_OFFSET(MP1, 0, mmMP1_SMN_C2PMSG_82);<br>
+       smu->msg_reg = SOC15_REG_OFFSET(MP1, 0, mmMP1_SMN_C2PMSG_66);<br>
+       smu->resp_reg = SOC15_REG_OFFSET(MP1, 0, mmMP1_SMN_C2PMSG_90);<br>
+<br>
+       smu->debug_param_reg = SOC15_REG_OFFSET(MP1, 0, mmMP1_SMN_C2PMSG_53);<br>
+       smu->debug_msg_reg = SOC15_REG_OFFSET(MP1, 0, mmMP1_SMN_C2PMSG_75);<br>
+       smu->debug_resp_reg = SOC15_REG_OFFSET(MP1, 0, mmMP1_SMN_C2PMSG_54);<br>
+}<br>
+<br>
 static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {<br>
         .get_allowed_feature_mask = smu_v13_0_0_get_allowed_feature_mask,<br>
         .set_default_dpm_table = smu_v13_0_0_set_default_dpm_table,<br>
@@ -1830,7 +1879,7 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {<br>
         .baco_enter = smu_v13_0_baco_enter,<br>
         .baco_exit = smu_v13_0_baco_exit,<br>
         .mode1_reset_is_support = smu_v13_0_0_is_mode1_reset_supported,<br>
-       .mode1_reset = smu_v13_0_mode1_reset,<br>
+       .mode1_reset = smu_v13_0_0_mode1_reset,<br>
         .set_mp1_state = smu_v13_0_0_set_mp1_state,<br>
         .set_df_cstate = smu_v13_0_0_set_df_cstate,<br>
 };<br>
@@ -1844,5 +1893,5 @@ void smu_v13_0_0_set_ppt_funcs(struct smu_context *smu)<br>
         smu->table_map = smu_v13_0_0_table_map;<br>
         smu->pwr_src_map = smu_v13_0_0_pwr_src_map;<br>
         smu->workload_map = smu_v13_0_0_workload_map;<br>
-       smu_v13_0_set_smu_mailbox_registers(smu);<br>
+       smu_v13_0_0_set_smu_mailbox_registers(smu);<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 e4f8f90ac5aa..768b6e7dbd77 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c<br>
@@ -233,6 +233,18 @@ static void __smu_cmn_send_msg(struct smu_context *smu,<br>
         WREG32(smu->msg_reg, msg);<br>
 }<br>
 <br>
+static int __smu_cmn_send_debug_msg(struct smu_context *smu,<br>
+                              u32 msg,<br>
+                              u32 param)<br>
+{<br>
+       struct amdgpu_device *adev = smu->adev;<br>
+<br>
+       WREG32(smu->debug_param_reg, param);<br>
+       WREG32(smu->debug_msg_reg, msg);<br>
+       WREG32(smu->debug_resp_reg, 0);<br>
+<br>
+       return 0;<br>
+}<br>
 /**<br>
  * smu_cmn_send_msg_without_waiting -- send the message; don't wait for status<br>
  * @smu: pointer to an SMU context<br>
@@ -386,6 +398,12 @@ int smu_cmn_send_smc_msg(struct smu_context *smu,<br>
                                                read_arg);<br>
 }<br>
 <br>
+int smu_cmn_send_debug_smc_msg(struct smu_context *smu,<br>
+                        uint32_t msg)<br>
+{<br>
+       return __smu_cmn_send_debug_msg(smu, msg, 0);<br>
+}<br>
+<br>
 int smu_cmn_to_asic_specific_index(struct smu_context *smu,<br>
                                    enum smu_cmn2asic_mapping_type type,<br>
                                    uint32_t index)<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 1526ce09c399..f82cf76dd3a4 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h<br>
@@ -42,6 +42,9 @@ int smu_cmn_send_smc_msg(struct smu_context *smu,<br>
                          enum smu_message_type msg,<br>
                          uint32_t *read_arg);<br>
 <br>
+int smu_cmn_send_debug_smc_msg(struct smu_context *smu,<br>
+                        uint32_t msg);<br>
+<br>
 int smu_cmn_wait_for_response(struct smu_context *smu);<br>
 <br>
 int smu_cmn_to_asic_specific_index(struct smu_context *smu,<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font><br>
</div>
</div>
</div>
</body>
</html>