From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm: nova: convert to use DRM registration data
Date: Thu, 04 Jun 2026 12:03:18 +1000 [thread overview]
Message-ID: <review-patch7-20260603011711.2077361-8-dakr@kernel.org> (raw)
In-Reply-To: <20260603011711.2077361-8-dakr@kernel.org>
Patch Review
This is the demonstration patch. Nova moves the auxiliary device reference from `drm::Device` data into `RegistrationData`:
```rust
-pub(crate) struct NovaData {
- pub(crate) adev: ARef<auxiliary::Device>,
+pub(crate) struct NovaData<'bound> {
+ pub(crate) adev: &'bound auxiliary::Device<Bound>,
}
```
And the driver trait:
```rust
- type Data = NovaData;
- type RegistrationData = ForLt!(());
+ type Data = ();
+ type RegistrationData = CovariantForLt!(NovaData<'_>);
```
**Key change**: `Data` becomes `()` (no per-device data accessible without UnbindGuard) and `RegistrationData` becomes `CovariantForLt!(NovaData<'_>)` containing the borrowed `&'bound auxiliary::Device<Bound>`.
**`new_with_lt()` usage**:
```rust
+ let drm = drm::UnregisteredDevice::<Self>::new(adev, Ok(()))?;
+ let reg_data = NovaData { adev };
+ // SAFETY: We never bypass the destructor of `reg`.
+ let reg = unsafe { drm::Registration::new_with_lt(adev.as_ref(), drm, reg_data, 0)? };
```
The `new_with_lt()` is unsafe because the caller must not `mem::forget()` the Registration (which would cause use-after-free of the borrowed `adev` reference after the bus driver unbinds). The safety comment "We never bypass the destructor of `reg`" is correct — `reg` is stored in `Nova<'bound>` which is the bus driver's `Data<'bound>`, and the bus framework guarantees drop is called.
Note that `drm::UnregisteredDevice::new(adev, Ok(()))` passes `Ok(())` as the data init — this works because `PinInit<(), Error>` is implemented for `Result<()>`. Slightly unusual but correct.
**In `get_param()`**:
```rust
- let adev = &dev.adev;
- let parent = adev.parent();
- let pdev: &pci::Device = parent.try_into()?;
+ let parent = reg_data.adev.parent();
+ let pdev: &pci::Device<Bound> = parent.try_into()?;
```
Now the PCI device reference is `&pci::Device<Bound>` instead of `&pci::Device` (unbound). This is a type-level improvement — the bound context guarantees the PCI device is still bound, which is correct within the `drm_dev_enter()` critical section.
Overall: this is a well-structured, carefully thought-out series that addresses a genuine soundness concern. The SRCU-based safety argument is correct (verified against the C `drm_dev_unplug()` implementation), and the HRTB closure pattern for lifetime-erased data access is the standard Rust approach for this kind of problem. The incremental patch structure makes it easy to review each step.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-06-04 2:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 1:15 [PATCH v2 0/7] rust: drm: Higher-Ranked Lifetime private data Danilo Krummrich
2026-06-03 1:15 ` [PATCH v2 1/7] rust: drm: Add Driver::ParentDevice associated type Danilo Krummrich
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 2/7] rust: drm: Add UnbindGuard for drm_dev_enter/exit critical sections Danilo Krummrich
2026-06-03 11:47 ` Gary Guo
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 3/7] rust: drm: Add RegistrationData to drm::Driver Danilo Krummrich
2026-06-03 11:51 ` Gary Guo
2026-06-03 22:24 ` Danilo Krummrich
2026-06-03 22:36 ` Gary Guo
2026-06-03 23:29 ` Deborah Brouwer
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 4/7] rust: drm: Wrap ioctl dispatch in UnbindGuard Danilo Krummrich
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 5/7] rust: drm: Pass bound parent device to ioctl handlers Danilo Krummrich
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 6/7] rust: drm: Pass registration data " Danilo Krummrich
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 7/7] drm: nova: convert to use DRM registration data Danilo Krummrich
2026-06-04 2:03 ` Claude Code Review Bot [this message]
2026-06-04 2:03 ` Claude review: rust: drm: Higher-Ranked Lifetime private data 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-patch7-20260603011711.2077361-8-dakr@kernel.org \
--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