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: rust: drm: dispatch work items to the private data
Date: Wed, 25 Mar 2026 07:11:04 +1000	[thread overview]
Message-ID: <review-patch2-20260323-aref-workitem-v3-2-f59729b812aa@collabora.com> (raw)
In-Reply-To: <20260323-aref-workitem-v3-2-f59729b812aa@collabora.com>

Patch Review

This patch implements `WorkItem` and `HasWork` for `Device<T>` to forward to `T::Data`.

**The `HasWork` implementation:**

```rust
unsafe impl<T, const ID: u64> HasWork<Device<T>, ID> for Device<T>
where
    T: drm::Driver,
    T::Data: HasWork<Device<T>, ID>,
{
    unsafe fn raw_get_work(ptr: *mut Self) -> *mut Work<Device<T>, ID> {
        let data_ptr = unsafe { &raw mut (*ptr).data };
        unsafe { T::Data::raw_get_work(data_ptr) }
    }
```

There's a subtle type issue worth noting: `T::Data::raw_get_work(data_ptr)` — the bound is `T::Data: HasWork<Device<T>, ID>`, so `raw_get_work` expects `*mut T::Data` (since `HasWork::raw_get_work` takes `*mut Self` where `Self = T::Data`). The `data_ptr` is `*mut T::Data` from `&raw mut (*ptr).data`, so this is correct.

The `work_container_of` does:

```rust
unsafe fn work_container_of(ptr: *mut Work<Device<T>, ID>) -> *mut Self {
    let data_ptr = unsafe { T::Data::work_container_of(ptr) };
    unsafe { crate::container_of!(data_ptr, Self, data) }
}
```

This correctly goes from `Work` → `T::Data` → `Device<T>` via `container_of`. Since `Device<T>` is `#[repr(C)]` with `data` as the second field, the `container_of` is valid.

**The `WorkItem` implementation:**

```rust
impl<T, const ID: u64> WorkItem<ID> for Device<T>
where
    T: drm::Driver,
    T::Data: WorkItem<ID, Pointer = ARef<Device<T>>>,
    T::Data: HasWork<Device<T>, ID>,
{
    type Pointer = ARef<Device<T>>;

    fn run(ptr: ARef<Device<T>>) {
        T::Data::run(ptr);
    }
}
```

This requires `T::Data: WorkItem<ID, Pointer = ARef<Device<T>>>`. This is the key constraint — the driver's data type must declare its work item pointer as `ARef<Device<T>>`, not `ARef<T::Data>`. This makes sense given the orphan rule motivation and is clearly documented in the commit message.

Looks correct.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-03-24 21:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 23:26 [PATCH v3 0/4] rust: Add ARef support for work items Daniel Almeida
2026-03-23 23:26 ` [PATCH v3 1/4] rust: workqueue: add support for ARef<T> Daniel Almeida
2026-03-24 11:00   ` Alice Ryhl
2026-03-24 21:11   ` Claude review: " Claude Code Review Bot
2026-03-23 23:27 ` [PATCH v3 2/4] rust: drm: dispatch work items to the private data Daniel Almeida
2026-03-24 21:11   ` Claude Code Review Bot [this message]
2026-03-23 23:27 ` [PATCH v3 3/4] rust: workqueue: add delayed work support for ARef<T> Daniel Almeida
2026-03-24 21:11   ` Claude review: " Claude Code Review Bot
2026-03-23 23:27 ` [PATCH v3 4/4] rust: drm: dispatch delayed work items to the private data Daniel Almeida
2026-03-24 21:11   ` Claude review: " Claude Code Review Bot
2026-03-24  8:20 ` [PATCH v3 0/4] rust: Add ARef support for work items Alice Ryhl
2026-03-24 21:11 ` 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-patch2-20260323-aref-workitem-v3-2-f59729b812aa@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