<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="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hi Rex,</p>
<p><br>
</p>
<p>Given how often we diagnose problems by disabling PG/CG I'd have to offer my NAK to this patch since it prevents me from disabling PG via the command line.</p>
<p><br>
</p>
<p>Any reason you want to make it permanently enabled?</p>
<p><br>
</p>
<p>Tom</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_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 Rex Zhu <Rex.Zhu@amd.com><br>
<b>Sent:</b> Thursday, December 1, 2016 03:24<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Zhu, Rex<br>
<b>Subject:</b> [PATCH] drm/amdgpu: refine pg code for gfx_v8.</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">1. bit CP_PG_DISABLE was reversed.<br>
2. load RLC_SRM_INDEX_CNTL_ADDR/DATA_x pairs<br>
   with valid addr/data.<br>
3. always init gfx pg.<br>
4. delete repeated check for pg mask.<br>
<br>
Change-Id: I9fcc8d1f79f5fa1803cb2625aa292188a656ae6b<br>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 85 +++++++++++++++--------------------<br>
 1 file changed, 37 insertions(+), 48 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
index c02ae07..fee8c2a 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
@@ -3948,8 +3948,10 @@ static int gfx_v8_0_init_save_restore_list(struct amdgpu_device *adev)<br>
         temp = mmRLC_SRM_INDEX_CNTL_ADDR_0;<br>
         data = mmRLC_SRM_INDEX_CNTL_DATA_0;<br>
         for (i = 0; i < sizeof(unique_indices) / sizeof(int); i++) {<br>
-               amdgpu_mm_wreg(adev, temp + i, unique_indices[i] & 0x3FFFF, false);<br>
-               amdgpu_mm_wreg(adev, data + i, unique_indices[i] >> 20, false);<br>
+               if (unique_indices[i] != 0) {<br>
+                       amdgpu_mm_wreg(adev, temp + i, unique_indices[i] & 0x3FFFF, false);<br>
+                       amdgpu_mm_wreg(adev, data + i, unique_indices[i] >> 20, false);<br>
+               }<br>
         }<br>
         kfree(register_list_format);<br>
 <br>
@@ -3965,20 +3967,16 @@ static void gfx_v8_0_init_power_gating(struct amdgpu_device *adev)<br>
 {<br>
         uint32_t data;<br>
 <br>
-       if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |<br>
-                             AMD_PG_SUPPORT_GFX_SMG |<br>
-                             AMD_PG_SUPPORT_GFX_DMG)) {<br>
-               WREG32_FIELD(CP_RB_WPTR_POLL_CNTL, IDLE_POLL_COUNT, 0x60);<br>
+       WREG32_FIELD(CP_RB_WPTR_POLL_CNTL, IDLE_POLL_COUNT, 0x60);<br>
 <br>
-               data = REG_SET_FIELD(0, RLC_PG_DELAY, POWER_UP_DELAY, 0x10);<br>
-               data = REG_SET_FIELD(data, RLC_PG_DELAY, POWER_DOWN_DELAY, 0x10);<br>
-               data = REG_SET_FIELD(data, RLC_PG_DELAY, CMD_PROPAGATE_DELAY, 0x10);<br>
-               data = REG_SET_FIELD(data, RLC_PG_DELAY, MEM_SLEEP_DELAY, 0x10);<br>
-               WREG32(mmRLC_PG_DELAY, data);<br>
+       data = REG_SET_FIELD(0, RLC_PG_DELAY, POWER_UP_DELAY, 0x10);<br>
+       data = REG_SET_FIELD(data, RLC_PG_DELAY, POWER_DOWN_DELAY, 0x10);<br>
+       data = REG_SET_FIELD(data, RLC_PG_DELAY, CMD_PROPAGATE_DELAY, 0x10);<br>
+       data = REG_SET_FIELD(data, RLC_PG_DELAY, MEM_SLEEP_DELAY, 0x10);<br>
+       WREG32(mmRLC_PG_DELAY, data);<br>
 <br>
-               WREG32_FIELD(RLC_PG_DELAY_2, SERDES_CMD_DELAY, 0x3);<br>
-               WREG32_FIELD(RLC_AUTO_PG_CTRL, GRBM_REG_SAVE_GFX_IDLE_THRESHOLD, 0x55f0);<br>
-       }<br>
+       WREG32_FIELD(RLC_PG_DELAY_2, SERDES_CMD_DELAY, 0x3);<br>
+       WREG32_FIELD(RLC_AUTO_PG_CTRL, GRBM_REG_SAVE_GFX_IDLE_THRESHOLD, 0x55f0);<br>
 }<br>
 <br>
 static void cz_enable_sck_slow_down_on_power_up(struct amdgpu_device *adev,<br>
@@ -3995,41 +3993,35 @@ static void cz_enable_sck_slow_down_on_power_down(struct amdgpu_device *adev,<br>
 <br>
 static void cz_enable_cp_power_gating(struct amdgpu_device *adev, bool enable)<br>
 {<br>
-       WREG32_FIELD(RLC_PG_CNTL, CP_PG_DISABLE, enable ? 1 : 0);<br>
+       WREG32_FIELD(RLC_PG_CNTL, CP_PG_DISABLE, enable ? 0 : 1);<br>
 }<br>
 <br>
 static void gfx_v8_0_init_pg(struct amdgpu_device *adev)<br>
 {<br>
-       if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |<br>
-                             AMD_PG_SUPPORT_GFX_SMG |<br>
-                             AMD_PG_SUPPORT_GFX_DMG |<br>
-                             AMD_PG_SUPPORT_CP |<br>
-                             AMD_PG_SUPPORT_GDS |<br>
-                             AMD_PG_SUPPORT_RLC_SMU_HS)) {<br>
-               gfx_v8_0_init_csb(adev);<br>
-               gfx_v8_0_init_save_restore_list(adev);<br>
-               gfx_v8_0_enable_save_restore_machine(adev);<br>
-<br>
-               if ((adev->asic_type == CHIP_CARRIZO) ||<br>
-                   (adev->asic_type == CHIP_STONEY)) {<br>
-                       WREG32(mmRLC_JUMP_TABLE_RESTORE, adev->gfx.rlc.cp_table_gpu_addr >> 8);<br>
-                       gfx_v8_0_init_power_gating(adev);<br>
-                       WREG32(mmRLC_PG_ALWAYS_ON_CU_MASK, adev->gfx.cu_info.ao_cu_mask);<br>
-                       if (adev->pg_flags & AMD_PG_SUPPORT_RLC_SMU_HS) {<br>
-                               cz_enable_sck_slow_down_on_power_up(adev, true);<br>
-                               cz_enable_sck_slow_down_on_power_down(adev, true);<br>
-                       } else {<br>
-                               cz_enable_sck_slow_down_on_power_up(adev, false);<br>
-                               cz_enable_sck_slow_down_on_power_down(adev, false);<br>
-                       }<br>
-                       if (adev->pg_flags & AMD_PG_SUPPORT_CP)<br>
-                               cz_enable_cp_power_gating(adev, true);<br>
-                       else<br>
-                               cz_enable_cp_power_gating(adev, false);<br>
-               } else if (adev->asic_type == CHIP_POLARIS11) {<br>
-                       gfx_v8_0_init_power_gating(adev);<br>
+       gfx_v8_0_init_csb(adev);<br>
+       gfx_v8_0_init_save_restore_list(adev);<br>
+       gfx_v8_0_enable_save_restore_machine(adev);<br>
+<br>
+       if ((adev->asic_type == CHIP_CARRIZO) ||<br>
+           (adev->asic_type == CHIP_STONEY)) {<br>
+               WREG32(mmRLC_JUMP_TABLE_RESTORE, adev->gfx.rlc.cp_table_gpu_addr >> 8);<br>
+               gfx_v8_0_init_power_gating(adev);<br>
+               WREG32(mmRLC_PG_ALWAYS_ON_CU_MASK, adev->gfx.cu_info.ao_cu_mask);<br>
+               if (adev->pg_flags & AMD_PG_SUPPORT_RLC_SMU_HS) {<br>
+                       cz_enable_sck_slow_down_on_power_up(adev, true);<br>
+                       cz_enable_sck_slow_down_on_power_down(adev, true);<br>
+               } else {<br>
+                       cz_enable_sck_slow_down_on_power_up(adev, false);<br>
+                       cz_enable_sck_slow_down_on_power_down(adev, false);<br>
                 }<br>
+               if (adev->pg_flags & AMD_PG_SUPPORT_CP)<br>
+                       cz_enable_cp_power_gating(adev, true);<br>
+               else<br>
+                       cz_enable_cp_power_gating(adev, false);<br>
+       } else if (adev->asic_type == CHIP_POLARIS11) {<br>
+               gfx_v8_0_init_power_gating(adev);<br>
         }<br>
+<br>
 }<br>
 <br>
 static void gfx_v8_0_rlc_stop(struct amdgpu_device *adev)<br>
@@ -5570,14 +5562,11 @@ static int gfx_v8_0_set_powergating_state(void *handle,<br>
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
         bool enable = (state == AMD_PG_STATE_GATE) ? true : false;<br>
 <br>
-       if (!(adev->pg_flags & AMD_PG_SUPPORT_GFX_PG))<br>
-               return 0;<br>
-<br>
         switch (adev->asic_type) {<br>
         case CHIP_CARRIZO:<br>
         case CHIP_STONEY:<br>
-               if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)<br>
-                       cz_update_gfx_cg_power_gating(adev, enable);<br>
+<br>
+               cz_update_gfx_cg_power_gating(adev, enable);<br>
 <br>
                 if ((adev->pg_flags & AMD_PG_SUPPORT_GFX_SMG) && enable)<br>
                         gfx_v8_0_enable_gfx_static_mg_power_gating(adev, true);<br>
-- <br>
1.9.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk673551" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_14805986103560.2303328502092905" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_14805986103510.928282809078228" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_14805986103530.5299249391541836" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_14805986103540.9670587046814567"></div>
<div id="LPTitle_14805986103540.19756975909973828" style="top: 0px; color: rgb(59, 87, 119); font-weight: normal; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_14805986103550.2422724483276617" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank" style="text-decoration: none;">amd-gfx Info Page - lists.freedesktop.org</a></div>
<div id="LPMetadata_14805986103550.8026698469598559" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
lists.freedesktop.org</div>
<div id="LPDescription_14805986103550.03961792031288636" style="display: block; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
To see the collection of prior postings to the list, visit the amd-gfx Archives. Using amd-gfx: To post a message to all the list members, send email ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>