Skip to content

drm/v3d: General job locking improvements + race-condition fixes

Maíra Canal dri-devel 3 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected] change-id 20250718-v3d-queue-lock-59babfb548bc

Versions newest first

  1. v3 Latest6 patches 1 replyApplied
  2. v26 patches 13 repliesSuperseded
  3. v16 patches 1 replySuperseded

Changes in v3 from the cover letter

- [1/6, 2/6, 3/6, 5/6] Add Melissa's R-b.
- [1/6] Improve the commit message (Melissa Wen)
- [2/6] Use &job->base instead of to_v3d_job(sched_job)
- [6/6] Fix the loop index (s/q/i) (Melissa Wen)
- Link to v2: https://lore.kernel.org/r/[email protected]

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/6drm/v3d: Store a pointer to `struct v3d_file_priv` inside each jobdrivers/gpu/drm/v3d/v3d_drv.h drivers/gpu/drm/v3d/v3d_sched.c drivers/gpu/drm/v3d/v3d_submit.c+8 -80 replies
2/6drm/v3d: Store the active job inside the queue's statedrivers/gpu/drm/v3d/v3d_drv.h drivers/gpu/drm/v3d/v3d_gem.c drivers/gpu/drm/v3d/v3d_irq.c +1 more+38 -550 replies
3/6drm/v3d: Replace a global spinlock with a per-queue spinlockdrivers/gpu/drm/v3d/v3d_drv.h drivers/gpu/drm/v3d/v3d_fence.c drivers/gpu/drm/v3d/v3d_gem.c +2 more+20 -210 replies
4/6drm/v3d: Address race-condition between per-fd GPU stats and fd releasedrivers/gpu/drm/v3d/v3d_drv.c drivers/gpu/drm/v3d/v3d_drv.h drivers/gpu/drm/v3d/v3d_sched.c+21 -90 replies
5/6drm/v3d: Synchronous operations can't timeoutdrivers/gpu/drm/v3d/v3d_sched.c+4 -40 replies
6/6drm/v3d: Protect per-fd reset counter against fd releasedrivers/gpu/drm/v3d/v3d_sched.c+17 -130 replies

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchIago Toral QuirogaMelissa Wen
1/6R-b R-b
2/6R-b R-b
3/6R-b R-b
4/6R-b
5/6R-b R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/6] drm/v3d: General job locking improvements + race-condition fixes

This patch series was initially motivated by a race condition (exposed in PATCH 4/6) where we lacked synchronization for job->file access. This led to use-after-free issues when a file descriptor was closed while a job was still running.

However, beyond fixing this specific race, the series introduces broader improvements to active job management and locking. While PATCH 1/6, 2/6, and 5/6 are primarily code refactors, PATCH 3/6 brings a significant change to the locking scheme. Previously, all queues shared the same spinlock, which caused unnecessary contention during high GPU usage across different queues. PATCH 3/6 allows queues to operate more independently.

Finally, PATCH 6/6 addresses a similar race condition to PATCH 4/6, but this time, on the per-file descriptor reset counter.

Best Regards,
- Maíra

---
v1 -> v2:

- Add Iago's R-b to all patches.
- Rebase on top of drm-misc-next.
- Link to v1: https://lore.kernel.org/r/[email protected]

v2 -> v3:

- [1/6, 2/6, 3/6, 5/6] Add Melissa's R-b.
- [1/6] Improve the commit message (Melissa Wen)
- [2/6] Use &job->base instead of to_v3d_job(sched_job)
- [6/6] Fix the loop index (s/q/i) (Melissa Wen)
- Link to v2: https://lore.kernel.org/r/[email protected]

---
Maíra Canal (6):
drm/v3d: Store a pointer to struct v3d_file_priv inside each job drm/v3d: Store the active job inside the queue's state drm/v3d: Replace a global spinlock with a per-queue spinlock drm/v3d: Address race-condition between per-fd GPU stats and fd release drm/v3d: Synchronous operations can't timeout
drm/v3d: Protect per-fd reset counter against fd release

 drivers/gpu/drm/v3d/v3d_drv.c    | 14 ++++++-
 drivers/gpu/drm/v3d/v3d_drv.h    | 22 ++++-------
 drivers/gpu/drm/v3d/v3d_fence.c  | 11 +++---
 drivers/gpu/drm/v3d/v3d_gem.c    | 10 ++---
 drivers/gpu/drm/v3d/v3d_irq.c    | 68 +++++++++++++-------------------
 drivers/gpu/drm/v3d/v3d_sched.c  | 85 +++++++++++++++++++++-------------------
 drivers/gpu/drm/v3d/v3d_submit.c |  2 +-
 7 files changed, 105 insertions(+), 107 deletions(-)

---
base-commit: 7399c13f619f33dc8bdce838f3c83e88a18765ee
change-id: 20250718-v3d-queue-lock-59babfb548bc