Re: [PATCH 1/2] rust: sizes: add u64 variants of SZ_* constants

From: Danilo Krummrich

Date: Tue Mar 10 2026 - 13:12:21 EST


On Tue Mar 10, 2026 at 3:31 AM CET, John Hubbard wrote:
> Drivers that operate on 64-bit address spaces (GPU framebuffer layouts,
> DMA regions, etc.) frequently need these size constants as a u64 type.
> Today this requires repeated usize-to-u64 conversion calls like
> usize_as_u64(SZ_1M) or u64::from_safe_cast(SZ_1M), which adds
> boilerplate without any safety benefit.
>
> Add u64-typed constants (SZ_1K_U64 through SZ_2G_U64) alongside the
> existing usize constants. Every value fits in u64 (actually, within a
> u32 for that matter), so the as-cast is always lossless.
>
> Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>

Feel free to add:

Suggested-by: Danilo Krummrich <dakr@xxxxxxxxxx>
Link: https://lore.kernel.org/all/DGB9G697GSWO.3VBFGU5MKFPMR@xxxxxxxxxx/
Link: https://lore.kernel.org/all/DGHI8WRKBQS9.38910L6FIIZTE@xxxxxxxxxx/

As mentioned in the other thread, we could also make this GPU infrastructure and
have GPU specific usize / isize types.