[PATCH v2 0/3] Inline helpers into Rust without full LTO
Marek Szyprowski
m.szyprowski at samsung.com
Fri Mar 27 01:16:52 PDT 2026
On 26.03.2026 22:12, Arnd Bergmann wrote:
> On Sun, Mar 22, 2026, at 20:46, Miguel Ojeda wrote:
>> On Sun, 22 Mar 2026 20:21:59 +0100 Miguel Ojeda <ojeda at kernel.org> wrote:
>> BINDGEN rust/bindings/bindings_generated.rs - due to target
>> missing
>> In file included from rust/helpers/helpers.c:59:
>> rust/helpers/dma.c:17:2: warning: static function 'dma_free_attrs'
>> is used in an inline function with external linkage [-Wstatic-in-inline]
>> 17 | dma_free_attrs(dev, size, cpu_addr, dma_handle,
>> attrs);
>> | ^
>> rust/helpers/dma.c:12:1: note: use 'static' to give inline function
>> 'rust_helper_dma_free_attrs' internal linkage
>> 12 | __rust_helper void rust_helper_dma_free_attrs(struct device
>> *dev, size_t size,
>> | ^
>> | static
>>
>> For some reason, `dma_free_attrs` is not marked `inline` in
>> `include/linux/dma-mapping.h` to begin with, unlike the rest.
>>
>> Unless I am missing something and there is a reason for that, it looks
>> like it has just been missing since it was added in commit ed6ccf10f24b
>> ("dma-mapping: properly stub out the DMA API for !CONFIG_HAS_DMA").
>>
>> Do you want a patch?
> I have an older patch to drop CONFIG_NO_DMA entirely, which
> may be better here, since we know that nobody cares about the
> empty stubs.
The inline fix is already merged to v7.0-rc, but I'm fine with stubs
removal and I can queue them to -next. Could You send a proper patch
separately so I can easily apply it?
> The only targets that 'select NO_DMA' today are m68k (sun3
> and dragonball), sh2 and um, which are some of the targets
> that don't have any DMA masters, but there is little downside
> of enabling the DMA mapping interfaces on those as well.
>
> Signed-off-by: Arnd Bergmann <arnd at arndb.de>
>
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index 11835eb59d94..19fb556357fc 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -38,7 +38,6 @@ config M68K
> select MMU_GATHER_NO_RANGE if MMU
> select MODULES_USE_ELF_REL
> select MODULES_USE_ELF_RELA
> - select NO_DMA if !MMU && !COLDFIRE
> select OLD_SIGACTION
> select OLD_SIGSUSPEND3
> select UACCESS_MEMCPY if !MMU
> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
> index c9a7e602d8a4..adc50396b87d 100644
> --- a/arch/m68k/Kconfig.cpu
> +++ b/arch/m68k/Kconfig.cpu
> @@ -38,7 +38,6 @@ config SUN3
> depends on MMU
> select HAVE_ARCH_PFN_VALID
> select LEGACY_TIMER_TICK
> - select NO_DMA
> select M68020
> help
> This option enables support for the Sun 3 series of workstations
> @@ -558,4 +557,4 @@ config COLDFIRE_COHERENT_DMA
> config M68K_NONCOHERENT_DMA
> bool
> default y
> - depends on HAS_DMA && !COLDFIRE_COHERENT_DMA
> + depends on HAS_DMA && !COLDFIRE_COHERENT_DMA && !SUN3
> diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h
> index 7501ff030c63..d095ae6c19f9 100644
> --- a/arch/m68k/include/asm/pgtable_mm.h
> +++ b/arch/m68k/include/asm/pgtable_mm.h
> @@ -159,8 +159,10 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf,
> ? (__pgprot((pgprot_val(prot) & _CACHEMASK040) | _PAGE_NOCACHE_S)) \
> : (prot)))
>
> +#ifndef CONFIG_SUN3
> pgprot_t pgprot_dmacoherent(pgprot_t prot);
> #define pgprot_dmacoherent(prot) pgprot_dmacoherent(prot)
> +#endif
>
> #endif /* CONFIG_COLDFIRE */
> #endif /* !__ASSEMBLER__ */
> diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c
> index 16063783aa80..c52584e024af 100644
> --- a/arch/m68k/kernel/dma.c
> +++ b/arch/m68k/kernel/dma.c
> @@ -8,7 +8,7 @@
> #include <linux/kernel.h>
> #include <asm/cacheflush.h>
>
> -#ifndef CONFIG_COLDFIRE
> +#if !defined(CONFIG_COLDFIRE) && !defined(CONFIG_SUN3)
> void arch_dma_prep_coherent(struct page *page, size_t size)
> {
> cache_push(page_to_phys(page), size);
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index d5795067befa..e246f295ec48 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -63,7 +63,6 @@ config SUPERH
> select LOCK_MM_AND_FIND_VMA
> select MODULES_USE_ELF_RELA
> select NEED_SG_DMA_LENGTH
> - select NO_DMA if !MMU && !DMA_COHERENT
> select NO_GENERIC_PCI_IOPORT_MAP if PCI
> select OLD_SIGACTION
> select OLD_SIGSUSPEND
> @@ -133,10 +132,10 @@ config SWAP_IO_SPACE
> bool
>
> config DMA_COHERENT
> - bool
> + def_bool !MMU
>
> config DMA_NONCOHERENT
> - def_bool !NO_DMA && !DMA_COHERENT
> + def_bool !DMA_COHERENT
> select ARCH_HAS_DMA_PREP_COHERENT
> select ARCH_HAS_SYNC_DMA_FOR_DEVICE
> select DMA_DIRECT_REMAP
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index 098cda44db22..dd3428a49614 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -25,7 +25,6 @@ config UML
> select HAVE_DEBUG_KMEMLEAK
> select HAVE_DEBUG_BUGVERBOSE
> select HAVE_PAGE_SIZE_4KB
> - select NO_DMA if !UML_DMA_EMULATION
> select OF_EARLY_FLATTREE if OF
> select GENERIC_IRQ_SHOW
> select GENERIC_CPU_DEVICES
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 677c51ab7510..a96a22f857f1 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -138,7 +138,6 @@ static inline void debug_dma_map_single(struct device *dev, const void *addr,
> }
> #endif /* CONFIG_DMA_API_DEBUG */
>
> -#ifdef CONFIG_HAS_DMA
> static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
> {
> debug_dma_mapping_error(dev, dma_addr);
> @@ -200,146 +199,6 @@ void *dma_vmap_noncontiguous(struct device *dev, size_t size,
> void dma_vunmap_noncontiguous(struct device *dev, void *vaddr);
> int dma_mmap_noncontiguous(struct device *dev, struct vm_area_struct *vma,
> size_t size, struct sg_table *sgt);
> -#else /* CONFIG_HAS_DMA */
> -static inline dma_addr_t dma_map_page_attrs(struct device *dev,
> - struct page *page, size_t offset, size_t size,
> - enum dma_data_direction dir, unsigned long attrs)
> -{
> - return DMA_MAPPING_ERROR;
> -}
> -static inline void dma_unmap_page_attrs(struct device *dev, dma_addr_t addr,
> - size_t size, enum dma_data_direction dir, unsigned long attrs)
> -{
> -}
> -static inline dma_addr_t dma_map_phys(struct device *dev, phys_addr_t phys,
> - size_t size, enum dma_data_direction dir, unsigned long attrs)
> -{
> - return DMA_MAPPING_ERROR;
> -}
> -static inline void dma_unmap_phys(struct device *dev, dma_addr_t addr,
> - size_t size, enum dma_data_direction dir, unsigned long attrs)
> -{
> -}
> -static inline unsigned int dma_map_sg_attrs(struct device *dev,
> - struct scatterlist *sg, int nents, enum dma_data_direction dir,
> - unsigned long attrs)
> -{
> - return 0;
> -}
> -static inline void dma_unmap_sg_attrs(struct device *dev,
> - struct scatterlist *sg, int nents, enum dma_data_direction dir,
> - unsigned long attrs)
> -{
> -}
> -static inline int dma_map_sgtable(struct device *dev, struct sg_table *sgt,
> - enum dma_data_direction dir, unsigned long attrs)
> -{
> - return -EOPNOTSUPP;
> -}
> -static inline dma_addr_t dma_map_resource(struct device *dev,
> - phys_addr_t phys_addr, size_t size, enum dma_data_direction dir,
> - unsigned long attrs)
> -{
> - return DMA_MAPPING_ERROR;
> -}
> -static inline void dma_unmap_resource(struct device *dev, dma_addr_t addr,
> - size_t size, enum dma_data_direction dir, unsigned long attrs)
> -{
> -}
> -static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
> -{
> - return -ENOMEM;
> -}
> -static inline void *dma_alloc_attrs(struct device *dev, size_t size,
> - dma_addr_t *dma_handle, gfp_t flag, unsigned long attrs)
> -{
> - return NULL;
> -}
> -static inline void dma_free_attrs(struct device *dev, size_t size,
> - void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs)
> -{
> -}
> -static inline void *dmam_alloc_attrs(struct device *dev, size_t size,
> - dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs)
> -{
> - return NULL;
> -}
> -static inline void dmam_free_coherent(struct device *dev, size_t size,
> - void *vaddr, dma_addr_t dma_handle)
> -{
> -}
> -static inline int dma_get_sgtable_attrs(struct device *dev,
> - struct sg_table *sgt, void *cpu_addr, dma_addr_t dma_addr,
> - size_t size, unsigned long attrs)
> -{
> - return -ENXIO;
> -}
> -static inline int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
> - void *cpu_addr, dma_addr_t dma_addr, size_t size,
> - unsigned long attrs)
> -{
> - return -ENXIO;
> -}
> -static inline bool dma_can_mmap(struct device *dev)
> -{
> - return false;
> -}
> -static inline bool dma_pci_p2pdma_supported(struct device *dev)
> -{
> - return false;
> -}
> -static inline int dma_set_mask(struct device *dev, u64 mask)
> -{
> - return -EIO;
> -}
> -static inline int dma_set_coherent_mask(struct device *dev, u64 mask)
> -{
> - return -EIO;
> -}
> -static inline u64 dma_get_required_mask(struct device *dev)
> -{
> - return 0;
> -}
> -static inline bool dma_addressing_limited(struct device *dev)
> -{
> - return false;
> -}
> -static inline size_t dma_max_mapping_size(struct device *dev)
> -{
> - return 0;
> -}
> -static inline size_t dma_opt_mapping_size(struct device *dev)
> -{
> - return 0;
> -}
> -static inline unsigned long dma_get_merge_boundary(struct device *dev)
> -{
> - return 0;
> -}
> -static inline struct sg_table *dma_alloc_noncontiguous(struct device *dev,
> - size_t size, enum dma_data_direction dir, gfp_t gfp,
> - unsigned long attrs)
> -{
> - return NULL;
> -}
> -static inline void dma_free_noncontiguous(struct device *dev, size_t size,
> - struct sg_table *sgt, enum dma_data_direction dir)
> -{
> -}
> -static inline void *dma_vmap_noncontiguous(struct device *dev, size_t size,
> - struct sg_table *sgt)
> -{
> - return NULL;
> -}
> -static inline void dma_vunmap_noncontiguous(struct device *dev, void *vaddr)
> -{
> -}
> -static inline int dma_mmap_noncontiguous(struct device *dev,
> - struct vm_area_struct *vma, size_t size, struct sg_table *sgt)
> -{
> - return -EINVAL;
> -}
> -#endif /* CONFIG_HAS_DMA */
>
> #ifdef CONFIG_IOMMU_DMA
> /**
> diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
> index 0748091339f7..228a3566d344 100644
> --- a/kernel/dma/Kconfig
> +++ b/kernel/dma/Kconfig
> @@ -1,12 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0-only
>
> -config NO_DMA
> - bool
> -
> config HAS_DMA
> - bool
> - depends on !NO_DMA
> - default y
> + def_bool y
>
> config DMA_OPS_HELPERS
> bool
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
More information about the linux-arm-kernel
mailing list