<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:#317100;margin:15pt;" align="Left">
[AMD Public Use]<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> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Huang Rui <ray.huang@amd.com><br>
<b>Sent:</b> Tuesday, August 11, 2020 2:27 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Kuehling, Felix <Felix.Kuehling@amd.com>; Huang, Ray <Ray.Huang@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdkfd: fix the wrong sdma instance query for renoir</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Renoir only has one sdma instance, it will get failed once query the<br>
sdma1 registers. So use switch-case instead of static register array.<br>
<br>
Signed-off-by: Huang Rui <ray.huang@amd.com><br>
---<br>
.../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 31 +++++++++++++------<br>
1 file changed, 22 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c<br>
index 032d3c866280..23ccfe0ad5d4 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c<br>
@@ -197,19 +197,32 @@ static uint32_t get_sdma_rlc_reg_offset(struct amdgpu_device *adev,<br>
unsigned int engine_id,<br>
unsigned int queue_id)<br>
{<br>
- uint32_t sdma_engine_reg_base[2] = {<br>
- SOC15_REG_OFFSET(SDMA0, 0,<br>
- mmSDMA0_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL,<br>
- SOC15_REG_OFFSET(SDMA1, 0,<br>
- mmSDMA1_RLC0_RB_CNTL) - mmSDMA1_RLC0_RB_CNTL<br>
- };<br>
- uint32_t retval = sdma_engine_reg_base[engine_id]<br>
+ uint32_t sdma_engine_reg_base = 0;<br>
+ uint32_t sdma_rlc_reg_offset;<br>
+<br>
+ switch (engine_id) {<br>
+ default:<br>
+ dev_warn(adev->dev,<br>
+ "Invalid sdma engine id (%d), using engine id 0\n",<br>
+ engine_id);<br>
+ /* fall through */<br>
+ case 0:<br>
+ sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA0, 0,<br>
+ mmSDMA0_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL;<br>
+ break;<br>
+ case 1:<br>
+ sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA1, 0,<br>
+ mmSDMA1_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL;<br>
+ break;<br>
+ }<br>
+<br>
+ sdma_rlc_reg_offset = sdma_engine_reg_base<br>
+ queue_id * (mmSDMA0_RLC1_RB_CNTL - mmSDMA0_RLC0_RB_CNTL);<br>
<br>
pr_debug("RLC register offset for SDMA%d RLC%d: 0x%x\n", engine_id,<br>
- queue_id, retval);<br>
+ queue_id, sdma_rlc_reg_offset);<br>
<br>
- return retval;<br>
+ return sdma_rlc_reg_offset;<br>
}<br>
<br>
static inline struct v9_mqd *get_mqd(void *mqd)<br>
-- <br>
2.25.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Calexander.deucher%40amd.com%7C575d3b20ab90469e7a5208d83dbfa612%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637327240654534583&sdata=u%2By9MwOEH7bGIQbajnefKann2HyJ%2FWRG6I91FBgVakM%3D&reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Calexander.deucher%40amd.com%7C575d3b20ab90469e7a5208d83dbfa612%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637327240654534583&sdata=u%2By9MwOEH7bGIQbajnefKann2HyJ%2FWRG6I91FBgVakM%3D&reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>