SZ_4G is used by Tyr when splitting the GPU VA range into user and kernel regions. Add a LargeSizeConstants trait, implemented for u64 since SizeConstants only covers sizes that fit in a u32.
Signed-off-by: Alvin Sun <[email protected]> Reviewed-by: Daniel Almeida <[email protected]> Reviewed-by: Gary Guo <[email protected]> Acked-by: Miguel Ojeda <[email protected]> --- rust/bindings/bindings_helper.h | 1 + rust/kernel/sizes.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h index 3791af0aadc73..fd39cc954eaba 100644 --- a/rust/bindings/bindings_helper.h +++ b/rust/bindings/bindings_helper.h @@ -116,6 +116,7 @@ const size_t RUST_CONST_HELPER_ARCH_SLAB_MINALIGN = ARCH_SLAB_MINALIGN; const size_t RUST_CONST_HELPER_ARCH_KMALLOC_MINALIGN = ARCH_KMALLOC_MINALIGN; const size_t RUST_CONST_HELPER_PAGE_SIZE = PAGE_SIZE; const size_t RUST_CONST_HELPER_GENLMSG_DEFAULT_SIZE = GENLMSG_DEFAULT_SIZE; +const unsigned long long RUST_CONST_HELPER_SZ_4G = SZ_4G; const gfp_t RUST_CONST_HELPER_GFP_ATOMIC = GFP_ATOMIC; const gfp_t RUST_CONST_HELPER_GFP_KERNEL = GFP_KERNEL; const gfp_t RUST_CONST_HELPER_GFP_KERNEL_ACCOUNT = GFP_KERNEL_ACCOUNT; diff --git a/rust/kernel/sizes.rs b/rust/kernel/sizes.rs index 188e00c2b8b46..760d26ebe6ff6 100644 --- a/rust/kernel/sizes.rs +++ b/rust/kernel/sizes.rs @@ -177,3 +177,15 @@ impl SizeConstants for $first { } define_sizes!(u32, u64, usize); + +/// Large size constants (≥ 4 GiB). +/// +/// Only implemented for [`u64`]. +pub trait LargeSizeConstants { + /// `0x1_0000_0000`. + const SZ_4G: Self; +} + +impl LargeSizeConstants for u64 { + const SZ_4G: Self = bindings::SZ_4G; +} -- 2.43.0
