On Sun Jul 19, 2026 at 12:40 PM CEST, Lorenzo Delgado wrote: > I tried that, but it doesn't build. ResourceSize wraps resource_size_t, > which is u64 on 64-bit (CONFIG_PHYS_ADDR_T_64BIT), so the impl the patch > already has, > > impl From<ResourceSize> for bindings::resource_size_t > > is already From<ResourceSize> for u64 there, and a second one conflicts: > > error[E0119]: conflicting implementations of trait > `From<ResourceSize>` for type `u64`
Sure, but in the case a cfg-gate is perfectly fine, as the impl will always be availble. Either through impl for u64 directly or through impl for bindings::resource_size_t. > There's a simpler way that stays infallible and adds nothing to io.rs. > ResourceSize already has into_raw() (io/resource.rs uses it at the C > boundaries), so nova-core can do: > > let num_pages = > > usize::from_safe_cast(sg_entry.dma_len().into_raw()).div_ceil(GSP_PAGE_SIZE); > > into_raw() gives back resource_size_t, and from_safe_cast handles that > as u32 or u64 depending on the config, so it stays infallible. I'll use > that in v2 unless you'd prefer something else. I don't want to grow it arbitrarily in nova-core - which is also why I opened the question of moving FromSafeCast to generic infrastructure again - but in this case we should rather add the FromSafeCast<ResourceSize> for usize impl in drivers/gpu/nova-core/num.rs for now and move it subsequently.
