From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/atomic: protect bridge private_obj during bridge removal
Date: Wed, 25 Mar 2026 06:50:56 +1000 [thread overview]
Message-ID: <review-patch1-20260324-drm-bridge-atomic-vs-remove-private_obj-v3-0-64deefe84044@bootlin.com> (raw)
In-Reply-To: <20260324-drm-bridge-atomic-vs-remove-private_obj-v3-0-64deefe84044@bootlin.com>
Patch Review
**Correctness**: The fix is correct. Looking at `drm_modeset_lock_all_ctx()` (in `drm_modeset_lock.c:451`), it iterates `drm_for_each_privobj()` and locks each private object. The race occurs when CPU1 calls `drm_atomic_private_obj_fini()` and does `list_del(&obj->head)` + `drm_modeset_lock_fini(&obj->lock)` while CPU0 still holds that lock in its acquire context. By wrapping `list_del` with `DRM_MODESET_LOCK_ALL_BEGIN/END`, the fini path must first acquire all modeset locks, which serializes against any concurrent `drm_modeset_lock_all_ctx()` user.
**One subtlety worth considering**: After `DRM_MODESET_LOCK_ALL_BEGIN` acquires all locks, it will also lock `obj->lock` itself (since `obj` is still in the `privobj_list` at that point). The `DRM_MODESET_LOCK_ALL_END` then drops all locks including `obj->lock`. Then `drm_modeset_lock_fini(&obj->lock)` is called outside the locked section, which checks `WARN_ON(!list_empty(&lock->head))` — at this point `lock->head` has been removed from `ctx->locked` by `drm_modeset_drop_locks()`, so the warn won't trigger. This is correct.
**Potential concern — `obj->dev` being NULL or stale**: The function uses `obj->dev` which was added by a prior patch ("drm/atomic: Add dev pointer to drm_private_obj"). This is fine as long as `obj->dev` is set during `drm_atomic_private_obj_init()` (confirmed at line 943: `obj->dev = dev;`).
**Ordering of operations**: The `atomic_destroy_state()` and `drm_modeset_lock_fini()` remain outside the locked region, which is correct — once the object is removed from the list, no concurrent code can find it, so no locking is needed for teardown.
**Minor nit**: The commit message says "Prevent this potential deadlock" but the issue described is actually a warning/use-after-remove, not a deadlock per se. The `DRM_MODESET_LOCK_ALL_BEGIN/END` approach handles actual deadlocks (via `-EDEADLK` backoff), but the original problem being solved is a race, not a deadlock. The v3 changelog mentions "Small commit message clarification" but this wording persists. Very minor.
**Overall**: Clean, minimal, correct fix. The approach of serializing via `DRM_MODESET_LOCK_ALL_BEGIN/END` is the right one — it reuses the existing deadlock avoidance infrastructure (ww_mutex) rather than introducing a new lock.
Reviewed-by worthy.
---
Generated by Claude Code Patch Reviewer
prev parent reply other threads:[~2026-03-24 20:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 13:07 [PATCH v3] drm/atomic: protect bridge private_obj during bridge removal Luca Ceresoli
2026-03-24 13:07 ` [PATCH v3] drm/atomic: drm_atomic_private_obj_fini: protect private_obj removal from list Luca Ceresoli
2026-03-24 20:50 ` Claude review: drm/atomic: protect bridge private_obj during bridge removal Claude Code Review Bot
2026-03-24 20:50 ` Claude Code Review Bot [this message]
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-patch1-20260324-drm-bridge-atomic-vs-remove-private_obj-v3-0-64deefe84044@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