drm/amdgpu: Run shader cleaner on all XCCs on faults
Subsystems (2)
PATCH 1/2 drm/amdgpu: Run shader cleaner on all XCCs on faults
The previous patch only ran on XCC0, giving us a good chance that we don't clear the right registers on fault handling in MI3. Loop through them all to make sure we clear them all.
Signed-off-by Kent Russell <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c | 78 +++++++++++++++---------- 1 file changed, 47 insertions(+), 31 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c +47 -31
@@ -716,51 +716,67 @@ static int gfx_v9_4_2_do_vgprs_init(struct amdgpu_device *adev)static int gfx_v9_clean_shaders (struct amdgpu_device *adev) { -int r; +int r =0 ;/* CU_ID: 0~15, SIMD_ID: 0~3, WAVE_ID: 0 ~ 9 */ int wb_size = adev->gfx.config.max_shader_engines *CU_ID_MAX *SIMD_ID_MAX *WAVE_ID_MAX ;struct amdgpu_ib wb_ib; +struct amdgpu_ring *ring;struct dma_fence *fence =NULL ;u32 pattern =0xa ; +int xcc_id; -/* bail if the compute ring is not ready */ -if (!adev->gfx.compute_ring[0 ].sched.ready) +if (adev->gfx.disable_kq) { +dev_warn (adev->dev,"Cannot run shader cleaner with kernel queues disabled" );return 0 ; - -/* allocate the write-back buffer from IB */ -memset (&wb_ib,0 ,sizeof (wb_ib)); - r =amdgpu_ib_get (adev,NULL , (1 + wb_size) *sizeof (uint32_t ), -AMDGPU_IB_POOL_DIRECT , &wb_ib); -if (r) { -dev_err (adev->dev,"failed to get ib (%d) for wb.\n" , r); -return r; } -memset (wb_ib.ptr,0 , (1 + wb_size) *sizeof (uint32_t )); - r =gfx_v9_4_2_run_shader (adev, - &adev->gfx.compute_ring[0 ], - fault_cleaner_compute_shader_aldebaran, -sizeof (fault_cleaner_compute_shader_aldebaran), - fault_cleaner_init_regs_aldebaran, -ARRAY_SIZE (fault_cleaner_init_regs_aldebaran), - adev->gfx.cu_info.number *32 , - wb_ib.gpu_addr, pattern, &fence); +for_each_inst (xcc_id, adev->gfx.xcc_mask) { + ring = &adev->gfx.compute_ring[xcc_id * adev->gfx.num_compute_rings]; -if (r) { -dev_err (adev->dev,"failed to clear MI200\n" ); - goto pro_end; - } +/* bail if the compute ring is not ready */ +if (!ring->sched.ready) +continue ; -/* wait for the GPU to finish processing the IB */ - r =dma_fence_wait (fence, false); -if (r) -dev_err (adev->dev,"timeout to clear MI200\n" ); +/* allocate the write-back buffer from IB */ +memset (&wb_ib,0 ,sizeof (wb_ib)); + r =amdgpu_ib_get (adev,NULL , (1 + wb_size) *sizeof (uint32_t ), +AMDGPU_IB_POOL_DIRECT , &wb_ib); +if (r) { +dev_err (adev->dev,"failed to get ib (%d) for wb.\n" , r); +return r; + } +memset (wb_ib.ptr,0 , (1 + wb_size) *sizeof (uint32_t )); + + r =gfx_v9_4_2_run_shader (adev, + ring, + fault_cleaner_compute_shader_aldebaran, +sizeof (fault_cleaner_compute_shader_aldebaran), + fault_cleaner_init_regs_aldebaran, +ARRAY_SIZE (fault_cleaner_init_regs_aldebaran), + adev->gfx.cu_info.number *32 , + wb_ib.gpu_addr, pattern, &fence); + +if (r) { +dev_err (adev->dev,"failed to clear GPR on xcc %d\n" , xcc_id); + goto pro_end; + } + +/* wait for the GPU to finish processing the IB */ + r =dma_fence_wait (fence, false); +if (r) +dev_err (adev->dev,"timeout to clear GPR on xcc %d\n" , xcc_id); pro_end: -if (fence) -dma_fence_put (fence); -amdgpu_ib_free (&wb_ib,NULL ); +if (fence) { +dma_fence_put (fence); + fence =NULL ; + } +amdgpu_ib_free (&wb_ib,NULL ); + +if (r) +break ; + }if (r)dev_dbg (adev->dev,"Clean GPR Failed\n" );
Signature · 1 line
2.43.0
PATCH 2/2 drm/amdgpu: Fix fault shader cleaner on MI3
MI300/MI350 have a different register layout, and cannot reuse the same definitions from MI2. The shader cleaner can be reused, but not the initialization steps.
Also change the dim_x to ensure that we cover all wave slots per SIMD.
Signed-off-by Kent Russell <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c | 37 +++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c +34 -3
@@ -23,6 +23,7 @@#include "amdgpu.h" #include "soc15.h" #include "soc15d.h" +#include "soc15_common.h" #include "gc/gc_9_4_2_offset.h" #include "gc/gc_9_4_2_sh_mask.h"
@@ -365,6 +366,20 @@ const struct soc15_reg_entry fault_cleaner_init_regs_aldebaran[] = { { SOC15_REG_ENTRY(GC, 0, regCOMPUTE_STATIC_THREAD_MGMT_SE7), 0xffffffff }, }; +static const struct soc15_reg_entry fault_cleaner_init_regs_aqua_vanjaram[] = { + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_RESOURCE_LIMITS),0x000000000 }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_NUM_THREAD_X),0x40 }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_NUM_THREAD_Y),1 }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_NUM_THREAD_Z),1 }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_PGM_RSRC1),0x00af0000 }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_PGM_RSRC2),0x000000c0 }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_PGM_RSRC3),0x00000000 }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_STATIC_THREAD_MGMT_SE0),0xffffffff }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_STATIC_THREAD_MGMT_SE1),0xffffffff }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_STATIC_THREAD_MGMT_SE2),0xffffffff }, + {SOC15_REG_ENTRY (GC ,0 , regCOMPUTE_STATIC_THREAD_MGMT_SE3),0xffffffff }, +}; + static int gfx_v9_4_2_run_shader(struct amdgpu_device *adev, struct amdgpu_ring *ring, const u32 *shader_ptr, u32 shader_size,
@@ -723,6 +738,8 @@ static int gfx_v9_clean_shaders(struct amdgpu_device *adev)struct amdgpu_ib wb_ib;struct amdgpu_ring *ring;struct dma_fence *fence =NULL ; +const struct soc15_reg_entry *init_regs; +u32 init_regs_size;u32 pattern =0xa ;int xcc_id;
@@ -731,6 +748,20 @@ static int gfx_v9_clean_shaders(struct amdgpu_device *adev)return 0 ; } +/* gfx943+ has different register layout compared to gfx942.*/ +switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { +case IP_VERSION (9 ,4 ,3 ): +case IP_VERSION (9 ,4 ,4 ): +case IP_VERSION (9 ,5 ,0 ): + init_regs = fault_cleaner_init_regs_aqua_vanjaram; + init_regs_size =ARRAY_SIZE (fault_cleaner_init_regs_aqua_vanjaram); +break ; +default : + init_regs = fault_cleaner_init_regs_aldebaran; + init_regs_size =ARRAY_SIZE (fault_cleaner_init_regs_aldebaran); +break ; + } +for_each_inst (xcc_id, adev->gfx.xcc_mask) { ring = &adev->gfx.compute_ring[xcc_id * adev->gfx.num_compute_rings];
@@ -752,9 +783,9 @@ static int gfx_v9_clean_shaders(struct amdgpu_device *adev) ring, fault_cleaner_compute_shader_aldebaran,sizeof (fault_cleaner_compute_shader_aldebaran), - fault_cleaner_init_regs_aldebaran, -ARRAY_SIZE (fault_cleaner_init_regs_aldebaran), - adev->gfx.cu_info.number *32 , + init_regs, + init_regs_size, + adev->gfx.cu_info.number *SIMD_ID_MAX *WAVE_ID_MAX , wb_ib.gpu_addr, pattern, &fence);if (r) {
Signature · 1 line
2.43.0