OSDN Git Service

drm/amdkfd: Fix spurious debug exception on gfx10
authorJay Cornwall <jay.cornwall@amd.com>
Fri, 24 Jul 2020 23:58:48 +0000 (16:58 -0700)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 10 Aug 2020 21:26:51 +0000 (17:26 -0400)
s_barrier triggers a debug exception when issued with PRIV=1,
DEBUG_EN=1. This causes spurious notifications to rocm-gdb.

Clear MODE before issuing s_barrier and restore MODE afterwards
in the context restore handler.

Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
Tested-by: Laurent Morichetti <laurent.morichetti@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm

index 577d901..affbca7 100644 (file)
@@ -911,7 +911,7 @@ static const uint32_t cwsr_trap_nv1x_hex[] = {
        0x705d0000, 0x807c817c,
        0x8070ff70, 0x00000080,
        0xbf0a7b7c, 0xbf85fff8,
-       0xbf82014f, 0xbef4037e,
+       0xbf820151, 0xbef4037e,
        0x8775ff7f, 0x0000ffff,
        0x8875ff75, 0x00040000,
        0xbef60380, 0xbef703ff,
@@ -1024,61 +1024,62 @@ static const uint32_t cwsr_trap_nv1x_hex[] = {
        0xbe883108, 0xbe8a310a,
        0xbe8c310c, 0xbe8e310e,
        0xbf06807c, 0xbf84fff0,
-       0xb9782a05, 0x80788178,
-       0xbf0d9972, 0xbf850002,
-       0x8f788978, 0xbf820001,
-       0x8f788a78, 0xb96e1e06,
-       0x8f6e8a6e, 0x80786e78,
-       0x8078ff78, 0x00000200,
-       0xbef603ff, 0x01000000,
-       0xf4211bfa, 0xf0000000,
-       0x80788478, 0xf4211b3a,
+       0xba80f801, 0x00000000,
+       0xbf8a0000, 0xb9782a05,
+       0x80788178, 0xbf0d9972,
+       0xbf850002, 0x8f788978,
+       0xbf820001, 0x8f788a78,
+       0xb96e1e06, 0x8f6e8a6e,
+       0x80786e78, 0x8078ff78,
+       0x00000200, 0xbef603ff,
+       0x01000000, 0xf4211bfa,
        0xf0000000, 0x80788478,
-       0xf4211b7a, 0xf0000000,
-       0x80788478, 0xf4211c3a,
+       0xf4211b3a, 0xf0000000,
+       0x80788478, 0xf4211b7a,
        0xf0000000, 0x80788478,
-       0xf4211c7a, 0xf0000000,
-       0x80788478, 0xf4211eba,
+       0xf4211c3a, 0xf0000000,
+       0x80788478, 0xf4211c7a,
        0xf0000000, 0x80788478,
-       0xf4211efa, 0xf0000000,
-       0x80788478, 0xf4211e7a,
+       0xf4211eba, 0xf0000000,
+       0x80788478, 0xf4211efa,
        0xf0000000, 0x80788478,
-       0xf4211cfa, 0xf0000000,
-       0x80788478, 0xf4211bba,
+       0xf4211e7a, 0xf0000000,
+       0x80788478, 0xf4211cfa,
        0xf0000000, 0x80788478,
-       0xbf8cc07f, 0xb9eef814,
        0xf4211bba, 0xf0000000,
        0x80788478, 0xbf8cc07f,
-       0xb9eef815, 0xbefc036f,
-       0xbefe0370, 0xbeff0371,
-       0x876f7bff, 0x000003ff,
-       0xb9ef4803, 0xb9f9f816,
-       0x876f7bff, 0xfffff800,
-       0x906f8b6f, 0xb9efa2c3,
-       0xb9f3f801, 0xb96e2a05,
-       0x806e816e, 0xbf0d9972,
-       0xbf850002, 0x8f6e896e,
-       0xbf820001, 0x8f6e8a6e,
-       0x806eff6e, 0x00000200,
-       0x806e746e, 0x826f8075,
-       0x876fff6f, 0x0000ffff,
-       0xf4091c37, 0xfa000050,
-       0xf4091d37, 0xfa000060,
-       0xf4011e77, 0xfa000074,
-       0xbf8cc07f, 0x876fff6d,
-       0xfc000000, 0x906f9a6f,
-       0x8f6f906f, 0xbeee0380,
+       0xb9eef814, 0xf4211bba,
+       0xf0000000, 0x80788478,
+       0xbf8cc07f, 0xb9eef815,
+       0xbefc036f, 0xbefe0370,
+       0xbeff0371, 0x876f7bff,
+       0x000003ff, 0xb9ef4803,
+       0xb9f9f816, 0x876f7bff,
+       0xfffff800, 0x906f8b6f,
+       0xb9efa2c3, 0xb9f3f801,
+       0xb96e2a05, 0x806e816e,
+       0xbf0d9972, 0xbf850002,
+       0x8f6e896e, 0xbf820001,
+       0x8f6e8a6e, 0x806eff6e,
+       0x00000200, 0x806e746e,
+       0x826f8075, 0x876fff6f,
+       0x0000ffff, 0xf4091c37,
+       0xfa000050, 0xf4091d37,
+       0xfa000060, 0xf4011e77,
+       0xfa000074, 0xbf8cc07f,
+       0x876fff6d, 0xfc000000,
+       0x906f9a6f, 0x8f6f906f,
+       0xbeee0380, 0x886e6f6e,
+       0x876fff6d, 0x02000000,
+       0x906f996f, 0x8f6f8f6f,
        0x886e6f6e, 0x876fff6d,
-       0x02000000, 0x906f996f,
-       0x8f6f8f6f, 0x886e6f6e,
-       0x876fff6d, 0x01000000,
-       0x906f986f, 0x8f6f996f,
-       0x886e6f6e, 0x876fff7a,
-       0x00800000, 0x906f976f,
-       0xb9eef807, 0x876dff6d,
-       0x0000ffff, 0x87fe7e7e,
-       0x87ea6a6a, 0xb9faf802,
-       0xbf8a0000, 0xbe80226c,
+       0x01000000, 0x906f986f,
+       0x8f6f996f, 0x886e6f6e,
+       0x876fff7a, 0x00800000,
+       0x906f976f, 0xb9eef807,
+       0x876dff6d, 0x0000ffff,
+       0x87fe7e7e, 0x87ea6a6a,
+       0xb9faf802, 0xbe80226c,
        0xbf810000, 0xbf9f0000,
        0xbf9f0000, 0xbf9f0000,
        0xbf9f0000, 0xbf9f0000,
@@ -1807,7 +1808,7 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {
        0x705d0000, 0x807c817c,
        0x8070ff70, 0x00000080,
        0xbf0a7b7c, 0xbf85fff8,
-       0xbf82013a, 0xbef4037e,
+       0xbf82013c, 0xbef4037e,
        0x8775ff7f, 0x0000ffff,
        0x8875ff75, 0x00040000,
        0xbef60380, 0xbef703ff,
@@ -1920,50 +1921,51 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {
        0xbe883108, 0xbe8a310a,
        0xbe8c310c, 0xbe8e310e,
        0xbf06807c, 0xbf84fff0,
-       0xb9782a05, 0x80788178,
-       0xbf0d9972, 0xbf850002,
-       0x8f788978, 0xbf820001,
-       0x8f788a78, 0xb96e1e06,
-       0x8f6e8a6e, 0x80786e78,
-       0x8078ff78, 0x00000200,
-       0xbef603ff, 0x01000000,
-       0xf4211bfa, 0xf0000000,
-       0x80788478, 0xf4211b3a,
+       0xba80f801, 0x00000000,
+       0xbf8a0000, 0xb9782a05,
+       0x80788178, 0xbf0d9972,
+       0xbf850002, 0x8f788978,
+       0xbf820001, 0x8f788a78,
+       0xb96e1e06, 0x8f6e8a6e,
+       0x80786e78, 0x8078ff78,
+       0x00000200, 0xbef603ff,
+       0x01000000, 0xf4211bfa,
        0xf0000000, 0x80788478,
-       0xf4211b7a, 0xf0000000,
-       0x80788478, 0xf4211c3a,
+       0xf4211b3a, 0xf0000000,
+       0x80788478, 0xf4211b7a,
        0xf0000000, 0x80788478,
-       0xf4211c7a, 0xf0000000,
-       0x80788478, 0xf4211eba,
+       0xf4211c3a, 0xf0000000,
+       0x80788478, 0xf4211c7a,
        0xf0000000, 0x80788478,
-       0xf4211efa, 0xf0000000,
-       0x80788478, 0xf4211e7a,
+       0xf4211eba, 0xf0000000,
+       0x80788478, 0xf4211efa,
        0xf0000000, 0x80788478,
-       0xf4211cfa, 0xf0000000,
-       0x80788478, 0xf4211bba,
+       0xf4211e7a, 0xf0000000,
+       0x80788478, 0xf4211cfa,
        0xf0000000, 0x80788478,
-       0xbf8cc07f, 0xb9eef814,
        0xf4211bba, 0xf0000000,
        0x80788478, 0xbf8cc07f,
-       0xb9eef815, 0xbefc036f,
-       0xbefe0370, 0xbeff0371,
-       0x876f7bff, 0x000003ff,
-       0xb9ef4803, 0x876f7bff,
-       0xfffff800, 0x906f8b6f,
-       0xb9efa2c3, 0xb9f3f801,
-       0xb96e2a05, 0x806e816e,
-       0xbf0d9972, 0xbf850002,
-       0x8f6e896e, 0xbf820001,
-       0x8f6e8a6e, 0x806eff6e,
-       0x00000200, 0x806e746e,
-       0x826f8075, 0x876fff6f,
-       0x0000ffff, 0xf4091c37,
-       0xfa000050, 0xf4091d37,
-       0xfa000060, 0xf4011e77,
-       0xfa000074, 0xbf8cc07f,
-       0x876dff6d, 0x0000ffff,
-       0x87fe7e7e, 0x87ea6a6a,
-       0xb9faf802, 0xbf8a0000,
+       0xb9eef814, 0xf4211bba,
+       0xf0000000, 0x80788478,
+       0xbf8cc07f, 0xb9eef815,
+       0xbefc036f, 0xbefe0370,
+       0xbeff0371, 0x876f7bff,
+       0x000003ff, 0xb9ef4803,
+       0x876f7bff, 0xfffff800,
+       0x906f8b6f, 0xb9efa2c3,
+       0xb9f3f801, 0xb96e2a05,
+       0x806e816e, 0xbf0d9972,
+       0xbf850002, 0x8f6e896e,
+       0xbf820001, 0x8f6e8a6e,
+       0x806eff6e, 0x00000200,
+       0x806e746e, 0x826f8075,
+       0x876fff6f, 0x0000ffff,
+       0xf4091c37, 0xfa000050,
+       0xf4091d37, 0xfa000060,
+       0xf4011e77, 0xfa000074,
+       0xbf8cc07f, 0x876dff6d,
+       0x0000ffff, 0x87fe7e7e,
+       0x87ea6a6a, 0xb9faf802,
        0xbe80226c, 0xbf810000,
        0xbf9f0000, 0xbf9f0000,
        0xbf9f0000, 0xbf9f0000,
index 5b220f2..5081f91 100644 (file)
@@ -894,6 +894,11 @@ L_RESTORE_SGPR:
        s_cmp_eq_u32    m0, 0                                                   //scc = (m0 < s_sgpr_save_num) ? 1 : 0
        s_cbranch_scc0  L_RESTORE_SGPR_LOOP
 
+       // s_barrier with MODE.DEBUG_EN=1, STATUS.PRIV=1 incorrectly asserts debug exception.
+       // Clear DEBUG_EN before and restore MODE after the barrier.
+       s_setreg_imm32_b32      hwreg(HW_REG_MODE), 0
+       s_barrier                                                               //barrier to ensure the readiness of LDS before access attemps from any other wave in the same TG
+
        /* restore HW registers */
 L_RESTORE_HWREG:
        // HWREG SR memory offset : size(VGPR)+size(SVGPR)+size(SGPR)
@@ -976,8 +981,6 @@ L_RESTORE_HWREG:
        s_and_b64       vcc, vcc, vcc                                           // Restore STATUS.VCCZ, not writable by s_setreg_b32
        s_setreg_b32    hwreg(HW_REG_STATUS), s_restore_status                  // SCC is included, which is changed by previous salu
 
-       s_barrier                                                               //barrier to ensure the readiness of LDS before access attemps from any other wave in the same TG
-
        s_rfe_b64       s_restore_pc_lo                                         //Return to the main shader program and resume execution
 
 L_END_PGM: