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: io: add view type
Date: Thu, 23 Apr 2026 08:25:46 +1000	[thread overview]
Message-ID: <review-patch6-20260421-io_projection-v2-6-4c251c692ef4@garyguo.net> (raw)
In-Reply-To: <20260421-io_projection-v2-6-4c251c692ef4@garyguo.net>

Patch Review

Introduces `View<'a, IO, T>` -- the core new abstraction. A view borrows an I/O region and holds a pointer to a sub-region within it.

The invariants are well-stated:
```rust
/// - `ptr` is aligned for `T`
/// - `ptr` has same provenance as `io.as_ptr()`
/// - `ptr.byte_offset_from(io.as_ptr())` is between 0 to
///   `KnownSize::size(io.as_ptr()) - KnownSize::size(ptr)`.
```

The `io_project!` macro leverages the existing `project!` pointer projection infrastructure and wraps the result in a `View`, which is clean.

The `try_cast` method requires `FromBytes + AsBytes` bounds, which correctly ensures safe reinterpretation. It checks both size and alignment:
```rust
if size_of::<U>() > KnownSize::size(self.ptr) {
    return Err(EINVAL);
}
if self.ptr.addr() % align_of::<U>() != 0 {
    return Err(EINVAL);
}
```

One design note: `View` is `Copy`, which is appropriate since it's just a reference + pointer pair, but means it can't enforce unique access. This is fine since I/O is inherently shared and the safety contracts are on the callers.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-04-22 22:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21 14:56 [PATCH v2 00/11] rust: I/O type generalization and projection Gary Guo
2026-04-21 14:56 ` [PATCH v2 01/11] rust: io: generalize `MmioRaw` to pointer to arbitrary type Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-21 14:56 ` [PATCH v2 02/11] rust: io: generalize `Mmio` " Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-21 14:56 ` [PATCH v2 03/11] rust: io: use pointer types instead of address Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-21 14:56 ` [PATCH v2 04/11] rust: io: add missing safety requirement in `IoCapable` methods Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-21 14:56 ` [PATCH v2 05/11] rust: io: restrict untyped IO access and `register!` to `Region` Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-21 14:56 ` [PATCH v2 06/11] rust: io: add view type Gary Guo
2026-04-22 22:25   ` Claude Code Review Bot [this message]
2026-04-21 14:56 ` [PATCH v2 07/11] rust: dma: add methods to unsafely create reference from subview Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-21 14:56 ` [PATCH v2 08/11] rust: io: add `read_val` and `write_val` function on I/O view Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-21 14:56 ` [PATCH v2 09/11] gpu: nova-core: use I/O projection for cleaner encapsulation Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-21 14:56 ` [PATCH v2 10/11] rust: dma: drop `dma_read!` and `dma_write!` API Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-21 14:56 ` [PATCH v2 11/11] rust: io: add copying methods Gary Guo
2026-04-22 22:25   ` Claude review: " Claude Code Review Bot
2026-04-22 22:25 ` Claude review: rust: I/O type generalization and projection 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-patch6-20260421-io_projection-v2-6-4c251c692ef4@garyguo.net \
    --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