<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:Aptos;}
@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:12.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#467886;
        text-decoration:underline;}
span.EmailStyle21
        {mso-style-type:personal-compose;
        font-family:"Arial",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@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="#467886" vlink="#96607D" style="word-wrap:break-word">
<p style="font-family:Calibri;font-size:10pt;color:#008000;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[Public]<br>
</p>
<br>
<div>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">It seems that there is no reason to write the same register bitfield separately as no HW sequence required that. Moreover, there is a similar program sequence in the KFD which
 directly programs the RLC_CP_SCHEDULERS register once.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Prike<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Deucher, Alexander <Alexander.Deucher@amd.com>
<br>
<b>Sent:</b> Wednesday, November 20, 2024 2:29 AM<br>
<b>To:</b> Liang, Prike <Prike.Liang@amd.com>; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: reduce the mmio writes in kiq setting<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:green">[Public]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="color:black">As long as there is no hw programming sequence requirement to do it as two separate writes this looks fine to me.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="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="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> Liang, Prike <<a href="mailto:Prike.Liang@amd.com">Prike.Liang@amd.com</a>><br>
<b>Sent:</b> Friday, November 15, 2024 3:39 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> Deucher, Alexander <<a href="mailto:Alexander.Deucher@amd.com">Alexander.Deucher@amd.com</a>>; Liang, Prike <<a href="mailto:Prike.Liang@amd.com">Prike.Liang@amd.com</a>><br>
<b>Subject:</b> [PATCH] drm/amdgpu: reduce the mmio writes in kiq setting</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"><span style="font-size:11.0pt">There's no need to perform the two MMIO writes in the KIQ<br>
Setting registers programmed period, and reducing the MMIO<br>
writes will save the driver loading time.<br>
<br>
Signed-off-by: Prike Liang <<a href="mailto:Prike.Liang@amd.com">Prike.Liang@amd.com</a>><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 8 ++------<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 4 +---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 4 +---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 4 +---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 4 +---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 4 +---<br>
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c  | 4 +---<br>
 drivers/gpu/drm/amd/amdgpu/mes_v12_0.c  | 4 +---<br>
 8 files changed, 9 insertions(+), 27 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c<br>
index 9da95b25e158..ffd3c45b4ccd 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c<br>
@@ -6593,17 +6593,13 @@ static void gfx_v10_0_kiq_setting(struct amdgpu_ring *ring)<br>
                 tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS_Sienna_Cichlid);<br>
                 tmp &= 0xffffff00;<br>
                 tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);<br>
-               WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS_Sienna_Cichlid, tmp);<br>
-               tmp |= 0x80;<br>
-               WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS_Sienna_Cichlid, tmp);<br>
+               WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS_Sienna_Cichlid, tmp | 0x80);<br>
                 break;<br>
         default:<br>
                 tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS);<br>
                 tmp &= 0xffffff00;<br>
                 tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);<br>
-               WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp);<br>
-               tmp |= 0x80;<br>
-               WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp);<br>
+               WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp | 0x80);<br>
                 break;<br>
         }<br>
 }<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c<br>
index 5aff8f72de9c..a2aedcabae65 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c<br>
@@ -3890,9 +3890,7 @@ static void gfx_v11_0_kiq_setting(struct amdgpu_ring *ring)<br>
         tmp = RREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS);<br>
         tmp &= 0xffffff00;<br>
         tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);<br>
-       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp);<br>
-       tmp |= 0x80;<br>
-       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp);<br>
+       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp | 0x80);<br>
 }<br>
 <br>
 static void gfx_v11_0_cp_set_doorbell_range(struct amdgpu_device *adev)<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c<br>
index 9fec28d8a5fc..c61d383c45c4 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c<br>
@@ -2826,9 +2826,7 @@ static void gfx_v12_0_kiq_setting(struct amdgpu_ring *ring)<br>
         tmp = RREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS);<br>
         tmp &= 0xffffff00;<br>
         tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);<br>
-       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp);<br>
-       tmp |= 0x80;<br>
-       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp);<br>
+       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp | 0x80);<br>
 }<br>
 <br>
 static void gfx_v12_0_cp_set_doorbell_range(struct amdgpu_device *adev)<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 480c41ee947e..d465c3ea6e6c 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
@@ -4304,9 +4304,7 @@ static void gfx_v8_0_kiq_setting(struct amdgpu_ring *ring)<br>
         tmp = RREG32(mmRLC_CP_SCHEDULERS);<br>
         tmp &= 0xffffff00;<br>
         tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);<br>
-       WREG32(mmRLC_CP_SCHEDULERS, tmp);<br>
-       tmp |= 0x80;<br>
-       WREG32(mmRLC_CP_SCHEDULERS, tmp);<br>
+       WREG32(mmRLC_CP_SCHEDULERS, tmp | 0x80);<br>
 }<br>
 <br>
 static int gfx_v8_0_kiq_kcq_enable(struct amdgpu_device *adev)<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
index e9248a855ba7..a6cb30558f2f 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
@@ -3482,9 +3482,7 @@ static void gfx_v9_0_kiq_setting(struct amdgpu_ring *ring)<br>
         tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS);<br>
         tmp &= 0xffffff00;<br>
         tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);<br>
-       WREG32_SOC15_RLC(GC, 0, mmRLC_CP_SCHEDULERS, tmp);<br>
-       tmp |= 0x80;<br>
-       WREG32_SOC15_RLC(GC, 0, mmRLC_CP_SCHEDULERS, tmp);<br>
+       WREG32_SOC15_RLC(GC, 0, mmRLC_CP_SCHEDULERS, tmp | 0x80);<br>
 }<br>
 <br>
 static void gfx_v9_0_mqd_set_priority(struct amdgpu_ring *ring, struct v9_mqd *mqd)<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c<br>
index 016290f00592..ae3c8645633b 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c<br>
@@ -1771,9 +1771,7 @@ static void gfx_v9_4_3_xcc_kiq_setting(struct amdgpu_ring *ring, int xcc_id)<br>
         tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regRLC_CP_SCHEDULERS);<br>
         tmp &= 0xffffff00;<br>
         tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);<br>
-       WREG32_SOC15_RLC(GC, GET_INST(GC, xcc_id), regRLC_CP_SCHEDULERS, tmp);<br>
-       tmp |= 0x80;<br>
-       WREG32_SOC15_RLC(GC, GET_INST(GC, xcc_id), regRLC_CP_SCHEDULERS, tmp);<br>
+       WREG32_SOC15_RLC(GC, GET_INST(GC, xcc_id), regRLC_CP_SCHEDULERS, tmp | 0x80);<br>
 }<br>
 <br>
 static void gfx_v9_4_3_mqd_set_priority(struct amdgpu_ring *ring, struct v9_mqd *mqd)<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c<br>
index 8ca137313961..3b818441c7ba 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c<br>
@@ -1491,9 +1491,7 @@ static void mes_v11_0_kiq_setting(struct amdgpu_ring *ring)<br>
         tmp = RREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS);<br>
         tmp &= 0xffffff00;<br>
         tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);<br>
-       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp);<br>
-       tmp |= 0x80;<br>
-       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp);<br>
+       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp | 0x80);<br>
 }<br>
 <br>
 static void mes_v11_0_kiq_clear(struct amdgpu_device *adev)<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v12_0.c b/drivers/gpu/drm/amd/amdgpu/mes_v12_0.c<br>
index 9d0e342a2f81..44b0d0f76944 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mes_v12_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v12_0.c<br>
@@ -1453,9 +1453,7 @@ static void mes_v12_0_kiq_setting(struct amdgpu_ring *ring)<br>
         tmp = RREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS);<br>
         tmp &= 0xffffff00;<br>
         tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);<br>
-       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp);<br>
-       tmp |= 0x80;<br>
-       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp);<br>
+       WREG32_SOC15(GC, 0, regRLC_CP_SCHEDULERS, tmp | 0x80);<br>
 }<br>
 <br>
 static int mes_v12_0_kiq_hw_init(struct amdgpu_device *adev)<br>
-- <br>
2.34.1<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>