<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);">
Acked-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> YuBiao Wang <YuBiao.Wang@amd.com><br>
<b>Sent:</b> Thursday, May 13, 2021 6:33 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Grodzovsky, Andrey <Andrey.Grodzovsky@amd.com>; Quan, Evan <Evan.Quan@amd.com>; Chen, Horace <Horace.Chen@amd.com>; Tuikov, Luben <Luben.Tuikov@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>;
 Xiao, Jack <Jack.Xiao@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Liu, Monk <Monk.Liu@amd.com>; Xu, Feifei <Feifei.Xu@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; Xiaojie Yuan <xiaojie.yuan@amd.com>; Wang, YuBiao <YuBiao.Wang@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/amdgpu: psp program IH_RB_CTRL on sienna_cichlid</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">[Why]<br>
IH_RB_CNTL is blocked by PSP so we need to ask psp to help config it.<br>
<br>
[How]<br>
Move psp ip block before ih, and use psp to program IH_RB_CNTL under sriov.<br>
<br>
Signed-off-by: YuBiao Wang <YuBiao.Wang@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/navi10_ih.c | 20 ++++++++++++++++++--<br>
 drivers/gpu/drm/amd/amdgpu/nv.c        | 12 +++++++++---<br>
 2 files changed, 27 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c<br>
index f4e4040bbd25..5ee923ccdeb3 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c<br>
@@ -151,7 +151,15 @@ static int navi10_ih_toggle_ring_interrupts(struct amdgpu_device *adev,<br>
         /* enable_intr field is only valid in ring0 */<br>
         if (ih == &adev->irq.ih)<br>
                 tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, ENABLE_INTR, (enable ? 1 : 0));<br>
-       WREG32(ih_regs->ih_rb_cntl, tmp);<br>
+<br>
+       if (amdgpu_sriov_vf(adev) && amdgpu_sriov_reg_indirect_ih(adev)) {<br>
+               if (psp_reg_program(&adev->psp, ih_regs->psp_reg_id, tmp)) {<br>
+                       DRM_ERROR("PSP program IH_RB_CNTL failed!\n");<br>
+                       return -ETIMEDOUT;<br>
+               }<br>
+       } else {<br>
+               WREG32(ih_regs->ih_rb_cntl, tmp);<br>
+       }<br>
 <br>
         if (enable) {<br>
                 ih->enabled = true;<br>
@@ -261,7 +269,15 @@ static int navi10_ih_enable_ring(struct amdgpu_device *adev,<br>
                 tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_ENABLE, 0);<br>
                 tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, RB_FULL_DRAIN_ENABLE, 1);<br>
         }<br>
-       WREG32(ih_regs->ih_rb_cntl, tmp);<br>
+<br>
+       if (amdgpu_sriov_vf(adev) && amdgpu_sriov_reg_indirect_ih(adev)) {<br>
+               if (psp_reg_program(&adev->psp, ih_regs->psp_reg_id, tmp)) {<br>
+                       DRM_ERROR("PSP program IH_RB_CNTL failed!\n");<br>
+                       return -ETIMEDOUT;<br>
+               }<br>
+       } else {<br>
+               WREG32(ih_regs->ih_rb_cntl, tmp);<br>
+       }<br>
 <br>
         if (ih == &adev->irq.ih) {<br>
                 /* set the ih ring 0 writeback address whether it's enabled or not */<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c<br>
index 75d1f9b939b2..2ec5d4e1f363 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/nv.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c<br>
@@ -764,9 +764,15 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)<br>
         case CHIP_SIENNA_CICHLID:<br>
                 amdgpu_device_ip_block_add(adev, &nv_common_ip_block);<br>
                 amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block);<br>
-               amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);<br>
-               if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP))<br>
-                       amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);<br>
+               if (!amdgpu_sriov_vf(adev)) {<br>
+                       amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);<br>
+                       if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP))<br>
+                               amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);<br>
+               } else {<br>
+                       if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP))<br>
+                               amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);<br>
+                       amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);<br>
+               }<br>
                 if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP &&<br>
                     is_support_sw_smu(adev))<br>
                         amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>