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: workqueue: add support for ARef<T>
Date: Wed, 25 Mar 2026 07:11:04 +1000	[thread overview]
Message-ID: <review-patch1-20260323-aref-workitem-v3-1-f59729b812aa@collabora.com> (raw)
In-Reply-To: <20260323-aref-workitem-v3-1-f59729b812aa@collabora.com>

Patch Review

This is the core patch, adding `WorkItemPointer`, `RawWorkItem`, and related trait implementations for `ARef<T>`.

The implementation closely mirrors the `Arc<T>` implementation, which is appropriate since both are refcounted smart pointers with similar ownership semantics.

**Minor observations:**

1. In the `WorkItemPointer::run` implementation, the `work_container_of` call returns a `*mut T` (not `*const T`), but the comment says:

```rust
// SAFETY: This computes the pointer that `__enqueue` got from
// `ARef::into_raw`.
let ptr = unsafe { T::work_container_of(ptr) };
```

This is fine — `ARef::into_raw` returns `NonNull<T>` which wraps a `*mut T` internally, so there's no const-to-mut cast issue here (unlike the `Arc` version which needs `cast_mut()`). Good.

2. The `__enqueue` method:

```rust
let ptr = ARef::into_raw(self);
// SAFETY: Pointers from ARef::into_raw are valid and non-null.
let work_ptr = unsafe { T::raw_get_work(ptr.as_ptr()) };
```

This is correct. `ARef::into_raw` returns `NonNull<T>`, so `.as_ptr()` gives the `*mut T` needed by `raw_get_work`. The refcount ownership is properly transferred: if `queue_work_on` returns true, the refcount is "leaked" to the work queue; if false, it's reclaimed via `ARef::from_raw(ptr)`.

3. The trait bounds use `T: AlwaysRefCounted` separately from `T: WorkItem<ID, Pointer = Self>`. This is slightly redundant since `ARef<T>` already requires `T: AlwaysRefCounted`, but being explicit is fine for clarity and consistency with how the other impls are structured.

Looks correct.

---
Generated by Claude Code Patch Reviewer

  parent 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 Code Review Bot [this message]
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 review: " Claude Code Review Bot
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-patch1-20260323-aref-workitem-v3-1-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