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/bridge: lock the encoder chain in scoped for_each loops
Date: Wed, 25 Mar 2026 06:59:31 +1000	[thread overview]
Message-ID: <review-patch4-20260324-drm-bridge-alloc-encoder-chain-mutex-v5-4-8bf786c5c7e6@bootlin.com> (raw)
In-Reply-To: <20260324-drm-bridge-alloc-encoder-chain-mutex-v5-4-8bf786c5c7e6@bootlin.com>

Patch Review

This is the most complex patch. The mutex lifecycle in the for_each macros is well-designed:

**`__drm_for_each_bridge_in_chain_next()`**: Gets the next bridge (incrementing its refcount), then conditionally unlocks the mutex only when we've reached the end of the chain (`!next`), then puts the current bridge. The ordering is correct — the next bridge's refcount is incremented before the current bridge is released.

**`__drm_for_each_bridge_in_chain_cleanup`**: Called via `__free()` when the loop variable goes out of scope (break/return). Correctly checks `if (_T)` to handle the normal loop-completion case where `_T` is already NULL (mutex was already unlocked in `_next()`).

**`__drm_for_each_bridge_in_chain_scoped_start()`**: Locks mutex, gets first bridge, unlocks if no bridges exist. This avoids leaving the mutex locked when there's nothing to iterate.

**Potential concern:** In `__drm_for_each_bridge_in_chain_from_start()`, the bridge is `drm_bridge_get()`'d before the mutex is locked. If the bridge is being concurrently removed from the chain (before the mutex is taken), the bridge struct remains valid due to the refcount, but its `chain_node` links could be poisoned. Since `drm_bridge_detach()` calls `list_del()` which sets the pointers to `LIST_POISON`, this could be problematic. However, the refcount prevents the bridge from being freed, and the mutex prevents concurrent chain modifications during actual iteration. The brief window between `drm_bridge_get()` and `mutex_lock()` should be safe because the caller is expected to already hold a reference to `first_bridge`.

No blocking issues.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-03-24 20:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24  8:58 [PATCH v5 0/7] drm/bridge: protect encoder bridge chain with a mutex Luca Ceresoli
2026-03-24  8:58 ` [PATCH v5 1/7] drm/encoder: add mutex to protect the bridge chain Luca Ceresoli
2026-03-24 20:59   ` Claude review: " Claude Code Review Bot
2026-03-24  8:58 ` [PATCH v5 2/7] drm/encoder: drm_encoder_cleanup: lock the encoder chain mutex during removal Luca Ceresoli
2026-03-24 20:59   ` Claude review: " Claude Code Review Bot
2026-03-24  8:58 ` [PATCH v5 3/7] drm/bridge: drm_bridge_attach: lock the encoder chain mutex during insertion Luca Ceresoli
2026-03-24 20:59   ` Claude review: " Claude Code Review Bot
2026-03-24  8:58 ` [PATCH v5 4/7] drm/bridge: lock the encoder chain in scoped for_each loops Luca Ceresoli
2026-03-24 20:59   ` Claude Code Review Bot [this message]
2026-03-24  8:58 ` [PATCH v5 5/7] drm/bridge: prevent encoder chain changes while iterating with list_for_each_entry_from() Luca Ceresoli
2026-03-24 20:59   ` Claude review: " Claude Code Review Bot
2026-03-24  8:58 ` [PATCH v5 6/7] drm/bridge: prevent encoder chain changes while iterating with list_for_each_entry_reverse() Luca Ceresoli
2026-03-24 20:59   ` Claude review: " Claude Code Review Bot
2026-03-24  8:58 ` [PATCH v5 7/7] drm/bridge: prevent encoder chain changes in pre_enable/post_disable Luca Ceresoli
2026-03-24 20:59   ` Claude review: " Claude Code Review Bot
2026-03-24 20:59 ` Claude review: drm/bridge: protect encoder bridge chain with a mutex 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-patch4-20260324-drm-bridge-alloc-encoder-chain-mutex-v5-4-8bf786c5c7e6@bootlin.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