drm/msm/a5xx: make it work with the latest Mesa
Subsystems (4)
cover drm/msm/a5xx: make it work with the latest Mesa
Mesa 22.3.x changed the priorities used for the GPU contexts, making kernel switch between different ring buffers. This uncovered several issues in the A5xx preemption code, which are now being resolved by this patchset.
Dmitry Baryshkov (4):
drm/msm/a5xx: fix setting of the CP_PREEMPT_ENABLE_LOCAL register drm/msm/a5xx: fix highest bank bit for a530 drm/msm/a5xx: fix the emptyness check in the preempt code drm/msm/a5xx: fix context faults during ring switch
drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 6 +++--- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/4 drm/msm/a5xx: fix setting of the CP_PREEMPT_ENABLE_LOCAL register
Rather than writing CP_PREEMPT_ENABLE_GLOBAL twice, follow the vendor kernel and set CP_PREEMPT_ENABLE_LOCAL register instead. a5xx_submit() will override it during submission, but let's get the sequence correct.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +2 -2
@@ -151,8 +151,8 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)OUT_RING (ring,1 );/* Enable local preemption for finegrain preemption */ -OUT_PKT7 (ring,CP_PREEMPT_ENABLE_GLOBAL ,1 ); -OUT_RING (ring,0x02 ); +OUT_PKT7 (ring,CP_PREEMPT_ENABLE_LOCAL ,1 ); +OUT_RING (ring,0x1 );/* Allow CP_CONTEXT_SWITCH_YIELD packets in the IB2 */ OUT_PKT7 (ring,CP_YIELD_ENABLE ,1 );
Signature · 1 line
2.30.2
PATCH 2/4 drm/msm/a5xx: fix highest bank bit for a530
In reply to Dmitry BaryshkovA530 has highest bank bit equal to 15 (like A540). Fix values written to REG_A5XX_RB_MODE_CNTL and REG_A5XX_TPL1_MODE_CNTL registers.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +1 -1
@@ -806,7 +806,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)gpu_write (gpu,REG_A5XX_RBBM_AHB_CNTL2 ,0x0000003F );/* Set the highest bank bit */ -if (adreno_is_a540 (adreno_gpu)) +if (adreno_is_a540 (adreno_gpu) ||adreno_is_a530 (adreno_gpu)) regbit =2 ;else regbit =1 ;
Signature · 1 line
2.30.2
PATCH 3/4 drm/msm/a5xx: fix the emptyness check in the preempt code
In reply to Dmitry BaryshkovQuoting Yassine: ring->memptrs->rptr is never updated and stays 0, so the comparison always evaluates to false and get_next_ring always returns ring 0 thinking it isn't empty.
Fix this by calling get_rptr() instead of reading rptr directly.
--- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +1 -1
@@ -63,7 +63,7 @@ static struct msm_ringbuffer *get_next_ring(struct msm_gpu *gpu)struct msm_ringbuffer *ring = gpu->rb[i];spin_lock_irqsave (&ring->preempt_lock, flags); - empty = (get_wptr (ring) == ring->memptrs->rptr); + empty = (get_wptr (ring) == gpu->funcs->get_rptr (gpu, ring));spin_unlock_irqrestore (&ring->preempt_lock, flags);if (!empty)
Signature · 1 line
2.30.2
PATCH 4/4 drm/msm/a5xx: fix context faults during ring switch
In reply to Dmitry BaryshkovThe rptr_addr is set in the preempt_init_ring(), which is called from a5xx_gpu_init(). It uses shadowptr() to set the address, however the shadow_iova is not yet initialized at that time. Move the rptr_addr setting to the a5xx_preempt_hw_init() which is called after setting the shadow_iova, getting the correct value for the address.
--- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +1 -1
@@ -207,6 +207,7 @@ void a5xx_preempt_hw_init(struct msm_gpu *gpu) a5xx_gpu->preempt[i]->wptr =0 ; a5xx_gpu->preempt[i]->rptr =0 ; a5xx_gpu->preempt[i]->rbase = gpu->rb[i]->iova; + a5xx_gpu->preempt[i]->rptr_addr =shadowptr (a5xx_gpu, gpu->rb[i]); }/* Write a 0 to signal that we aren't switching pagetables */
@@ -257,7 +258,6 @@ static int preempt_init_ring(struct a5xx_gpu *a5xx_gpu, ptr->data =0 ; ptr->cntl =MSM_GPU_RB_CNTL_DEFAULT |AXXX_CP_RB_CNTL_NO_UPDATE ; - ptr->rptr_addr =shadowptr (a5xx_gpu, ring); ptr->counter = counters_iova;return 0 ;
Signature · 1 line
2.30.2
Re: [PATCH 4/4] drm/msm/a5xx: fix context faults during ring switch
Quoted 8 lines · Dmitry Baryshkov
The
rptr_addris set in thepreempt_init_ring(), which is called froma5xx_gpu_init(). It usesshadowptr()to set the address, however theshadow_iovais not yet initialized at that time. Move therptr_addrsetting to thea5xx_preempt_hw_init()which is called after setting theshadow_iova, getting the correct value for the address.Fixes 8907afb476ac ("drm/msm: Allow a5xx to mark the RPTR shadow as privileged")
Quoted 29 lines
Suggested-by Rob Clark <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/msm/adreno/a5xx_preempt.c +1
-2@@ -207,6 +207,7 @@ void a5xx_preempt_hw_init(struct msm_gpu *gpu) a5xx_gpu->preempt[i]->wptr =0 ; a5xx_gpu->preempt[i]->rptr =0 ; a5xx_gpu->preempt[i]->rbase = gpu->rb[i]->iova; + a5xx_gpu->preempt[i]->rptr_addr =shadowptr (a5xx_gpu, gpu->rb[i]); }/* Write a 0 to signal that we aren't switching pagetables */ @@ -257,7 +258,6 @@ static int preempt_init_ring(struct a5xx_gpu *a5xx_gpu, ptr->data =0 ; ptr->cntl =MSM_GPU_RB_CNTL_DEFAULT |AXXX_CP_RB_CNTL_NO_UPDATE ; - ptr->rptr_addr =shadowptr (a5xx_gpu, ring); ptr->counter = counters_iova;return 0 ; --2.30.2
Quoted 11 lines · Dmitry Baryshkov
Mesa 22.3.x changed the priorities used for the GPU contexts, making kernel switch between different ring buffers. This uncovered several issues in the A5xx preemption code, which are now being resolved by this patchset.
Dmitry Baryshkov (4):
drm/msm/a5xx: fix setting of theCP_PREEMPT_ENABLE_LOCALregister drm/msm/a5xx: fix highest bank bit for a530 drm/msm/a5xx: fix the emptyness check in the preempt code drm/msm/a5xx: fix context faults during ring switch
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a5xx_gpu.c| 6 +++---drivers/gpu/drm/msm/adreno/a5xx_preempt.c| 4 ++--2 files changed, 5 insertions(+), 5 deletions(-)--
2.30.2
Thanks for the fix!
For the whole series, on MSM8996: