]> www.infradead.org Git - users/jedix/linux-maple.git/commit
drm/msm/a5xx: fix races in preemption evaluation stage
authorVladimir Lypak <vladimir.lypak@gmail.com>
Sun, 1 Sep 2024 13:54:02 +0000 (13:54 +0000)
committerRob Clark <robdclark@chromium.org>
Sun, 1 Sep 2024 15:17:53 +0000 (08:17 -0700)
commitce050f307ad93bcc5958d0dd35fc276fd394d274
tree66e1a77dea47499581754bd96a1cd660d95b6849
parent64fd6d01a52904bdbda0ce810a45a428c995a4ca
drm/msm/a5xx: fix races in preemption evaluation stage

On A5XX GPUs when preemption is used it's invietable to enter a soft
lock-up state in which GPU is stuck at empty ring-buffer doing nothing.
This appears as full UI lockup and not detected as GPU hang (because
it's not). This happens due to not triggering preemption when it was
needed. Sometimes this state can be recovered by some new submit but
generally it won't happen because applications are waiting for old
submits to retire.

One of the reasons why this happens is a race between a5xx_submit and
a5xx_preempt_trigger called from IRQ during submit retire. Former thread
updates ring->cur of previously empty and not current ring right after
latter checks it for emptiness. Then both threads can just exit because
for first one preempt_state wasn't NONE yet and for second one all rings
appeared to be empty.

To prevent such situations from happening we need to establish guarantee
for preempt_trigger to make decision after each submit or retire. To
implement this we serialize preemption initiation using spinlock. If
switch is already in progress we need to re-trigger preemption when it
finishes.

Fixes: b1fc2839d2f9 ("drm/msm: Implement preemption for A5XX targets")
Signed-off-by: Vladimir Lypak <vladimir.lypak@gmail.com>
Patchwork: https://patchwork.freedesktop.org/patch/612045/
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/adreno/a5xx_gpu.h
drivers/gpu/drm/msm/adreno/a5xx_preempt.c