Skip to content

Commit 22e4a34

Browse files
Yajun DengChristoph Hellwig
authored andcommitted
dma-contiguous: support per-numa CMA for all architectures
In the commit b7176c2 ("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. Signed-off-by: Yajun Deng <yajun.deng@linux.dev> Tested-by: Yicong Yang <yangyicong@hisilicon.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 3d6f126 commit 22e4a34

5 files changed

Lines changed: 11 additions & 13 deletions

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@
696696
kernel/dma/contiguous.c
697697

698698
cma_pernuma=nn[MG]
699-
[ARM64,KNL,CMA]
699+
[KNL,CMA]
700700
Sets the size of kernel per-numa memory area for
701701
contiguous memory allocations. A value of 0 disables
702702
per-numa CMA altogether. And If this option is not

arch/arm64/mm/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ void __init bootmem_init(void)
434434
arm64_hugetlb_cma_reserve();
435435
#endif
436436

437-
dma_pernuma_cma_reserve();
438-
439437
kvm_hyp_reserve();
440438

441439
/*

include/linux/dma-map-ops.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ static inline void dma_free_contiguous(struct device *dev, struct page *page,
169169
}
170170
#endif /* CONFIG_DMA_CMA*/
171171

172-
#ifdef CONFIG_DMA_PERNUMA_CMA
173-
void dma_pernuma_cma_reserve(void);
174-
#else
175-
static inline void dma_pernuma_cma_reserve(void) { }
176-
#endif /* CONFIG_DMA_PERNUMA_CMA */
177-
178172
#ifdef CONFIG_DMA_DECLARE_COHERENT
179173
int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
180174
dma_addr_t device_addr, size_t size);

kernel/dma/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ if DMA_CMA
147147

148148
config DMA_PERNUMA_CMA
149149
bool "Enable separate DMA Contiguous Memory Area for each NUMA Node"
150-
default NUMA && ARM64
150+
default NUMA
151151
help
152-
Enable this option to get pernuma CMA areas so that devices like
153-
ARM64 SMMU can get local memory by DMA coherent APIs.
152+
Enable this option to get pernuma CMA areas so that NUMA devices
153+
can get local memory by DMA coherent APIs.
154154

155155
You can set the size of pernuma CMA by specifying "cma_pernuma=size"
156156
on the kernel's command line.

kernel/dma/contiguous.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static inline __maybe_unused phys_addr_t cma_early_percent_memory(void)
128128
#endif
129129

130130
#ifdef CONFIG_DMA_PERNUMA_CMA
131-
void __init dma_pernuma_cma_reserve(void)
131+
static void __init dma_pernuma_cma_reserve(void)
132132
{
133133
int nid;
134134

@@ -153,6 +153,10 @@ void __init dma_pernuma_cma_reserve(void)
153153
(unsigned long long)pernuma_size_bytes / SZ_1M, nid);
154154
}
155155
}
156+
#else
157+
static inline void __init dma_pernuma_cma_reserve(void)
158+
{
159+
}
156160
#endif
157161

158162
/**
@@ -171,6 +175,8 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
171175
phys_addr_t selected_limit = limit;
172176
bool fixed = false;
173177

178+
dma_pernuma_cma_reserve();
179+
174180
pr_debug("%s(limit %08lx)\n", __func__, (unsigned long)limit);
175181

176182
if (size_cmdline != -1) {

0 commit comments

Comments
 (0)