<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">
<div id="appendonsend" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Reviewed-by: Kevin Wang <kevin1.wang@amd.com></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Best Regards,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Kevin</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 Kenneth Feng <kenneth.feng@amd.com><br>
<b>Sent:</b> Thursday, September 26, 2019 4:47 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Feng, Kenneth <Kenneth.Feng@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/amdgpu: add IH cg support on soc15 project</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">enable/disable IH clock gating on soc15 projects.<br>
<br>
Signed-off-by: Kenneth Feng <kenneth.feng@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/soc15.c                 |  3 +-<br>
 drivers/gpu/drm/amd/amdgpu/vega10_ih.c             | 39 ++++++++++++++++++++++<br>
 .../amd/include/asic_reg/oss/osssys_4_0_sh_mask.h  |  4 +++<br>
 3 files changed, 45 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
index 58818761..e40410e 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
@@ -1166,7 +1166,8 @@ static int soc15_common_early_init(void *handle)<br>
                         AMD_CG_SUPPORT_SDMA_MGCG |<br>
                         AMD_CG_SUPPORT_SDMA_LS |<br>
                         AMD_CG_SUPPORT_MC_MGCG |<br>
-                       AMD_CG_SUPPORT_MC_LS;<br>
+                       AMD_CG_SUPPORT_MC_LS |<br>
+                       AMD_CG_SUPPORT_IH_CG;<br>
                 adev->pg_flags = 0;<br>
                 adev->external_rev_id = adev->rev_id + 0x32;<br>
                 break;<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c<br>
index 14e0b04..5cb7e23 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c<br>
@@ -675,10 +675,49 @@ static int vega10_ih_soft_reset(void *handle)<br>
         return 0;<br>
 }<br>
 <br>
+static void vega10_ih_update_clockgating_state(struct amdgpu_device *adev,<br>
+                                              bool enable)<br>
+{<br>
+       uint32_t data, def, field_val;<br>
+<br>
+       if (adev->cg_flags & AMD_CG_SUPPORT_IH_CG) {<br>
+               def = data = RREG32_SOC15(OSSSYS, 0, mmIH_CLK_CTRL);<br>
+               field_val = enable ? 0 : 1;<br>
+               /**<br>
+                * Vega10 does not have IH_RETRY_INT_CAM_MEM_CLK_SOFT_OVERRIDE<br>
+                * and IH_BUFFER_MEM_CLK_SOFT_OVERRIDE field.<br>
+                */<br>
+               if (adev->asic_type > CHIP_VEGA10) {<br>
+                       data = REG_SET_FIELD(data, IH_CLK_CTRL,<br>
+                                    IH_RETRY_INT_CAM_MEM_CLK_SOFT_OVERRIDE, field_val);<br>
+                       data = REG_SET_FIELD(data, IH_CLK_CTRL,<br>
+                                    IH_BUFFER_MEM_CLK_SOFT_OVERRIDE, field_val);<br>
+               }<br>
+<br>
+               data = REG_SET_FIELD(data, IH_CLK_CTRL,<br>
+                                    DBUS_MUX_CLK_SOFT_OVERRIDE, field_val);<br>
+               data = REG_SET_FIELD(data, IH_CLK_CTRL,<br>
+                                    OSSSYS_SHARE_CLK_SOFT_OVERRIDE, field_val);<br>
+               data = REG_SET_FIELD(data, IH_CLK_CTRL,<br>
+                                    LIMIT_SMN_CLK_SOFT_OVERRIDE, field_val);<br>
+               data = REG_SET_FIELD(data, IH_CLK_CTRL,<br>
+                                    DYN_CLK_SOFT_OVERRIDE, field_val);<br>
+               data = REG_SET_FIELD(data, IH_CLK_CTRL,<br>
+                                    REG_CLK_SOFT_OVERRIDE, field_val);<br>
+               if (def != data)<br>
+                       WREG32_SOC15(OSSSYS, 0, mmIH_CLK_CTRL, data);<br>
+       }<br>
+}<br>
+<br>
 static int vega10_ih_set_clockgating_state(void *handle,<br>
                                           enum amd_clockgating_state state)<br>
 {<br>
+       struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
+<br>
+       vega10_ih_update_clockgating_state(adev,<br>
+                               state == AMD_CG_STATE_GATE ? true : false);<br>
         return 0;<br>
+<br>
 }<br>
 <br>
 static int vega10_ih_set_powergating_state(void *handle,<br>
diff --git a/drivers/gpu/drm/amd/include/asic_reg/oss/osssys_4_0_sh_mask.h b/drivers/gpu/drm/amd/include/asic_reg/oss/osssys_4_0_sh_mask.h<br>
index dc9895a..096d878 100644<br>
--- a/drivers/gpu/drm/amd/include/asic_reg/oss/osssys_4_0_sh_mask.h<br>
+++ b/drivers/gpu/drm/amd/include/asic_reg/oss/osssys_4_0_sh_mask.h<br>
@@ -588,11 +588,15 @@<br>
 #define IH_STORM_CLIENT_LIST_CNTL__CLIENT30_IS_STORM_CLIENT_MASK                                              0x40000000L<br>
 #define IH_STORM_CLIENT_LIST_CNTL__CLIENT31_IS_STORM_CLIENT_MASK                                              0x80000000L<br>
 //IH_CLK_CTRL<br>
+#define IH_CLK_CTRL__IH_RETRY_INT_CAM_MEM_CLK_SOFT_OVERRIDE__SHIFT                                             0x19<br>
+#define IH_CLK_CTRL__IH_BUFFER_MEM_CLK_SOFT_OVERRIDE__SHIFT                                                               0x1a<br>
 #define IH_CLK_CTRL__DBUS_MUX_CLK_SOFT_OVERRIDE__SHIFT                                                        0x1b<br>
 #define IH_CLK_CTRL__OSSSYS_SHARE_CLK_SOFT_OVERRIDE__SHIFT                                                    0x1c<br>
 #define IH_CLK_CTRL__LIMIT_SMN_CLK_SOFT_OVERRIDE__SHIFT                                                       0x1d<br>
 #define IH_CLK_CTRL__DYN_CLK_SOFT_OVERRIDE__SHIFT                                                             0x1e<br>
 #define IH_CLK_CTRL__REG_CLK_SOFT_OVERRIDE__SHIFT                                                             0x1f<br>
+#define IH_CLK_CTRL__IH_RETRY_INT_CAM_MEM_CLK_SOFT_OVERRIDE_MASK                                              0x02000000L<br>
+#define IH_CLK_CTRL__IH_BUFFER_MEM_CLK_SOFT_OVERRIDE_MASK                                                         0x04000000L<br>
 #define IH_CLK_CTRL__DBUS_MUX_CLK_SOFT_OVERRIDE_MASK                                                          0x08000000L<br>
 #define IH_CLK_CTRL__OSSSYS_SHARE_CLK_SOFT_OVERRIDE_MASK                                                      0x10000000L<br>
 #define IH_CLK_CTRL__LIMIT_SMN_CLK_SOFT_OVERRIDE_MASK                                                         0x20000000L<br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></div>
</span></font></div>
</body>
</html>