On Fri Oct 17, 2025 at 8:11 AM JST, Danilo Krummrich wrote: > On Fri Oct 17, 2025 at 1:03 AM CEST, Alistair Popple wrote: >> On 2025-10-16 at 17:23 +1100, Alexandre Courbot <[email protected]> >> wrote... >>> On Mon Oct 13, 2025 at 3:20 PM JST, Alistair Popple wrote: >>> > +impl GspFwWprMeta { >>> > + pub(crate) fn new(gsp_firmware: &GspFirmware, fb_layout: &FbLayout) >>> > -> Self { >>> > + Self(bindings::GspFwWprMeta { >>> > + magic: r570_144::GSP_FW_WPR_META_MAGIC as u64, >>> > + revision: u64::from(r570_144::GSP_FW_WPR_META_REVISION), >>> > + sysmemAddrOfRadix3Elf: gsp_firmware.radix3_dma_handle(), >>> > + sizeOfRadix3Elf: gsp_firmware.size as u64, >>> >>> Very unfortunately I'm afraid we will need to replace the `as` in this >>> method with `u64::try_from` and make it return a `Result` for now. >> >> And presumably most of the other `as` keywords in this function dealing with >> usize as well? Have made the change but would you mind quickly explaining >> why this is needed? Is the concern that usize might be more than 64 bits or >> something? > > Since nova-core depends on CONFIG_64BIT, I think we want a helper function > that > converts usize to u64 infallibly. > > This helper function can simply generate a compile time error, when > !CONFIG_64BIT, etc. > > We can do this locally in nova-core, but it could also find it's place in the > generic infrastructure. nova-core clearly won't be the last driver running > into > this inconvinience.
How do you see this taking shape concretely? I have tried writing extention traits (e.g. `IntoU64`), but unfortunately we also need to use these in const contexts so that won't until const trait methods are a thing. The alternative would be to have const functions like `usize_to_u64`. It doesn't look as smooth as the extention trait, but can be used in const contexts. I can try and provide an implementation to apply before this patch series if given guidance on which direction we want to go.
