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

From: Danilo Krummrich

Date: Tue Mar 10 2026 - 16:55:53 EST


On Tue Mar 10, 2026 at 9:47 PM CET, Danilo Krummrich wrote:
> On Tue Mar 10, 2026 at 9:20 PM CET, Miguel Ojeda wrote:
>> Whether we go for `u64::` or not
>
> The more I think about it, the more I tend towards not going for u64::, at least
> not directly.
>
> The point really is that we differentiate between GPU (or more generally device)
> address space size and CPU address space size.
>
> So, I think what we really want is an abstraction of a usize type for GPUs (or
> devices in general).

Forgot to mention, the background of this is that existing DRM components, such
as GPUVM, Buddy, etc. just use u64 as a common denominator. However, this
becomes annoying when the corresponding device is u32 (or even smaller outside
of DRM). Because then we have all the fallible conversions on the other end
where the driver interacts with the HW.

So, on the Rust side I think we want to abstract this, such that drivers can
choose the actual device size type and the corresponding APIs just work with
this type and store the actual value in the backing u64 internally, but hand it
out as the actual type the driver passed in originally.

> A corresponding implementation of SZ_* would just follow those.
>
> In any case, I think we should implement those with a macro.