<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<p style="font-family:Arial;font-size:10pt;color:#317100;margin:15pt;" align="Left">
[AMD Public Use]<br>
</p>
<br>
<div>
<div class="WordSection1">
<p class="MsoNormal">Reviewed-by: Chen, Horace <a href="mailto:Horace.Chen@amd.com">
Horace.Chen@amd.com</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Deucher, Alexander <Alexander.Deucher@amd.com> <br>
<b>Sent:</b> Thursday, May 13, 2021 10:12 PM<br>
<b>To:</b> Wang, YuBiao <YuBiao.Wang@amd.com>; 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>; 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><br>
<b>Subject:</b> Re: [PATCH] drm/amd/amdgpu: psp program IH_RB_CTRL on sienna_cichlid<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p style="margin:15.0pt"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#317100">[AMD Public Use]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Acked-by: Alex Deucher <<a href="mailto:alexander.deucher@amd.com">alexander.deucher@amd.com</a>><o:p></o:p></span></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> YuBiao Wang <<a href="mailto:YuBiao.Wang@amd.com">YuBiao.Wang@amd.com</a>><br>
<b>Sent:</b> Thursday, May 13, 2021 6:33 AM<br>
<b>To:</b> <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a> <<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>><br>
<b>Cc:</b> Grodzovsky, Andrey <<a href="mailto:Andrey.Grodzovsky@amd.com">Andrey.Grodzovsky@amd.com</a>>; Quan, Evan <<a href="mailto:Evan.Quan@amd.com">Evan.Quan@amd.com</a>>; Chen, Horace <<a href="mailto:Horace.Chen@amd.com">Horace.Chen@amd.com</a>>; Tuikov,
 Luben <<a href="mailto:Luben.Tuikov@amd.com">Luben.Tuikov@amd.com</a>>; Koenig, Christian <<a href="mailto:Christian.Koenig@amd.com">Christian.Koenig@amd.com</a>>; Deucher, Alexander <<a href="mailto:Alexander.Deucher@amd.com">Alexander.Deucher@amd.com</a>>;
 Xiao, Jack <<a href="mailto:Jack.Xiao@amd.com">Jack.Xiao@amd.com</a>>; Zhang, Hawking <<a href="mailto:Hawking.Zhang@amd.com">Hawking.Zhang@amd.com</a>>; Liu, Monk <<a href="mailto:Monk.Liu@amd.com">Monk.Liu@amd.com</a>>; Xu, Feifei <<a href="mailto:Feifei.Xu@amd.com">Feifei.Xu@amd.com</a>>;
 Wang, Kevin(Yang) <<a href="mailto:Kevin1.Wang@amd.com">Kevin1.Wang@amd.com</a>>; Xiaojie Yuan <<a href="mailto:xiaojie.yuan@amd.com">xiaojie.yuan@amd.com</a>>; Wang, YuBiao <<a href="mailto:YuBiao.Wang@amd.com">YuBiao.Wang@amd.com</a>><br>
<b>Subject:</b> [PATCH] drm/amd/amdgpu: psp program IH_RB_CTRL on sienna_cichlid</span>
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">[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 <<a href="mailto:YuBiao.Wang@amd.com">YuBiao.Wang@amd.com</a>><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<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>