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: gem: shmem: Add vmap functions
Date: Fri, 05 Jun 2026 06:03:38 +1000	[thread overview]
Message-ID: <review-patch2-20260604192740.659240-3-lyude@redhat.com> (raw)
In-Reply-To: <20260604192740.659240-3-lyude@redhat.com>

Patch Review

**Generally well-structured.** The `make_vmap` → `vmap`/`owned_vmap` pattern with the generic `R: Deref<Target = Self> + From<&'a Self>` is clean and avoids code duplication.

**Lock/unlock sequencing in `make_vmap` looks correct:**
```rust
let guard = DmaResvGuard::new(self);
to_result(unsafe {
    bindings::drm_gem_shmem_vmap_locked(self.as_raw_shmem(), map.as_mut_ptr())
})?;
drop(guard);
```
The explicit `drop(guard)` before the iomem check + potential `raw_vunmap` is necessary since `raw_vunmap` re-acquires the lock. Good.

**`ENOTSUPP` for iomem:** The XXX comment acknowledges this limitation. `ENOTSUPP` vs `EOPNOTSUPP` — kernel convention typically uses `EOPNOTSUPP` for userspace-facing errors and `ENOTSUPP` for internal use. Since this is an internal Rust API, `ENOTSUPP` is acceptable but worth confirming intent.

**`IoCapable` macro — raw pointer casts from `usize`:**
```rust
unsafe fn io_read(&self, address: usize) -> $ty {
    let ptr = address as *mut $ty;
    unsafe { ptr::read(ptr) }
}
```
The `address` is a raw kernel virtual address cast from the `Io` trait's `addr()`. The safety contract is documented via `Io` trait bounds. This follows the existing kernel `Io` pattern so it's fine.

**Test coverage is good.** The `compile_time_vmap_sizes` test validates the SIZE invariant, and `vmap_io` exercises read/write paths including cross-type verification (write u32 then read individual u8 bytes).

**Byte-order assumption in test:**
```rust
vmap.write32(0xFFFFFFFF, 0x20);
assert_eq!(vmap.read8(0x20), 0xFF);
```
This works for `0xFFFFFFFF` regardless of endianness, but the pattern would be fragile for other values. Since all bytes are `0xFF` here, it's fine.

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-06-04 20:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04 19:24 [PATCH v18 0/4] Rust bindings for gem shmem Lyude Paul
2026-06-04 19:24 ` [PATCH v18 1/4] rust: drm: gem: shmem: Add DmaResvGuard helper Lyude Paul
2026-06-04 19:39   ` sashiko-bot
2026-06-04 20:03   ` Claude review: " Claude Code Review Bot
2026-06-04 19:24 ` [PATCH v18 2/4] rust: drm: gem: shmem: Add vmap functions Lyude Paul
2026-06-04 19:41   ` sashiko-bot
2026-06-04 20:03   ` Claude Code Review Bot [this message]
2026-06-04 19:24 ` [PATCH v18 3/4] rust: faux: Allow retrieving a bound Device Lyude Paul
2026-06-04 19:39   ` sashiko-bot
2026-06-04 20:03   ` Claude review: " Claude Code Review Bot
2026-06-04 19:24 ` [PATCH v18 4/4] rust: drm: gem: Introduce shmem::Object::sg_table() Lyude Paul
2026-06-04 19:54   ` sashiko-bot
2026-06-04 20:03   ` Claude review: " Claude Code Review Bot
2026-06-04 20:03 ` Claude review: Rust bindings for gem shmem Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-06-03 19:42 [PATCH v17 0/6] " Lyude Paul
2026-06-03 19:42 ` [PATCH v17 3/6] rust: drm: gem: shmem: Add vmap functions Lyude Paul
2026-06-04  1:29   ` 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-20260604192740.659240-3-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