<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:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">Reviewed-by: David Nieto <david.nieto@amd.com></span><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> Skvortsov, Victor <Victor.Skvortsov@amd.com><br>
<b>Sent:</b> Thursday, December 16, 2021 11:42 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deng, Emily <Emily.Deng@amd.com>; Liu, Monk <Monk.Liu@amd.com>; Ming, Davis <Davis.Ming@amd.com>; Liu, Shaoyun <Shaoyun.Liu@amd.com>; Zhou, Peng Ju <PengJu.Zhou@amd.com>; Chen, JingWen
<JingWen.Chen2@amd.com>; Chen, Horace <Horace.Chen@amd.com>; Nieto, David M <David.Nieto@amd.com><br>
<b>Cc:</b> Skvortsov, Victor <Victor.Skvortsov@amd.com><br>
<b>Subject:</b> [PATCH v3 2/5] drm/amdgpu: Modify indirect register access for gmc_v9_0 sriov</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Modify GC register access from MMIO to RLCG if the<br>
indirect flag is set<br>
<br>
v2: Replaced ternary operator with if-else for better<br>
readability<br>
<br>
Signed-off-by: Victor Skvortsov <victor.skvortsov@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 57 ++++++++++++++++++++-------<br>
1 file changed, 43 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c<br>
index a5471923b3f6..2b86c63b032a 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c<br>
@@ -478,9 +478,18 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct amdgpu_device *adev,<br>
hub = &adev->vmhub[j];<br>
for (i = 0; i < 16; i++) {<br>
reg = hub->vm_context0_cntl + i;<br>
- tmp = RREG32(reg);<br>
+<br>
+ if (j == AMDGPU_GFXHUB_0)<br>
+ tmp = RREG32_SOC15_IP(GC, reg);<br>
+ else<br>
+ tmp = RREG32_SOC15_IP(MMHUB, reg);<br>
+<br>
tmp &= ~bits;<br>
- WREG32(reg, tmp);<br>
+<br>
+ if (j == AMDGPU_GFXHUB_0)<br>
+ WREG32_SOC15_IP(GC, reg, tmp);<br>
+ else<br>
+ WREG32_SOC15_IP(MMHUB, reg, tmp);<br>
}<br>
}<br>
break;<br>
@@ -489,9 +498,18 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct amdgpu_device *adev,<br>
hub = &adev->vmhub[j];<br>
for (i = 0; i < 16; i++) {<br>
reg = hub->vm_context0_cntl + i;<br>
- tmp = RREG32(reg);<br>
+<br>
+ if (j == AMDGPU_GFXHUB_0)<br>
+ tmp = RREG32_SOC15_IP(GC, reg);<br>
+ else<br>
+ tmp = RREG32_SOC15_IP(MMHUB, reg);<br>
+<br>
tmp |= bits;<br>
- WREG32(reg, tmp);<br>
+<br>
+ if (j == AMDGPU_GFXHUB_0)<br>
+ WREG32_SOC15_IP(GC, reg, tmp);<br>
+ else<br>
+ WREG32_SOC15_IP(MMHUB, reg, tmp);<br>
}<br>
}<br>
break;<br>
@@ -788,9 +806,12 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,<br>
/* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */<br>
if (use_semaphore) {<br>
for (j = 0; j < adev->usec_timeout; j++) {<br>
- /* a read return value of 1 means semaphore acuqire */<br>
- tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_sem +<br>
- hub->eng_distance * eng);<br>
+ /* a read return value of 1 means semaphore acquire */<br>
+ if (vmhub == AMDGPU_GFXHUB_0)<br>
+ tmp = RREG32_SOC15_IP_NO_KIQ(GC, hub->vm_inv_eng0_sem + hub->eng_distance * eng);<br>
+ else<br>
+ tmp = RREG32_SOC15_IP_NO_KIQ(MMHUB, hub->vm_inv_eng0_sem + hub->eng_distance * eng);<br>
+<br>
if (tmp & 0x1)<br>
break;<br>
udelay(1);<br>
@@ -801,8 +822,10 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,<br>
}<br>
<br>
do {<br>
- WREG32_NO_KIQ(hub->vm_inv_eng0_req +<br>
- hub->eng_distance * eng, inv_req);<br>
+ if (vmhub == AMDGPU_GFXHUB_0)<br>
+ WREG32_SOC15_IP_NO_KIQ(GC, hub->vm_inv_eng0_req + hub->eng_distance * eng, inv_req);<br>
+ else<br>
+ WREG32_SOC15_IP_NO_KIQ(MMHUB, hub->vm_inv_eng0_req + hub->eng_distance * eng, inv_req);<br>
<br>
/*<br>
* Issue a dummy read to wait for the ACK register to<br>
@@ -815,8 +838,11 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,<br>
hub->eng_distance * eng);<br>
<br>
for (j = 0; j < adev->usec_timeout; j++) {<br>
- tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_ack +<br>
- hub->eng_distance * eng);<br>
+ if (vmhub == AMDGPU_GFXHUB_0)<br>
+ tmp = RREG32_SOC15_IP_NO_KIQ(GC, hub->vm_inv_eng0_ack + hub->eng_distance * eng);<br>
+ else<br>
+ tmp = RREG32_SOC15_IP_NO_KIQ(MMHUB, hub->vm_inv_eng0_ack + hub->eng_distance * eng);<br>
+<br>
if (tmp & (1 << vmid))<br>
break;<br>
udelay(1);<br>
@@ -827,13 +853,16 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,<br>
} while (inv_req);<br>
<br>
/* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */<br>
- if (use_semaphore)<br>
+ if (use_semaphore) {<br>
/*<br>
* add semaphore release after invalidation,<br>
* write with 0 means semaphore release<br>
*/<br>
- WREG32_NO_KIQ(hub->vm_inv_eng0_sem +<br>
- hub->eng_distance * eng, 0);<br>
+ if (vmhub == AMDGPU_GFXHUB_0)<br>
+ WREG32_SOC15_IP_NO_KIQ(GC, hub->vm_inv_eng0_sem + hub->eng_distance * eng, 0);<br>
+ else<br>
+ WREG32_SOC15_IP_NO_KIQ(MMHUB, hub->vm_inv_eng0_sem + hub->eng_distance * eng, 0);<br>
+ }<br>
<br>
spin_unlock(&adev->gmc.invalidate_lock);<br>
<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>