From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: rust/drm/gem: Use DeviceContext with GEM objects
Date: Sun, 22 Mar 2026 03:17:23 +1000 [thread overview]
Message-ID: <review-patch5-20260320233645.950190-6-lyude@redhat.com> (raw)
In-Reply-To: <20260320233645.950190-6-lyude@redhat.com>
Patch Review
**GAT (Generic Associated Type) usage:**
```rust
type Object<Ctx: drm::DeviceContext>: AllocImpl;
```
This is a significant API change, making `Object` a GAT. This is well-motivated — it allows GEM objects to carry their device's context state.
**VTABLE initialization with arbitrary `Uninit` context:**
```rust
// Ignore the Uninit DeviceContext below. It is only provided because it is required by the
// compiler, and it is not actually used by these functions.
gem_create_object: T::Object::<Uninit>::ALLOC_OPS.gem_create_object,
```
The comment explains this well. Since `ALLOC_OPS` is a `const` that doesn't depend on the context type, the choice of `Uninit` is arbitrary and correct. It would be slightly cleaner if `AllocOps` were associated with the driver rather than the object type, but that would be a larger refactor.
**`open_callback` / `close_callback` use `Registered` context:**
```rust
let obj: &DriverAllocImpl<T> = unsafe { IntoGEMObject::from_raw(raw_obj) };
```
Since `DriverAllocImpl<T>` defaults to `DriverAllocImpl<T, Registered>`, this correctly uses the `Registered` context for callbacks that can only be invoked after registration. The safety comment explicitly calls this out — good.
**`Object::dev()` propagates `Ctx`:**
```rust
pub fn dev(&self) -> &drm::Device<T::Driver, Ctx> {
```
This is correct — if you have an `Object<T, Uninit>`, you get back a `&Device<T, Uninit>`, which appropriately restricts what you can do with the device.
**`BaseObject::create_handle` and `lookup_handle` bound changes:**
```rust
D: drm::Driver<Object<Registered> = Self, File = F>,
```
This correctly constrains these operations to only work with `Registered` context objects, since handle operations require a registered device.
**Overall:** This patch ties the series together cleanly. The PhantomData addition to `Object` is zero-cost, and the context propagation through the type system is sound.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-03-21 17:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 23:34 [PATCH v6 0/5] Introduce DeviceContext Lyude Paul
2026-03-20 23:34 ` [PATCH v6 1/5] rust/drm: Fix potential drop of uninitialized driver data Lyude Paul
2026-03-21 17:17 ` Claude review: " Claude Code Review Bot
2026-03-20 23:34 ` [PATCH v6 2/5] rust/drm: Introduce DeviceContext Lyude Paul
2026-03-21 17:17 ` Claude review: " Claude Code Review Bot
2026-03-20 23:34 ` [PATCH v6 3/5] rust/drm: Don't setup private driver data until registration Lyude Paul
2026-03-21 17:17 ` Claude review: " Claude Code Review Bot
2026-03-20 23:34 ` [PATCH v6 4/5] rust/drm/gem: Add DriverAllocImpl type alias Lyude Paul
2026-03-21 17:17 ` Claude review: " Claude Code Review Bot
2026-03-20 23:34 ` [PATCH v6 5/5] rust/drm/gem: Use DeviceContext with GEM objects Lyude Paul
2026-03-21 17:17 ` Claude Code Review Bot [this message]
2026-03-21 17:17 ` Claude review: Introduce DeviceContext 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-patch5-20260320233645.950190-6-lyude@redhat.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