Files
linux/rust/helpers
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-09-15 09:38:32 +02:00
2025-09-15 09:38:34 +02:00
2025-09-19 09:40:46 +02:00
2025-09-22 15:52:44 -04:00
2025-09-22 15:52:44 -04:00
2025-07-23 02:05:58 +02:00
2025-05-19 12:55:40 +05:30
2025-05-19 12:55:40 +05:30
2025-07-09 00:04:33 +02:00
2025-09-21 14:22:19 -07:00
2025-05-11 17:48:24 -07:00
2025-09-19 09:40:46 +02:00
2024-10-08 15:44:36 +02:00
2025-08-21 16:58:07 +02:00
2025-11-27 14:24:30 -08:00
2024-12-20 17:19:26 +01:00
2025-09-19 09:40:46 +02:00
2025-11-04 13:25:29 +01:00
2025-09-24 13:13:04 +02:00