drm/amdgpu/gfx9: set additional bits on CP halt
Subsystems (2)
Alex Deucher
maintainerPATCH 1/2 drm/amdgpu/gfx9: set additional bits on CP halt
Need to set the pipe reset and cache invalidation bits on halt otherwise we can get stale state if the CP firmware changes (e.g., on module unload and reload).
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +18 -1
@@ -3184,6 +3184,15 @@ static void gfx_v9_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable) {u32 tmp =RREG32_SOC15 (GC ,0 , mmCP_ME_CNTL); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,CE_INVALIDATE_ICACHE , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,PFP_INVALIDATE_ICACHE , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,ME_INVALIDATE_ICACHE , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,CE_PIPE0_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,CE_PIPE1_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,PFP_PIPE0_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,PFP_PIPE1_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,ME_PIPE0_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,ME_PIPE1_RESET , enable ?0 :1 ); tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,ME_HALT , enable ?0 :1 ); tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,PFP_HALT , enable ?0 :1 ); tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,CE_HALT , enable ?0 :1 );
@@ -3393,7 +3402,15 @@ static void gfx_v9_0_cp_compute_enable(struct amdgpu_device *adev, bool enable)WREG32_SOC15_RLC (GC ,0 , mmCP_MEC_CNTL,0 ); }else {WREG32_SOC15_RLC (GC ,0 , mmCP_MEC_CNTL, - (CP_MEC_CNTL__MEC_ME1_HALT_MASK |CP_MEC_CNTL__MEC_ME2_HALT_MASK )); + (CP_MEC_CNTL__MEC_INVALIDATE_ICACHE_MASK | +CP_MEC_CNTL__MEC_ME1_PIPE0_RESET_MASK | +CP_MEC_CNTL__MEC_ME1_PIPE1_RESET_MASK | +CP_MEC_CNTL__MEC_ME1_PIPE2_RESET_MASK | +CP_MEC_CNTL__MEC_ME1_PIPE3_RESET_MASK | +CP_MEC_CNTL__MEC_ME2_PIPE0_RESET_MASK | +CP_MEC_CNTL__MEC_ME2_PIPE1_RESET_MASK | +CP_MEC_CNTL__MEC_ME1_HALT_MASK | +CP_MEC_CNTL__MEC_ME2_HALT_MASK )); adev->gfx.kiq[0 ].ring.sched.ready = false; }udelay (50 );
Signature · 1 line
2.46.0
Alex Deucher
maintainerPATCH 2/2 drm/amdgpu/gfx9: Explicitly halt CP before init
Need to make sure it's halted as we don't know what state the GPU may have been left in previously.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4 -0
@@ -3931,6 +3931,10 @@ static int gfx_v9_0_cp_resume(struct amdgpu_device *adev)return r; } +if (adev->gfx.num_gfx_rings) +gfx_v9_0_cp_gfx_enable (adev, false); +gfx_v9_0_cp_compute_enable (adev, false); + r =gfx_v9_0_kiq_resume (adev);if (r)return r;
Signature · 1 line
2.46.0
Re: [PATCH 2/2] drm/amdgpu/gfx9: Explicitly halt CP before init
Quoted 13 lines · Alex Deucher
Need to make sure it's halted as we don't know what state the GPU may have been left in previously.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_cp_resume(struct amdgpu_device *adev) · line 3940
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4
-0@@ -3931,6 +3931,10 @@ static int gfx_v9_0_cp_resume(struct amdgpu_device *adev)return r; } +if (adev->gfx.num_gfx_rings) +gfx_v9_0_cp_gfx_enable (adev, false); +gfx_v9_0_cp_compute_enable (adev, false); + r =gfx_v9_0_kiq_resume (adev);if (r)return r;
This is a precautionary measure to make sure that the GPU is in a known state before the driver attempts to initialize it. Adds calls to gfx_v9_0_cp_gfx_enable and gfx_v9_0_cp_compute_enable with enable set to false to halt the CP before the KIQ (Kernel Interface Queue) is resumed.
Quoted 36 lines · Alex Deucher
Need to set the pipe reset and cache invalidation bits on halt otherwise we can get stale state if the CP firmware changes (e.g., on module unload and reload).
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +11
-1@@ -3184,6 +3184,15 @@ static void gfx_v9_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable) {u32 tmp =RREG32_SOC15 (GC ,0 , mmCP_ME_CNTL); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,CE_INVALIDATE_ICACHE , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,PFP_INVALIDATE_ICACHE , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,ME_INVALIDATE_ICACHE , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,CE_PIPE0_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,CE_PIPE1_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,PFP_PIPE0_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,PFP_PIPE1_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,ME_PIPE0_RESET , enable ?0 :1 ); + tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,ME_PIPE1_RESET , enable ?0 :1 ); tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,ME_HALT , enable ?0 :1 ); tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,PFP_HALT , enable ?0 :1 ); tmp =REG_SET_FIELD (tmp,CP_ME_CNTL ,CE_HALT , enable ?0 :1 );@@ -3393,7 +3402,15 @@ static void gfx_v9_0_cp_compute_enable(struct amdgpu_device *adev, bool enable)WREG32_SOC15_RLC (GC ,0 , mmCP_MEC_CNTL,0 ); }else { WREG32_SOC15_RLC(GC, 0, mmCP_MEC_CNTL, - (CP_MEC_CNTL__MEC_ME1_HALT_MASK |CP_MEC_CNTL__MEC_ME2_HALT_MASK )); + (CP_MEC_CNTL__MEC_INVALIDATE_ICACHE_MASK | + CP_MEC_CNTL__MEC_ME1_PIPE0_RESET_MASK |
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static void gfx_v9_0_cp_compute_enable(struct amdgpu_device *adev, bool enable) · line 3416
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +7
-0+CP_MEC_CNTL__MEC_ME1_PIPE1_RESET_MASK | +CP_MEC_CNTL__MEC_ME1_PIPE2_RESET_MASK | +CP_MEC_CNTL__MEC_ME1_PIPE3_RESET_MASK | +CP_MEC_CNTL__MEC_ME2_PIPE0_RESET_MASK | +CP_MEC_CNTL__MEC_ME2_PIPE1_RESET_MASK | +CP_MEC_CNTL__MEC_ME1_HALT_MASK | + CP_MEC_CNTL__MEC_ME2_HALT_MASK)); adev->gfx.kiq[0 ].ring.sched.ready = false; }udelay (50 );
These bits are related to invalidating the instruction cache and resetting the pipes, which are necessary to ensure that the CP is in a clean state. This is particularly important if the CP firmware changes, such as during a module unload and reload, to prevent stale state from causing issues.