<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:#008000;margin:15pt;" align="Left">
[Public]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-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> Khaire, Rohit <Rohit.Khaire@amd.com><br>
<b>Sent:</b> Friday, June 4, 2021 12:38 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Deng, Emily <Emily.Deng@amd.com>; Liu, Monk <Monk.Liu@amd.com>; Zhou, Peng Ju <PengJu.Zhou@amd.com>;
 Chen, Horace <Horace.Chen@amd.com><br>
<b>Cc:</b> Ming, Davis <Davis.Ming@amd.com>; Khaire, Rohit <Rohit.Khaire@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Khaire, Rohit <Rohit.Khaire@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: Modify GC register access to use _SOC15 macros</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">In SRIOV environment, KMD should access GC registers<br>
with RLCG if GC indirect access flag enabled.<br>
<br>
Using _SOC15 read/write macros ensures that they go<br>
through RLC when flag is enabled.<br>
<br>
Signed-off-by: Rohit Khaire <rohit.khaire@amd.com><br>
---<br>
 .../drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c  | 42 +++++++++----------<br>
 1 file changed, 21 insertions(+), 21 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c<br>
index d39cff4a1fe3..1f5620cc3570 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c<br>
@@ -95,8 +95,8 @@ static void program_sh_mem_settings_v10_3(struct kgd_dev *kgd, uint32_t vmid,<br>
 <br>
         lock_srbm(kgd, 0, 0, 0, vmid);<br>
 <br>
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmSH_MEM_CONFIG), sh_mem_config);<br>
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmSH_MEM_BASES), sh_mem_bases);<br>
+       WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, sh_mem_config);<br>
+       WREG32_SOC15(GC, 0, mmSH_MEM_BASES, sh_mem_bases);<br>
         /* APE1 no longer exists on GFX9 */<br>
 <br>
         unlock_srbm(kgd);<br>
@@ -129,7 +129,7 @@ static int init_interrupts_v10_3(struct kgd_dev *kgd, uint32_t pipe_id)<br>
 <br>
         lock_srbm(kgd, mec, pipe, 0, 0);<br>
 <br>
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCPC_INT_CNTL),<br>
+       WREG32_SOC15(GC, 0, mmCPC_INT_CNTL,<br>
                 CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK |<br>
                 CP_INT_CNTL_RING0__OPCODE_ERROR_INT_ENABLE_MASK);<br>
 <br>
@@ -212,10 +212,10 @@ static int hqd_load_v10_3(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,<br>
 <br>
                 pr_debug("kfd: set HIQ, mec:%d, pipe:%d, queue:%d.\n",<br>
                         mec, pipe, queue_id);<br>
-               value = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CP_SCHEDULERS));<br>
+               value = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS);<br>
                 value = REG_SET_FIELD(value, RLC_CP_SCHEDULERS, scheduler1,<br>
                         ((mec << 5) | (pipe << 3) | queue_id | 0x80));<br>
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CP_SCHEDULERS), value);<br>
+               WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, value);<br>
         }<br>
 <br>
         /* HQD registers extend from CP_MQD_BASE_ADDR to CP_HQD_EOP_WPTR_MEM. */<br>
@@ -224,13 +224,13 @@ static int hqd_load_v10_3(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,<br>
 <br>
         for (reg = hqd_base;<br>
              reg <= SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_HI); reg++)<br>
-               WREG32(reg, mqd_hqd[reg - hqd_base]);<br>
+               WREG32_SOC15_IP(GC, reg, mqd_hqd[reg - hqd_base]);<br>
 <br>
 <br>
         /* Activate doorbell logic before triggering WPTR poll. */<br>
         data = REG_SET_FIELD(m->cp_hqd_pq_doorbell_control,<br>
                              CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);<br>
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL), data);<br>
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, data);<br>
 <br>
         if (wptr) {<br>
                 /* Don't read wptr with get_user because the user<br>
@@ -259,17 +259,17 @@ static int hqd_load_v10_3(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,<br>
                 guessed_wptr += m->cp_hqd_pq_wptr_lo & ~(queue_size - 1);<br>
                 guessed_wptr += (uint64_t)m->cp_hqd_pq_wptr_hi << 32;<br>
 <br>
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_LO),<br>
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO,<br>
                        lower_32_bits(guessed_wptr));<br>
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_HI),<br>
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI,<br>
                        upper_32_bits(guessed_wptr));<br>
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR),<br>
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR,<br>
                        lower_32_bits((uint64_t)wptr));<br>
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR_HI),<br>
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR_HI,<br>
                        upper_32_bits((uint64_t)wptr));<br>
                 pr_debug("%s setting CP_PQ_WPTR_POLL_CNTL1 to %x\n", __func__,<br>
                          (uint32_t)get_queue_mask(adev, pipe_id, queue_id));<br>
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_PQ_WPTR_POLL_CNTL1),<br>
+               WREG32_SOC15(GC, 0, mmCP_PQ_WPTR_POLL_CNTL1,<br>
                        (uint32_t)get_queue_mask(adev, pipe_id, queue_id));<br>
         }<br>
 <br>
@@ -279,7 +279,7 @@ static int hqd_load_v10_3(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,<br>
                              CP_HQD_EOP_RPTR, INIT_FETCHER, 1));<br>
 <br>
         data = REG_SET_FIELD(m->cp_hqd_active, CP_HQD_ACTIVE, ACTIVE, 1);<br>
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE), data);<br>
+       WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE, data);<br>
 <br>
         release_queue(kgd);<br>
 <br>
@@ -350,7 +350,7 @@ static int hqd_dump_v10_3(struct kgd_dev *kgd,<br>
                 if (WARN_ON_ONCE(i >= HQD_N_REGS))      \<br>
                         break;                          \<br>
                 (*dump)[i][0] = (addr) << 2;            \<br>
-               (*dump)[i++][1] = RREG32(addr);         \<br>
+               (*dump)[i++][1] = RREG32_SOC15_IP(GC, addr);            \<br>
         } while (0)<br>
 <br>
         *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);<br>
@@ -482,13 +482,13 @@ static bool hqd_is_occupied_v10_3(struct kgd_dev *kgd, uint64_t queue_address,<br>
         uint32_t low, high;<br>
 <br>
         acquire_queue(kgd, pipe_id, queue_id);<br>
-       act = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE));<br>
+       act = RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE);<br>
         if (act) {<br>
                 low = lower_32_bits(queue_address >> 8);<br>
                 high = upper_32_bits(queue_address >> 8);<br>
 <br>
-               if (low == RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_BASE)) &&<br>
-                  high == RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_BASE_HI)))<br>
+               if (low == RREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE) &&<br>
+                  high == RREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE_HI))<br>
                         retval = true;<br>
         }<br>
         release_queue(kgd);<br>
@@ -542,11 +542,11 @@ static int hqd_destroy_v10_3(struct kgd_dev *kgd, void *mqd,<br>
                 break;<br>
         }<br>
 <br>
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_DEQUEUE_REQUEST), type);<br>
+       WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, type);<br>
 <br>
         end_jiffies = (utimeout * HZ / 1000) + jiffies;<br>
         while (true) {<br>
-               temp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE));<br>
+               temp = RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE);<br>
                 if (!(temp & CP_HQD_ACTIVE__ACTIVE_MASK))<br>
                         break;<br>
                 if (time_after(jiffies, end_jiffies)) {<br>
@@ -626,7 +626,7 @@ static int wave_control_execute_v10_3(struct kgd_dev *kgd,<br>
 <br>
         mutex_lock(&adev->grbm_idx_mutex);<br>
 <br>
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_GFX_INDEX), gfx_index_val);<br>
+       WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX, gfx_index_val);<br>
         WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_CMD), sq_cmd);<br>
 <br>
         data = REG_SET_FIELD(data, GRBM_GFX_INDEX,<br>
@@ -636,7 +636,7 @@ static int wave_control_execute_v10_3(struct kgd_dev *kgd,<br>
         data = REG_SET_FIELD(data, GRBM_GFX_INDEX,<br>
                 SE_BROADCAST_WRITES, 1);<br>
 <br>
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_GFX_INDEX), data);<br>
+       WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX, data);<br>
         mutex_unlock(&adev->grbm_idx_mutex);<br>
 <br>
         return 0;<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>