Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] rust: missing SizeConstants implementation and sub-1K constants for 
Alignment
--

commit 2a0eb77a4c0fef593fa5a986d45a2a3fe50ca233
Author: Eliot Courtney <[email protected]>

rust: use Alignment size constants

This commit replaces Alignment::new::<...>() calls with SizeConstants
associated constants on Alignment across rust/kernel/ and
drivers/gpu/nova-core/.

> diff --git a/drivers/gpu/nova-core/mm.rs b/drivers/gpu/nova-core/mm.rs
> index 8a934c55169fd..f53886f9ed91e 100644
> --- a/drivers/gpu/nova-core/mm.rs
> +++ b/drivers/gpu/nova-core/mm.rs
> @@ -317,7 +317,7 @@ pub(crate) fn run(
>  
>          let base = usable_fb_regions.iter().find_map(|region| {
>              // Tests rely on this being 8 byte aligned for checking 
> misalignment handling.
> -            let base = region.start.align_up(Alignment::new::<8>())?;
> +            let base = region.start.align_up(Alignment::SZ_8)?;
>              (base.checked_add(SELFTEST_SPAN)? <= region.end).then_some(base)
>          });
>          let Some(base) = base else {
> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
> index 9c214b9f4dd9d..a2d2d170b5014 100644
> --- a/drivers/gpu/nova-core/vbios.rs
> +++ b/drivers/gpu/nova-core/vbios.rs

[ ... ]

> @@ -291,7 +294,7 @@ fn next(&mut self) -> Option<Self::Item> {
>  
>          // Advance to next image (aligned to 512 bytes).
>          self.current_offset += image_size;
> -        self.current_offset = 
> self.current_offset.align_up(Alignment::new::<512>())?;
> +        self.current_offset = 
> self.current_offset.align_up(Alignment::SZ_512)?;
>  
>          Some(Ok(full_image))
>      }
> diff --git a/rust/kernel/io.rs b/rust/kernel/io.rs
> index de8ef8e2aec41..5712478a54616 100644
> --- a/rust/kernel/io.rs
> +++ b/rust/kernel/io.rs
> @@ -19,7 +19,8 @@
>      ptr::{
>          Alignment,
>          KnownSize, //
> -    }, //
> +    },
> +    sizes::SizeConstants, //
>  };
>  
>  #[cfg(CONFIG_HAS_IOMEM)]
> @@ -90,7 +91,7 @@ pub fn ptr_try_from_raw_parts_mut(base: *mut u8, size: 
> usize) -> Result<*mut Sel
>  impl<const SIZE: usize> KnownSize for Region<SIZE> {
>      const MIN_SIZE: usize = SIZE;
>      // Alignment of 4 is the most common; different base types can be added 
> once required.
> -    const MIN_ALIGN: Alignment = Alignment::new::<4>();
> +    const MIN_ALIGN: Alignment = Alignment::SZ_4;
>  
>      #[inline(always)]
>      fn size(p: *const Self) -> usize {

[Severity: Low]
Is this patch missing a prerequisite commit that implements SizeConstants for
Alignment and adds the sub-1K size constants?

Currently in rust/kernel/sizes.rs, define_sizes! is only invoked for integer
types:

    define_sizes!(u32, u64, usize);

and define_sizes! only defines constants from SZ_1K through SZ_2G. There is no
SizeConstants implementation for Alignment in rust/kernel/sizes.rs or
rust/kernel/ptr.rs, and sub-1K constants such as SZ_4 (used in
Region::MIN_ALIGN in rust/kernel/io.rs), SZ_8 (used in selftest::run in
drivers/gpu/nova-core/mm.rs under CONFIG_NOVA_CORE_SELFTESTS), and SZ_512 (used
in PciRomImageIterator::next in drivers/gpu/nova-core/vbios.rs) are not defined
in SizeConstants.

Without that prerequisite change, will building the kernel Rust crate,
rust/kernel/gpu/buddy.rs doctests, and drivers/gpu/nova-core/ fail?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to