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

Andrew Morton akpm at linux-foundation.org
Fri May 12 14:08:59 PDT 2023


On Fri, 12 May 2023 17:42:10 +0800 Yajun Deng <yajun.deng at linux.dev> 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?



More information about the linux-arm-kernel mailing list