<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);">
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> Zhang, Yifan <Yifan1.Zhang@amd.com><br>
<b>Sent:</b> Tuesday, June 7, 2022 10:36 AM<br>
<b>To:</b> Zhang, Yifan <Yifan1.Zhang@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Huang, Ray <Ray.Huang@amd.com>; Huang, Tim <Tim.Huang@amd.com>; Du, Xiaojian <Xiaojian.Du@amd.com><br>
<b>Subject:</b> RE: [PATCH] drm/amdgpu/mes: only invalid/prime icache after finish loading both pipe MES FWs.</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">[AMD Official Use Only - General]<br>
<br>
Ping<br>
<br>
-----Original Message-----<br>
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Yifan Zhang<br>
Sent: Monday, June 6, 2022 6:40 PM<br>
To: amd-gfx@lists.freedesktop.org<br>
Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Zhang, Yifan <Yifan1.Zhang@amd.com>; Huang, Ray <Ray.Huang@amd.com><br>
Subject: [PATCH] drm/amdgpu/mes: only invalid/prime icache after finish loading both pipe MES FWs.<br>
<br>
invalid/prime icahce operation takes effect on both pipes cuconrrently, therefore CP_MES_IC_BASE_LO/HI and CP_MES_MDBASE_LO/HI have to be both set before prime icache. Otherwise MES hardware gets garbage data in above regsters and causes page fault<br>
<br>
[ 470.873200] amdgpu 0000:33:00.0: amdgpu: [gfxhub] page fault (src_id:0 ring:217 vmid:0 pasid:0, for process pid 0 thread pid 0)<br>
[ 470.873222] amdgpu 0000:33:00.0: amdgpu: in page starting at address 0x000092cb89b00000 from client 10<br>
[ 470.873234] amdgpu 0000:33:00.0: amdgpu: GCVM_L2_PROTECTION_FAULT_STATUS:0x00000BB3<br>
[ 470.873242] amdgpu 0000:33:00.0: amdgpu: Faulty UTCL2 client ID: CPC (0x5)<br>
[ 470.873247] amdgpu 0000:33:00.0: amdgpu: MORE_FAULTS: 0x1<br>
[ 470.873251] amdgpu 0000:33:00.0: amdgpu: WALKER_ERROR: 0x1<br>
[ 470.873256] amdgpu 0000:33:00.0: amdgpu: PERMISSION_FAULTS: 0xb<br>
[ 470.873260] amdgpu 0000:33:00.0: amdgpu: MAPPING_ERROR: 0x1<br>
[ 470.873264] amdgpu 0000:33:00.0: amdgpu: RW: 0x0<br>
<br>
Signed-off-by: Yifan Zhang <yifan1.zhang@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 32 +++++++++++++++-----------<br>
1 file changed, 18 insertions(+), 14 deletions(-)<br>
<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 fcf51947bb18..9741b7ff4224 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c<br>
@@ -541,7 +541,7 @@ static void mes_v11_0_enable(struct amdgpu_device *adev, bool enable)<br>
<br>
/* This function is for backdoor MES firmware */ static int mes_v11_0_load_microcode(struct amdgpu_device *adev,<br>
- enum admgpu_mes_pipe pipe)<br>
+ enum admgpu_mes_pipe pipe, bool prime_icache)<br>
{<br>
int r;<br>
uint32_t data;<br>
@@ -593,16 +593,18 @@ static int mes_v11_0_load_microcode(struct amdgpu_device *adev,<br>
/* Set 0x3FFFF (256K-1) to CP_MES_MDBOUND_LO */<br>
WREG32_SOC15(GC, 0, regCP_MES_MDBOUND_LO, 0x3FFFF);<br>
<br>
- /* invalidate ICACHE */<br>
- data = RREG32_SOC15(GC, 0, regCP_MES_IC_OP_CNTL);<br>
- data = REG_SET_FIELD(data, CP_MES_IC_OP_CNTL, PRIME_ICACHE, 0);<br>
- data = REG_SET_FIELD(data, CP_MES_IC_OP_CNTL, INVALIDATE_CACHE, 1);<br>
- WREG32_SOC15(GC, 0, regCP_MES_IC_OP_CNTL, data);<br>
-<br>
- /* prime the ICACHE. */<br>
- data = RREG32_SOC15(GC, 0, regCP_MES_IC_OP_CNTL);<br>
- data = REG_SET_FIELD(data, CP_MES_IC_OP_CNTL, PRIME_ICACHE, 1);<br>
- WREG32_SOC15(GC, 0, regCP_MES_IC_OP_CNTL, data);<br>
+ if (prime_icache) {<br>
+ /* invalidate ICACHE */<br>
+ data = RREG32_SOC15(GC, 0, regCP_MES_IC_OP_CNTL);<br>
+ data = REG_SET_FIELD(data, CP_MES_IC_OP_CNTL, PRIME_ICACHE, 0);<br>
+ data = REG_SET_FIELD(data, CP_MES_IC_OP_CNTL, INVALIDATE_CACHE, 1);<br>
+ WREG32_SOC15(GC, 0, regCP_MES_IC_OP_CNTL, data);<br>
+<br>
+ /* prime the ICACHE. */<br>
+ data = RREG32_SOC15(GC, 0, regCP_MES_IC_OP_CNTL);<br>
+ data = REG_SET_FIELD(data, CP_MES_IC_OP_CNTL, PRIME_ICACHE, 1);<br>
+ WREG32_SOC15(GC, 0, regCP_MES_IC_OP_CNTL, data);<br>
+ }<br>
<br>
soc21_grbm_select(adev, 0, 0, 0, 0);<br>
mutex_unlock(&adev->srbm_mutex);<br>
@@ -1044,17 +1046,19 @@ static int mes_v11_0_kiq_hw_init(struct amdgpu_device *adev)<br>
int r = 0;<br>
<br>
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {<br>
- r = mes_v11_0_load_microcode(adev, AMDGPU_MES_KIQ_PIPE);<br>
+<br>
+ r = mes_v11_0_load_microcode(adev, AMDGPU_MES_KIQ_PIPE, true);<br>
if (r) {<br>
DRM_ERROR("failed to load MES kiq fw, r=%d\n", r);<br>
return r;<br>
}<br>
<br>
- r = mes_v11_0_load_microcode(adev, AMDGPU_MES_SCHED_PIPE);<br>
+ r = mes_v11_0_load_microcode(adev, AMDGPU_MES_SCHED_PIPE, false);<br>
if (r) {<br>
DRM_ERROR("failed to load MES fw, r=%d\n", r);<br>
return r;<br>
}<br>
+<br>
}<br>
<br>
mes_v11_0_enable(adev, true);<br>
@@ -1086,7 +1090,7 @@ static int mes_v11_0_hw_init(void *handle)<br>
if (!adev->enable_mes_kiq) {<br>
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {<br>
r = mes_v11_0_load_microcode(adev,<br>
- AMDGPU_MES_SCHED_PIPE);<br>
+ AMDGPU_MES_SCHED_PIPE, true);<br>
if (r) {<br>
DRM_ERROR("failed to MES fw, r=%d\n", r);<br>
return r;<br>
--<br>
2.35.1<br>
</div>
</span></font></div>
</div>
</body>
</html>