drm/msm/a5xx: fix the emptyness check in the preempt code
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tue, 14 Feb 2023 02:09:55 +0000 (05:09 +0300)
committerRob Clark <robdclark@chromium.org>
Wed, 22 Feb 2023 19:22:03 +0000 (11:22 -0800)
Quoting 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.

Reported-by: Yassine Oudjana <y.oudjana@protonmail.com>
Fixes: b1fc2839d2f9 ("drm/msm: Implement preemption for A5XX targets")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/522642/
Link: https://lore.kernel.org/r/20230214020956.164473-4-dmitry.baryshkov@linaro.org
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/adreno/a5xx_preempt.c

index 7658e89844b460bac2336a297844a05dc7ca94cb..7e0affd60993f4616c57e53b0cdfa6f7383ac13f 100644 (file)
@@ -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)