On Tue Jul 7, 2026 at 6:14 PM BST, Daniel Almeida wrote:
> 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 <[email protected]> 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?

It does, but if the alignment is 8 then it breaks a lot of platform devices. 4
is the most common alignment needed so it is chosen. Different base types can be
added subsequently when needs arise.

There's some additional discussions here:
https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Generic.20I.2FO.20backends/with/601411822
and in earlier versions.

Best,
Gary

>> 
>> 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 <[email protected]>
>> Signed-off-by: Gary Guo <[email protected]>
>
> If MIN_ALIGN = 4 is actually intentional:
>
> Reviewed-by: Daniel Almeida <[email protected]>


Reply via email to