Re: [PATCH v6 01/20] rust: io: add dynamically-sized `Region` type
From: Daniel Almeida
Date: Tue Jul 07 2026 - 13:19:32 EST
Hi Gary,
A bit late to the party here, but going through this series one by one :)
> On 6 Jul 2026, at 09:44, Gary Guo <gary@xxxxxxxxxxx> wrote:
>
> Currently many I/O related structs carry a `SIZE` parameter to denote the
> minimum size of the I/O region, while they also carry a field indicating
> the actual size. Proliferation of the pattern creates a lot of duplicated
> code, and makes it hard to create typed views of I/O.
>
> Introduce a `Region` type that carries the `SIZE` parameter. It is a
> wrapper of `[u8]`, which makes it dynamically sized with a metadata of
> `usize`. This way, pointers to `Region` naturally carry size information.
> This type is required to be 4-byte aligned.
Why 4, specifically? i.e.: I wonder if this breaks u64 mmio accessors?
>
> Expose the minimum size information via `MIN_SIZE` constant of the
> `KnownSize` trait. Similarly, expose the minimum alignment information via
> `KnownSize::MIN_ALIGN`.
>
> With these changes, it is possible to add an associated type to `Io` trait
> to represent the type of I/O region. For untyped regions, this is the newly
> added `Region` type. Remove `IoKnownSize` as it is no longer necessary. Use
> the same mechanism to indicate minimum size of PCI config spaces.
>
> Reviewed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>
If MIN_ALIGN = 4 is actually intentional:
Reviewed-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>