public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/v3d: Ensure atomic submissions in v3d_submit_jobs()
Date: Sat, 16 May 2026 15:59:30 +1000	[thread overview]
Message-ID: <review-patch14-20260510-v3d-sched-misc-fixes-v2-14-ca4aba343ef6@igalia.com> (raw)
In-Reply-To: <20260510-v3d-sched-misc-fixes-v2-14-ca4aba343ef6@igalia.com>

Patch Review

The key correctness fix. Restructures `v3d_submit_jobs()` into three phases:
1. **Arm** all jobs (`drm_sched_job_arm()`)
2. **Wire dependencies** between consecutive jobs
3. **Push** all jobs to the scheduler

If phase 2 fails, all armed jobs get their finished fence marked with an error and are pushed anyway. The `run_job()` callbacks (BIN, RENDER, TFU, CSD, CPU, CACHE_CLEAN) all check `s_fence->finished.error` and skip execution.

This patch also adds the error check to `v3d_cpu_job_run()` and `v3d_cache_clean_job_run()`, which previously lacked it (the other queue types already had it from patch 2's pre-existing code).

**One observation about the error path**: On failure, `v3d_submit_jobs()` calls `v3d_submit_unlock_reservations()` but does *not* call `v3d_submit_attach_object_fences()`. This means on error, the BOs' reservation objects don't get the errored fence attached. This is correct — on error, the caller returns the error to userspace, and the errored jobs will complete via the scheduler without touching hardware. No BO fences are needed.

**Error path cleanup in callers**: The callers now handle `v3d_submit_jobs()` failure differently than other failures:
```c
ret = v3d_submit_jobs(&submit);
if (ret) {
    v3d_submit_put_jobs(&submit);
    v3d_submit_put_post_deps(sync_out, &se);
    return ret;
}
```
This is because after `v3d_submit_jobs()` (even on error), the jobs have been armed+pushed and are now owned by the scheduler. The caller uses `v3d_submit_put_jobs()` (kref_put) instead of `v3d_submit_cleanup_jobs()` (drm_sched_job_cleanup + kfree). This is correct.

**Potential concern**: The `v3d_submit_cpu_ioctl()` error-after-submit path does:
```c
if (ret) {
    v3d_submit_put_jobs(&submit);
    v3d_submit_put_post_deps(NULL, &se);
    return ret;
}
```
This skips the `kvfree(cpu_job->timestamp_query.queries)` and `kvfree(cpu_job->performance_query.queries)` cleanup that happens in the `fail:` label. However, since the jobs are now scheduler-owned and will be freed through the scheduler's cleanup path (via `v3d_job_free`), those allocations should be freed when the job's kref drops to zero. I'd verify that `v3d_job_free()` (the `free` callback) handles freeing these sub-allocations. If it does, this is correct. If not, this would be a memory leak on this specific error path.

Overall, this is a solid and well-organized series. The bounds check in `v3d_submit_add_job()` is the main thing I'd want added before merging.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-05-16  5:59 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-10 22:11 [PATCH v2 00/14] drm/v3d: Scheduler and submission fixes and refactoring Maíra Canal
2026-05-10 22:11 ` [PATCH v2 01/14] drm/v3d: Drop unused drm_encoder.h include from v3d_drv.h Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:11 ` [PATCH v2 02/14] drm/v3d: Clear queue->active_job when v3d_fence_create() fails Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 03/14] drm/v3d: Use inline lock for dma fence initialization Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 04/14] drm/v3d: Replace spin_lock_irqsave() with spin_lock() Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 05/14] drm/v3d: Extract v3d_job_add_syncobjs() helper Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 06/14] drm/v3d: Reject invalid syncobj handles in submit ioctls Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 07/14] drm/v3d: Migrate BO reservation locking to DRM exec Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 08/14] drm/v3d: Introduce struct v3d_submit and convert CL/TFU/CSD ioctls Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 09/14] drm/v3d: Make v3d_get_cpu_indirect_csd_params() a pure parser Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 10/14] drm/v3d: Convert submit helpers to operate on struct v3d_submit Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 11/14] drm/v3d: Refactor CPU ioctl into unified submission chain Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 12/14] drm/v3d: Split BO fence attach from syncobj output handling Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 13/14] drm/v3d: Reject invalid out_sync handles in submit ioctls Maíra Canal
2026-05-16  5:59   ` Claude review: " Claude Code Review Bot
2026-05-10 22:12 ` [PATCH v2 14/14] drm/v3d: Ensure atomic submissions in v3d_submit_jobs() Maíra Canal
2026-05-16  5:59   ` Claude Code Review Bot [this message]
2026-05-16  5:59 ` Claude review: drm/v3d: Scheduler and submission fixes and refactoring Claude Code Review Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch14-20260510-v3d-sched-misc-fixes-v2-14-ca4aba343ef6@igalia.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox