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.

rust: dma: allow drivers to tune max segment size

Make dma_set_max_seg_size() available to Rust so drivers can perform
standard DMA setup steps.

Signed-off-by: Beata Michalska <beata.michalska@arm.com>
Acked-by: Robin Murphy <robvin.murphy@arm.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260128135320.689046-1-beata.michalska@arm.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

Beata Michalska and committed by
Danilo Krummrich
c7125739 7c60d964

+23
+6
rust/helpers/dma.c
··· 43 43 { 44 44 return dma_max_mapping_size(dev); 45 45 } 46 + 47 + __rust_helper void rust_helper_dma_set_max_seg_size(struct device *dev, 48 + unsigned int size) 49 + { 50 + dma_set_max_seg_size(dev, size); 51 + }
+17
rust/kernel/dma.rs
··· 85 85 bindings::dma_set_mask_and_coherent(self.as_ref().as_raw(), mask.value()) 86 86 }) 87 87 } 88 + 89 + /// Set the maximum size of a single DMA segment the device may request. 90 + /// 91 + /// This method is usually called once from `probe()` as soon as the device capabilities are 92 + /// known. 93 + /// 94 + /// # Safety 95 + /// 96 + /// This method must not be called concurrently with any DMA allocation or mapping primitives, 97 + /// such as [`CoherentAllocation::alloc_attrs`]. 98 + unsafe fn dma_set_max_seg_size(&self, size: u32) { 99 + // SAFETY: 100 + // - By the type invariant of `device::Device`, `self.as_ref().as_raw()` is valid. 101 + // - The safety requirement of this function guarantees that there are no concurrent calls 102 + // to DMA allocation and mapping primitives using this parameter. 103 + unsafe { bindings::dma_set_max_seg_size(self.as_ref().as_raw(), size) } 104 + } 88 105 } 89 106 90 107 /// A DMA mask that holds a bitmask with the lowest `n` bits set.