This series addresses several issues in the v3d scheduler and submission
code. Most of the fixes were motivated by feedback in the vc4 scheduler
series [1], which inherited issues from v3d. Based on the issues found
there, this series addresses the issues in the v3d driver as well.

This series has cleanup patches, fixes, and finally, a refactoring of
the submission code, which allowed us to fix the atomicity of a submission.

- Cleanups and small improvements:
  - PATCH 1/12: "drm/v3d: Drop unused drm_encoder.h include from v3d_drv.h"

- Fixes:
  - PATCH 2/12: "drm/v3d: Clear queue->active_job when v3d_fence_create() fails"
  - PATCH 3/12: "drm/v3d: Extract v3d_job_add_syncobjs() helper"
  - PATCH 4/12: "drm/v3d: Reject invalid syncobj handles in submit ioctls"
  - PATCH 11/12: "drm/v3d: Reject invalid out_sync handles in submit ioctls"

- Submission refactoring:
  - PATCH 5/12: "drm/v3d: Migrate BO reservation locking to DRM exec"
  - PATCH 6/12: "drm/v3d: Introduce struct v3d_submit and convert CL/TFU/CSD 
ioctls"
  - PATCH 7/12: "drm/v3d: Make v3d_get_cpu_indirect_csd_params() a pure parser"
  - PATCH 8/12: "drm/v3d: Convert submit helpers to operate on struct 
v3d_submit"
  - PATCH 9/12: "drm/v3d: Refactor CPU ioctl into unified submission chain"
  - PATCH 10/12: "drm/v3d: Split BO fence attach from syncobj output handling"
  - PATCH 12/12: "drm/v3d: Ensure atomic submissions in v3d_submit_jobs()" 
(Also a fix)

During the refactoring, I tried to break the conversion into small steps.
On the one hand, this helps reviewability; on the other hand, some things
may look unfinished at the end of a given commit. I tried to balance the
trade-off, but I'm happy to take split or squash requests during review.

[1] 
https://lore.kernel.org/dri-devel/[email protected]/T/

Best regards,
- Maíra

---
v1 -> v2: 
https://lore.kernel.org/r/[email protected]

- [2/14, 3/14, 5/14, 6/14] Add Tvrtko's R-b tag (Tvrtko Ursulin)
- [4/14] Use spin_lock() instead of spin_lock_irq() and change the commit 
message
         (Tvrtko Ursulin)
- [4/14] Use scoped_guard() instead of open-coding spin_(un)lock()
- [6/14] s/NULL/zero in the comments (Tvrtko Ursulin)
- [8/14] s/kcalloc(1, size, GFP_KERNEL)/kzalloc (Tvrtko Ursulin)
- [8/14] Save one atomic in v3d_attach_perfmon_to_jobs() by adding a conditional
         in the loop (Tvrtko Ursulin)
- [8/14] Zero is implied when initializing the struct v3d_submit (Tvrtko 
Ursulin)
- [8/14] Create v3d_submit_put_jobs() and v3d_submit_cleanup_jobs() (Tvrtko 
Ursulin)
- [9/14, 10/14, 11/14] NEW PATCHES: Trying to make the original patch
                       "[PATCH 09/10] drm/v3d: Refactor CPU ioctl into unified
                       submission chain" a bit easier to review.
- [10/14] Wrap drm_exec_fini() in a function v3d_submit_unlock_reservations()
          (Tvrtko Ursulin)
- [12/14] NEW PATCH: "drm/v3d: Split BO fence attach from syncobj output 
handling"
          - Split v3d_attach_fences_and_unlock_reservation() into different 
functions
            and fold parts of it into v3d_submit_jobs (Tvrtko Ursulin)
- [13/14] NEW PATCH: "drm/v3d: Reject invalid out_sync handles in submit ioctls"
          - Stop silently ignoring invalid syncobj handles (Tvrtko Ursulin)
- [14/14] Move the error path to a goto
- [14/14] Skip fence attachment and syncobj exportation to user-space if the
          submission has failed (Tvrtko Ursulin)

v2 -> v3: 
https://lore.kernel.org/r/[email protected]

- Rebased on top of drm-misc-next.
- [1/14] Add Iago's R-b tag (Iago Toral)
- [4/14, 7/14, 9/14] Add Tvrtko's R-b tag (Tvrtko Ursulin)
- [5/14] Create a job->queue variable to be used by v3d_job_add_syncobjs()
- [8/14] v3d_submit_add_job() returns struct v3d_job * instead of using
         void **container as argument (Tvrtko Ursulin)
- [10/14] Pull v3d_submit_lock_reservations() out of
          v3d_setup_csd_jobs_and_bos() (Tvrtko Ursulin)
- [11/14] Assert that jobs[1] is actually a CSD job (Tvrtko Ursulin)
- [11/14] v3d_submit_lock_reservations() is now called unconditionally
          in v3d_submit_cpu_ioctl() (Tvrtko Ursulin)
- [12/14, 13/14] Fold v3d_submit_process_post_deps() and v3d_submit_put_jobs()
                 into v3d_submit_jobs() (Tvrtko Ursulin)

v3 -> v4: 
https://lore.kernel.org/r/[email protected]

- Dropped "[PATCH v3 03/14] drm/v3d: Use inline lock for dma fence
  initialization" and "[PATCH v3 04/14] drm/v3d: Replace spin_lock_irqsave()
  with spin_lock()".
  - As pointed out by Sashiko, decoupling the DMA fence lock from the queue
    lock would break implicit synchronization, causing a UAF of `bin_job` in
    `v3d_overflow_mem_work()`.
  - I'll need to rework this in the future.
- [6/12, 8/12, 9/12, 10/12, 11/12] Add Tvrtko's R-b
- [2/12] Propagate the error pointer when v3d_fence_create() fails instead
         of treating the job as successfully completed (Sashiko)
- [6/12] Don't initialize the variables: render, clean_job and tfu_job
         (Tvrtko Ursulin)
- [11/12] Add an assert that sync_obj and multisync are mutually exclusive 
(Tvrtko Ursulin)
- [11/12] Document that multisync is prioritized over sync_obj (Tvrtko Ursulin)
- [12/12] Change the loop to for (i = 1; i < count; i++) (Tvrtko Ursulin)

---
Maíra Canal (12):
      drm/v3d: Drop unused drm_encoder.h include from v3d_drv.h
      drm/v3d: Clear queue->active_job when v3d_fence_create() fails
      drm/v3d: Extract v3d_job_add_syncobjs() helper
      drm/v3d: Reject invalid syncobj handles in submit ioctls
      drm/v3d: Migrate BO reservation locking to DRM exec
      drm/v3d: Introduce struct v3d_submit and convert CL/TFU/CSD ioctls
      drm/v3d: Make v3d_get_cpu_indirect_csd_params() a pure parser
      drm/v3d: Convert submit helpers to operate on struct v3d_submit
      drm/v3d: Refactor CPU ioctl into unified submission chain
      drm/v3d: Split BO fence attach from syncobj output handling
      drm/v3d: Reject invalid out_sync handles in submit ioctls
      drm/v3d: Ensure atomic submissions in v3d_submit_jobs()

 drivers/gpu/drm/v3d/Kconfig      |   1 +
 drivers/gpu/drm/v3d/v3d_drv.h    |  35 +-
 drivers/gpu/drm/v3d/v3d_sched.c  |  66 ++--
 drivers/gpu/drm/v3d/v3d_submit.c | 770 +++++++++++++++++++--------------------
 4 files changed, 445 insertions(+), 427 deletions(-)
---
base-commit: 86925ba9da20857b7d4525256a405fe789d4aa33
change-id: 20260407-v3d-sched-misc-fixes-623739017e53

Reply via email to