Files
linux/rust
FUJITA Tomonori d8932355f8 rust: dma: add helpers for architectures without CONFIG_HAS_DMA
Add dma_set_mask(), dma_set_coherent_mask(), dma_map_sgtable(), and
dma_max_mapping_size() helpers to fix a build error when
CONFIG_HAS_DMA is not enabled.

Note that when CONFIG_HAS_DMA is enabled, they are included in both
bindings_generated.rs and bindings_helpers_generated.rs. The former
takes precedence so behavior remains unchanged in that case.

This fixes the following build error on UML:

error[E0425]: cannot find function `dma_set_mask` in crate `bindings`
     --> rust/kernel/dma.rs:46:38
      |
   46 |         to_result(unsafe { bindings::dma_set_mask(self.as_ref().as_raw(), mask.value()) })
      |                                      ^^^^^^^^^^^^ help: a function with a similar name exists: `xa_set_mark`
      |
     ::: rust/bindings/bindings_generated.rs:24690:5
      |
24690 |     pub fn xa_set_mark(arg1: *mut xarray, index: ffi::c_ulong, arg2: xa_mark_t);
      |     ---------------------------------------------------------------------------- similarly named function `xa_set_mark` defined here

error[E0425]: cannot find function `dma_set_coherent_mask` in crate `bindings`
     --> rust/kernel/dma.rs:63:38
      |
   63 |         to_result(unsafe { bindings::dma_set_coherent_mask(self.as_ref().as_raw(), mask.value()) })
      |                                      ^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `dma_coherent_ok`
      |
     ::: rust/bindings/bindings_generated.rs:52745:5
      |
52745 |     pub fn dma_coherent_ok(dev: *mut device, phys: phys_addr_t, size: usize) -> bool_;
      |     ---------------------------------------------------------------------------------- similarly named function `dma_coherent_ok` defined here

error[E0425]: cannot find function `dma_map_sgtable` in crate `bindings`
    --> rust/kernel/scatterlist.rs:212:23
     |
 212 |               bindings::dma_map_sgtable(dev.as_raw(), sgt.as_ptr(), dir.into(), 0)
     |                         ^^^^^^^^^^^^^^^ help: a function with a similar name exists: `dma_unmap_sgtable`
     |
    ::: rust/bindings/bindings_helpers_generated.rs:1351:5
     |
1351 | /     pub fn dma_unmap_sgtable(
1352 | |         dev: *mut device,
1353 | |         sgt: *mut sg_table,
1354 | |         dir: dma_data_direction,
1355 | |         attrs: ffi::c_ulong,
1356 | |     );
     | |______- similarly named function `dma_unmap_sgtable` defined here

error[E0425]: cannot find function `dma_max_mapping_size` in crate `bindings`
   --> rust/kernel/scatterlist.rs:356:52
    |
356 |         let max_segment = match unsafe { bindings::dma_max_mapping_size(dev.as_raw()) } {
    |                                                    ^^^^^^^^^^^^^^^^^^^^ not found in `bindings`

error: aborting due to 4 previous errors

Cc: stable@vger.kernel.org # v6.17+
Fixes: 101d66828a ("rust: dma: add DMA addressing capabilities")
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20251204160639.364936-1-fujita.tomonori@gmail.com
[ Use relative paths in the error splat; add 'dma' prefix. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-12-16 13:20:14 +01:00
..
2025-11-24 17:15:43 +01:00
2025-11-24 17:15:47 +01:00
2025-03-19 23:22:21 +01:00
2022-12-04 01:59:16 +01:00
2025-10-22 07:47:27 +02:00