Re: [PATCH] dma-contiguous: support per-numa CMA for all architectures

From: Andrew Morton
Date: Fri May 12 2023 - 17:12:31 EST


On Fri, 12 May 2023 17:42:10 +0800 Yajun Deng <yajun.deng@xxxxxxxxx> wrote:

> In the commit b7176c261cdb ("dma-contiguous: provide the ability to
> reserve per-numa CMA"), Barry adds DMA_PERNUMA_CMA for ARM64.
>
> But this feature is architecture independent, so support per-numa CMA
> for all architectures, and enable it by default if NUMA.
>
> ...
>
> --- a/include/linux/dma-map-ops.h
> +++ b/include/linux/dma-map-ops.h
> @@ -168,12 +168,6 @@ static inline void dma_free_contiguous(struct device *dev, struct page *page,
> }
> #endif /* CONFIG_DMA_CMA*/
>
> -#ifdef CONFIG_DMA_PERNUMA_CMA
> -void dma_pernuma_cma_reserve(void);
> -#else
> -static inline void dma_pernuma_cma_reserve(void) { }

It would be a little nicer to retain this line.

> -#endif /* CONFIG_DMA_PERNUMA_CMA */
> -
> #ifdef CONFIG_DMA_DECLARE_COHERENT
> int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
> dma_addr_t device_addr, size_t size);
>
> ...
>
> --- a/kernel/dma/contiguous.c
> +++ b/kernel/dma/contiguous.c
> @@ -128,7 +128,7 @@ static inline __maybe_unused phys_addr_t cma_early_percent_memory(void)
> #endif
>
> #ifdef CONFIG_DMA_PERNUMA_CMA
> -void __init dma_pernuma_cma_reserve(void)
> +static void __init dma_pernuma_cma_reserve(void)
> {
> int nid;
>
> @@ -153,6 +153,10 @@ void __init dma_pernuma_cma_reserve(void)
> (unsigned long long)pernuma_size_bytes / SZ_1M, nid);
> }
> }
> +#else
> +static inline void __init dma_pernuma_cma_reserve(void)
> +{
> +}
> #endif

And to not add this function?