Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpu: nova-core: use sized array for GSP log buffers

Switch LogBuffer from Coherent<[u8]> (unsized) to
Coherent<[u8; LOG_BUFFER_SIZE]> (sized). The buffer size is a
compile-time constant (RM_LOG_BUFFER_NUM_PAGES * GSP_PAGE_SIZE), so a
fixed-size array is more precise and avoids the need for the runtime
length parameter of zeroed_slice().

Acked-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260325003921.3420-3-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

+6 -10
+6 -10
drivers/gpu/nova-core/gsp.rs
··· 42 42 43 43 /// Number of GSP pages to use in a RM log buffer. 44 44 const RM_LOG_BUFFER_NUM_PAGES: usize = 0x10; 45 + const LOG_BUFFER_SIZE: usize = RM_LOG_BUFFER_NUM_PAGES * GSP_PAGE_SIZE; 45 46 46 47 /// Array of page table entries, as understood by the GSP bootloader. 47 48 #[repr(C)] ··· 78 77 /// then pp points to index into the buffer where the next logging entry will 79 78 /// be written. Therefore, the logging data is valid if: 80 79 /// 1 <= pp < sizeof(buffer)/sizeof(u64) 81 - struct LogBuffer(Coherent<[u8]>); 80 + struct LogBuffer(Coherent<[u8; LOG_BUFFER_SIZE]>); 82 81 83 82 impl LogBuffer { 84 83 /// Creates a new `LogBuffer` mapped on `dev`. 85 84 fn new(dev: &device::Device<device::Bound>) -> Result<Self> { 86 - const NUM_PAGES: usize = RM_LOG_BUFFER_NUM_PAGES; 87 - 88 - let obj = Self(Coherent::<u8>::zeroed_slice( 89 - dev, 90 - NUM_PAGES * GSP_PAGE_SIZE, 91 - GFP_KERNEL, 92 - )?); 85 + let obj = Self(Coherent::zeroed(dev, GFP_KERNEL)?); 93 86 94 87 let start_addr = obj.0.dma_handle(); 95 88 96 89 // SAFETY: `obj` has just been created and we are its sole user. 97 - let pte_region = 98 - unsafe { &mut obj.0.as_mut()[size_of::<u64>()..][..NUM_PAGES * size_of::<u64>()] }; 90 + let pte_region = unsafe { 91 + &mut obj.0.as_mut()[size_of::<u64>()..][..RM_LOG_BUFFER_NUM_PAGES * size_of::<u64>()] 92 + }; 99 93 100 94 // Write values one by one to avoid an on-stack instance of `PteArray`. 101 95 for (i, chunk) in pte_region.chunks_exact_mut(size_of::<u64>()).enumerate() {