An `as` cast silently drops the bits that do not fit the target type, and nothing at the cast shows whether that can happen. As part of a larger effort to reduce the number of `as` casts in Tyr, convert `VmAsData::va_bits` from `u8` to `u32`.
`VmAsData::new()` receives the number of virtual address bits as a `u32` and narrows it with `as` to store it in a `u8` field. The only reader of the field, `as_config()`, widens it again to `u64`. Store it as `u32`, which removes the cast. No functional change intended. Signed-off-by: Daniel Almeida <[email protected]> --- drivers/gpu/drm/tyr/mmu/address_space.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tyr/mmu/address_space.rs b/drivers/gpu/drm/tyr/mmu/address_space.rs index dd6377bee989..a388c0087b20 100644 --- a/drivers/gpu/drm/tyr/mmu/address_space.rs +++ b/drivers/gpu/drm/tyr/mmu/address_space.rs @@ -78,7 +78,7 @@ pub(crate) struct VmAsData<'drm> { as_seat: LockedSeat<AddressSpaceManager<'drm>, MAX_AS>, /// Virtual address bits for this address space. - va_bits: u8, + va_bits: u32, /// The page table which maps GPU virtual addresses to physical addresses for this VM. #[pin] @@ -105,7 +105,7 @@ pub(crate) fn new<'a>( try_pin_init!(Self { as_seat: LockedBy::new(&mmu.as_manager, Seat::NoSeat), - va_bits: va_bits as u8, + va_bits, page_table <- page_table_init, }? Error) } -- 2.56.0
