<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">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Yong Zhao <Yong.Zhao@amd.com></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 Cornwall, Jay <Jay.Cornwall@amd.com><br>
<b>Sent:</b> Wednesday, September 25, 2019 6:06 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Cornwall, Jay <Jay.Cornwall@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdkfd: Fix race in gfx10 context restore handler</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Missing synchronization with VGPR restore leads to intermittent<br>
VGPR trashing in the user shader.<br>
<br>
Signed-off-by: Jay Cornwall <jay.cornwall@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h | 139 +++++++++++----------<br>
.../gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm | 1 +<br>
2 files changed, 71 insertions(+), 69 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h<br>
index 901fe35..d3400da 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h<br>
+++ b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h<br>
@@ -905,7 +905,7 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {<br>
0x7a5d0000, 0x807c817c,<br>
0x807aff7a, 0x00000080,<br>
0xbf0a717c, 0xbf85fff8,<br>
- 0xbf820141, 0xbef4037e,<br>
+ 0xbf820142, 0xbef4037e,<br>
0x8775ff7f, 0x0000ffff,<br>
0x8875ff75, 0x00040000,<br>
0xbef60380, 0xbef703ff,<br>
@@ -967,7 +967,7 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {<br>
0x725d0000, 0xe0304080,<br>
0x725d0100, 0xe0304100,<br>
0x725d0200, 0xe0304180,<br>
- 0x725d0300, 0xbf820031,<br>
+ 0x725d0300, 0xbf820032,<br>
0xbef603ff, 0x01000000,<br>
0xbef20378, 0x8078ff78,<br>
0x00000400, 0xbefc0384,<br>
@@ -992,83 +992,84 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {<br>
0x725d0000, 0xe0304100,<br>
0x725d0100, 0xe0304200,<br>
0x725d0200, 0xe0304300,<br>
- 0x725d0300, 0xb9782a05,<br>
- 0x80788178, 0x907c9973,<br>
- 0x877c817c, 0xbf06817c,<br>
- 0xbf850002, 0x8f788978,<br>
- 0xbf820001, 0x8f788a78,<br>
- 0xb9721e06, 0x8f728a72,<br>
- 0x80787278, 0x8078ff78,<br>
- 0x00000200, 0x80f8ff78,<br>
- 0x00000050, 0xbef603ff,<br>
- 0x01000000, 0xbefc03ff,<br>
- 0x0000006c, 0x80f89078,<br>
- 0xf429003a, 0xf0000000,<br>
- 0xbf8cc07f, 0x80fc847c,<br>
- 0xbf800000, 0xbe803100,<br>
- 0xbe823102, 0x80f8a078,<br>
- 0xf42d003a, 0xf0000000,<br>
- 0xbf8cc07f, 0x80fc887c,<br>
- 0xbf800000, 0xbe803100,<br>
- 0xbe823102, 0xbe843104,<br>
- 0xbe863106, 0x80f8c078,<br>
- 0xf431003a, 0xf0000000,<br>
- 0xbf8cc07f, 0x80fc907c,<br>
- 0xbf800000, 0xbe803100,<br>
- 0xbe823102, 0xbe843104,<br>
- 0xbe863106, 0xbe883108,<br>
- 0xbe8a310a, 0xbe8c310c,<br>
- 0xbe8e310e, 0xbf06807c,<br>
- 0xbf84fff0, 0xb9782a05,<br>
- 0x80788178, 0x907c9973,<br>
- 0x877c817c, 0xbf06817c,<br>
- 0xbf850002, 0x8f788978,<br>
- 0xbf820001, 0x8f788a78,<br>
- 0xb9721e06, 0x8f728a72,<br>
- 0x80787278, 0x8078ff78,<br>
- 0x00000200, 0xbef603ff,<br>
- 0x01000000, 0xf4211bfa,<br>
+ 0x725d0300, 0xbf8c3f70,<br>
+ 0xb9782a05, 0x80788178,<br>
+ 0x907c9973, 0x877c817c,<br>
+ 0xbf06817c, 0xbf850002,<br>
+ 0x8f788978, 0xbf820001,<br>
+ 0x8f788a78, 0xb9721e06,<br>
+ 0x8f728a72, 0x80787278,<br>
+ 0x8078ff78, 0x00000200,<br>
+ 0x80f8ff78, 0x00000050,<br>
+ 0xbef603ff, 0x01000000,<br>
+ 0xbefc03ff, 0x0000006c,<br>
+ 0x80f89078, 0xf429003a,<br>
+ 0xf0000000, 0xbf8cc07f,<br>
+ 0x80fc847c, 0xbf800000,<br>
+ 0xbe803100, 0xbe823102,<br>
+ 0x80f8a078, 0xf42d003a,<br>
+ 0xf0000000, 0xbf8cc07f,<br>
+ 0x80fc887c, 0xbf800000,<br>
+ 0xbe803100, 0xbe823102,<br>
+ 0xbe843104, 0xbe863106,<br>
+ 0x80f8c078, 0xf431003a,<br>
+ 0xf0000000, 0xbf8cc07f,<br>
+ 0x80fc907c, 0xbf800000,<br>
+ 0xbe803100, 0xbe823102,<br>
+ 0xbe843104, 0xbe863106,<br>
+ 0xbe883108, 0xbe8a310a,<br>
+ 0xbe8c310c, 0xbe8e310e,<br>
+ 0xbf06807c, 0xbf84fff0,<br>
+ 0xb9782a05, 0x80788178,<br>
+ 0x907c9973, 0x877c817c,<br>
+ 0xbf06817c, 0xbf850002,<br>
+ 0x8f788978, 0xbf820001,<br>
+ 0x8f788a78, 0xb9721e06,<br>
+ 0x8f728a72, 0x80787278,<br>
+ 0x8078ff78, 0x00000200,<br>
+ 0xbef603ff, 0x01000000,<br>
+ 0xf4211bfa, 0xf0000000,<br>
+ 0x80788478, 0xf4211b3a,<br>
0xf0000000, 0x80788478,<br>
- 0xf4211b3a, 0xf0000000,<br>
- 0x80788478, 0xf4211b7a,<br>
+ 0xf4211b7a, 0xf0000000,<br>
+ 0x80788478, 0xf4211eba,<br>
0xf0000000, 0x80788478,<br>
- 0xf4211eba, 0xf0000000,<br>
- 0x80788478, 0xf4211efa,<br>
+ 0xf4211efa, 0xf0000000,<br>
+ 0x80788478, 0xf4211c3a,<br>
0xf0000000, 0x80788478,<br>
- 0xf4211c3a, 0xf0000000,<br>
- 0x80788478, 0xf4211c7a,<br>
+ 0xf4211c7a, 0xf0000000,<br>
+ 0x80788478, 0xf4211e7a,<br>
0xf0000000, 0x80788478,<br>
- 0xf4211e7a, 0xf0000000,<br>
- 0x80788478, 0xf4211cfa,<br>
+ 0xf4211cfa, 0xf0000000,<br>
+ 0x80788478, 0xf4211bba,<br>
0xf0000000, 0x80788478,<br>
+ 0xbf8cc07f, 0xb9eef814,<br>
0xf4211bba, 0xf0000000,<br>
0x80788478, 0xbf8cc07f,<br>
- 0xb9eef814, 0xf4211bba,<br>
- 0xf0000000, 0x80788478,<br>
- 0xbf8cc07f, 0xb9eef815,<br>
- 0xbef2036d, 0x876dff72,<br>
- 0x0000ffff, 0xbefc036f,<br>
- 0xbefe037a, 0xbeff037b,<br>
- 0x876f71ff, 0x000003ff,<br>
- 0xb9ef4803, 0xb9f9f816,<br>
- 0x876f71ff, 0xfffff800,<br>
- 0x906f8b6f, 0xb9efa2c3,<br>
- 0xb9f3f801, 0x876fff72,<br>
- 0xfc000000, 0x906f9a6f,<br>
- 0x8f6f906f, 0xbef30380,<br>
+ 0xb9eef815, 0xbef2036d,<br>
+ 0x876dff72, 0x0000ffff,<br>
+ 0xbefc036f, 0xbefe037a,<br>
+ 0xbeff037b, 0x876f71ff,<br>
+ 0x000003ff, 0xb9ef4803,<br>
+ 0xb9f9f816, 0x876f71ff,<br>
+ 0xfffff800, 0x906f8b6f,<br>
+ 0xb9efa2c3, 0xb9f3f801,<br>
+ 0x876fff72, 0xfc000000,<br>
+ 0x906f9a6f, 0x8f6f906f,<br>
+ 0xbef30380, 0x88736f73,<br>
+ 0x876fff72, 0x02000000,<br>
+ 0x906f996f, 0x8f6f8f6f,<br>
0x88736f73, 0x876fff72,<br>
- 0x02000000, 0x906f996f,<br>
- 0x8f6f8f6f, 0x88736f73,<br>
- 0x876fff72, 0x01000000,<br>
- 0x906f986f, 0x8f6f996f,<br>
- 0x88736f73, 0x876fff70,<br>
- 0x00800000, 0x906f976f,<br>
- 0xb9f3f807, 0x87fe7e7e,<br>
- 0x87ea6a6a, 0xb9f0f802,<br>
- 0xbf8a0000, 0xbe80226c,<br>
- 0xbf810000, 0xbf9f0000,<br>
+ 0x01000000, 0x906f986f,<br>
+ 0x8f6f996f, 0x88736f73,<br>
+ 0x876fff70, 0x00800000,<br>
+ 0x906f976f, 0xb9f3f807,<br>
+ 0x87fe7e7e, 0x87ea6a6a,<br>
+ 0xb9f0f802, 0xbf8a0000,<br>
+ 0xbe80226c, 0xbf810000,<br>
0xbf9f0000, 0xbf9f0000,<br>
0xbf9f0000, 0xbf9f0000,<br>
+ 0xbf9f0000, 0x00000000,<br>
};<br>
static const uint32_t cwsr_trap_arcturus_hex[] = {<br>
0xbf820001, 0xbf8202c4,<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm<br>
index cdaa523..4433bda 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm<br>
+++ b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm<br>
@@ -758,6 +758,7 @@ L_RESTORE_V0:<br>
buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:256<br>
buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:256*2<br>
buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:256*3<br>
+ s_waitcnt vmcnt(0)<br>
<br>
/* restore SGPRs */<br>
//will be 2+8+16*6<br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></div>
</span></font></div>
</body>
</html>