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/panthor: Prepare the scheduler logic for FW events in IRQ context
Date: Sat, 16 May 2026 13:32:45 +1000	[thread overview]
Message-ID: <review-patch6-20260512-panthor-signal-from-irq-v2-6-95c614a739cb@collabora.com> (raw)
In-Reply-To: <20260512-panthor-signal-from-irq-v2-6-95c614a739cb@collabora.com>

Patch Review

This is the most substantial and critical patch in the series. Key changes:

**1. New `events_lock` spinlock:** Replaces the `sched->lock` mutex for the event processing path. This is necessary because mutex can't be held in IRQ context.

**2. Event processing inlined into `panthor_sched_report_fw_events()`:** The old `fw_events_work` work item is eliminated. Events are now processed directly under `events_lock`:
```c
guard(spinlock_irqsave)(&ptdev->scheduler->events_lock);
// process events inline
```

**3. Fence signalling moved inline:** `group_sync_upd_work` (work item) replaced by `group_check_job_completion()` called directly from `csg_slot_sync_update_locked()`. This is the key change enabling fence signalling from IRQ context. The `dma_fence_signal_locked()` call is correctly wrapped with `dma_fence_begin_signalling()` / `dma_fence_end_signalling()`.

**4. Lock upgrades:** Multiple `spin_lock()` converted to `spin_lock_irqsave()` variants for `fence_ctx.lock` and `fdinfo.lock`, since these are now taken under `events_lock` (IRQ context).

**Concern — `events_lock` scope in `tick_ctx_apply` and `panthor_sched_suspend`:**

In `tick_ctx_apply`, the patch uses `guard(spinlock_irqsave)` inside an `if` block:
```c
if (group->csg_id >= 0) {
    guard(spinlock_irqsave)(&sched->events_lock);
    sched_process_csg_irq_locked(ptdev, group->csg_id);
}

group_unbind_locked(group);
```

The `guard()` acquires at declaration and releases at scope exit. Since it's declared inside the `if` block, the lock is released when the `if` block exits, **before** `group_unbind_locked()` is called. However, `group_unbind_locked()` itself takes `events_lock` internally (for the slot reassignment). So the lock is released between `sched_process_csg_irq_locked()` and the unbind's `events_lock` section. There's a theoretical window where a new IRQ could arrive and process events for this CSG slot between the two. This is addressed in patch 7 by moving the `sched_process_csg_irq_locked()` call into `group_unbind_locked()` itself, making it atomic. So while this patch has a subtle window, patch 7 fixes it. This is acceptable as a series but worth noting the ordering dependency.

**Concern — `sched_queue_delayed_work` from IRQ context:**

`sched_queue_delayed_work` calls `mod_delayed_work()`, which is documented as IRQ-safe, so this is fine.

**Concern — `cancel_delayed_work` from IRQ context:**

`queue_suspend_timeout_locked()` calls `cancel_delayed_work()` (not `_sync`), which is IRQ-safe. Good.

**Concern — double `dma_fence_begin_signalling`:**

In `queue_check_job_completion()`:
```c
cookie = dma_fence_begin_signalling();
scoped_guard(spinlock_irqsave, &queue->fence_ctx.lock) { ... }
dma_fence_end_signalling(cookie);
```

And the caller `group_check_job_completion()` also does:
```c
cookie = dma_fence_begin_signalling();
for (...) queue_check_job_completion(queue);
dma_fence_end_signalling(cookie);
```

This results in nested `dma_fence_begin_signalling()` calls. The kernel's fence signalling annotation framework supports nesting (it's a counter), so this is correct but redundant. The inner `dma_fence_begin_signalling` in `queue_check_job_completion` could be removed since the caller already establishes the signalling context, but it's not a bug.

Overall this patch is the riskiest in the series but the approach is sound.

---

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-05-16  3:32 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 11:37 [PATCH v2 00/11] drm/panthor: Reduce dma_fence signalling latency Boris Brezillon
2026-05-12 11:37 ` [PATCH v2 01/11] drm/panthor: Make panthor_irq::state a non-atomic field Boris Brezillon
2026-05-12 18:40   ` Chia-I Wu
2026-05-16  3:32   ` Claude review: " Claude Code Review Bot
2026-05-12 11:37 ` [PATCH v2 02/11] drm/panthor: Move the register accessors before the IRQ helpers Boris Brezillon
2026-05-12 18:41   ` Chia-I Wu
2026-05-16  3:32   ` Claude review: " Claude Code Review Bot
2026-05-12 11:37 ` [PATCH v2 03/11] drm/panthor: Replace the panthor_irq macro machinery by inline helpers Boris Brezillon
2026-05-12 18:58   ` Chia-I Wu
2026-05-13  8:03     ` Boris Brezillon
2026-05-13 16:46       ` Chia-I Wu
2026-05-16  3:32   ` Claude review: " Claude Code Review Bot
2026-05-12 11:37 ` [PATCH v2 04/11] drm/panthor: Extend the IRQ logic to allow fast/hard IRQ handlers Boris Brezillon
2026-05-12 19:11   ` Chia-I Wu
2026-05-13  8:09     ` Boris Brezillon
2026-05-13 17:06       ` Chia-I Wu
2026-05-13 17:30         ` Boris Brezillon
2026-05-13 18:17           ` Chia-I Wu
2026-05-16  3:32   ` Claude review: " Claude Code Review Bot
2026-05-12 11:37 ` [PATCH v2 05/11] drm/panthor: Make panthor_fw_{update,toggle}_reqs() callable from IRQ context Boris Brezillon
2026-05-12 19:29   ` [PATCH v2 05/11] drm/panthor: Make panthor_fw_{update, toggle}_reqs() " Chia-I Wu
2026-05-16  3:32   ` Claude review: drm/panthor: Make panthor_fw_{update,toggle}_reqs() " Claude Code Review Bot
2026-05-12 11:37 ` [PATCH v2 06/11] drm/panthor: Prepare the scheduler logic for FW events in " Boris Brezillon
2026-05-12 21:04   ` Chia-I Wu
2026-05-13  8:29     ` Boris Brezillon
2026-05-13 17:47       ` Chia-I Wu
2026-05-16  3:32   ` Claude Code Review Bot [this message]
2026-05-12 11:37 ` [PATCH v2 07/11] drm/panthor: Automate CSG IRQ processing at group unbind time Boris Brezillon
2026-05-12 21:16   ` Chia-I Wu
2026-05-14 14:17   ` Steven Price
2026-05-16  3:32   ` Claude review: " Claude Code Review Bot
2026-05-12 11:37 ` [PATCH v2 08/11] drm/panthor: Automatically enable interrupts in panthor_fw_wait_acks() Boris Brezillon
2026-05-12 21:55   ` Chia-I Wu
2026-05-13  8:42     ` Boris Brezillon
2026-05-13 17:14       ` Chia-I Wu
2026-05-14 14:25   ` Steven Price
2026-05-16  3:32   ` Claude review: " Claude Code Review Bot
2026-05-12 11:37 ` [PATCH v2 09/11] drm/panthor: Process FW events in IRQ context Boris Brezillon
2026-05-12 22:05   ` Chia-I Wu
2026-05-12 22:09     ` Chia-I Wu
2026-05-13  8:44       ` Boris Brezillon
2026-05-14 15:23   ` Steven Price
2026-05-16  3:32   ` Claude review: " Claude Code Review Bot
2026-05-12 11:37 ` [PATCH v2 10/11] drm/panthor: Use the irqsave variant of spin_lock in panthor_gpu_irq_handler() Boris Brezillon
2026-05-14 15:26   ` Steven Price
2026-05-16  3:32   ` Claude review: " Claude Code Review Bot
2026-05-12 11:37 ` [PATCH v2 11/11] drm/panthor: Process GPU events in IRQ context Boris Brezillon
2026-05-12 11:50   ` Boris Brezillon
2026-05-12 22:40     ` Chia-I Wu
2026-05-13  8:54       ` Boris Brezillon
2026-05-13 18:07         ` Chia-I Wu
2026-05-16  3:32   ` Claude review: " Claude Code Review Bot
2026-05-16  3:32 ` Claude review: drm/panthor: Reduce dma_fence signalling latency Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-04-29  9:38 [PATCH 00/10] " Boris Brezillon
2026-04-29  9:38 ` [PATCH 06/10] drm/panthor: Prepare the scheduler logic for FW events in IRQ context Boris Brezillon
2026-05-05  1:44   ` Claude review: " 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-patch6-20260512-panthor-signal-from-irq-v2-6-95c614a739cb@collabora.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