Re: [PATCH v4 19/33] gpu: nova-core: Hopper/Blackwell: calculate reserved FB heap size

John Hubbard
2026-02-19T03:02:28Z

On 2/17/26 8:39 AM, Danilo Krummrich wrote:
> On Tue Feb 10, 2026 at 3:45 AM CET, John Hubbard wrote:
>> diff --git a/drivers/gpu/nova-core/num.rs b/drivers/gpu/nova-core/num.rs
>> index c952a834e662..f068722c5bdf 100644
>> --- a/drivers/gpu/nova-core/num.rs
>> +++ b/drivers/gpu/nova-core/num.rs
>> @@ -215,3 +215,13 @@ pub(crate) const fn [<$from _into_ $into>]<const N: $from>() -> $into {
>> impl_const_into!(u64 => { u8, u16, u32 });
>> impl_const_into!(u32 => { u8, u16 });
>> impl_const_into!(u16 => { u8 });
>> +
>> +/// Aligns `value` up to `ALIGN` at compile time.
>> +///
>> +/// This is the const-compatible equivalent of [`kernel::ptr::Alignable::align_up`].
>> +/// `ALIGN` must be a power of two (enforced at compile time).
>> +#[inline(always)]
>> +pub(crate) const fn const_align_up<const ALIGN: usize>(value: usize) -> usize {
>
> We should probably just add this as a function to Alignable.

So that would go in via a separate git branch? And therefore probably
I should send that change separately?

Or should I just create a new patch for rust/kernel/ptr.rs as part of
this series?

>
>> + build_assert!(ALIGN.is_power_of_two());
>
> ALIGN is a const generic, hence this should be:
>
> const { core::assert!(ALIGN.is_power_of_two(), "ALIGN must be a power of two") };

That doesn't compile on rustc 1.78.0:

error[E0658]: inline-const is experimental
--> drivers/gpu/nova-core/num.rs:225:5
|
225 | const { core::assert!(ALIGN.is_power_of_two(), "ALIGN must be a power of two") };
| ^^^^^
|
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
= help: add `#![feature(inline_const)]` to the crate attributes to enable
= note: this compiler was built on 2024-04-29; consider upgrading it if it is out of date

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.

>
>> + (value + (ALIGN - 1)) & !(ALIGN - 1)
>> +}

thanks,
--
John Hubbard