Re: [PATCH v2 3/3] gpu: nova-core: use DeviceSize trait for u64 size constants

From: Alexandre Courbot

Date: Tue Mar 24 2026 - 10:07:34 EST


On Thu Mar 12, 2026 at 12:15 PM JST, John Hubbard wrote:
<snip>
> @@ -211,15 +208,15 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result<
> };
>
> let frts = {
> - const FRTS_DOWN_ALIGN: Alignment = Alignment::new::<SZ_128K>();
> - const FRTS_SIZE: u64 = usize_as_u64(SZ_1M);
> + const FRTS_DOWN_ALIGN: Alignment = Alignment::from_u64(u64::SZ_128K);

Replacing the call to `new` by `from_u64` seems to be unnecessary -
`Alignment` works with `usize`, which `SZ_128K` already is. By using
`from_u64` we convert `SZ_128K` into a `u64` in the `define_sizes`
macro, only to convert it back into a `usize`.

All the uses of `from_u64` follow this pattern, so I'd say we can just
drop patch 2.

> + const FRTS_SIZE: u64 = u64::SZ_1M;

This, on the other hand, is really useful and much better than using
`usize_as_u64`. Actually I'm wondering whether we should not have
`DeviceSize` implemented for `usize` as well to provide better scope and
consistency (in which case it should just be renamed `Size`?) and sunset
the original definitions.