aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mm/dma-mapping-nommu.c9
-rw-r--r--arch/arm/mm/dma-mapping.c9
-rw-r--r--arch/arm64/mm/dma-mapping.c10
-rw-r--r--arch/c6x/kernel/dma.c11
-rw-r--r--arch/ia64/kernel/dma-mapping.c10
-rw-r--r--arch/microblaze/kernel/dma.c11
-rw-r--r--arch/mips/mm/dma-default.c10
-rw-r--r--arch/openrisc/kernel/dma.c11
-rw-r--r--arch/powerpc/kernel/dma.c3
-rw-r--r--arch/s390/pci/pci_dma.c9
-rw-r--r--arch/sh/mm/consistent.c9
-rw-r--r--arch/sparc/kernel/Makefile2
-rw-r--r--arch/sparc/kernel/dma.c13
-rw-r--r--arch/x86/kernel/pci-dma.c4
-rw-r--r--arch/xtensa/kernel/pci-dma.c9
-rw-r--r--include/linux/dma-debug.h6
-rw-r--r--lib/dma-debug.c21
17 files changed, 14 insertions, 143 deletions
diff --git a/arch/arm/mm/dma-mapping-nommu.c b/arch/arm/mm/dma-mapping-nommu.c
index 619f24a42d09..f448a0663b10 100644
--- a/arch/arm/mm/dma-mapping-nommu.c
+++ b/arch/arm/mm/dma-mapping-nommu.c
@@ -241,12 +241,3 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
241void arch_teardown_dma_ops(struct device *dev) 241void arch_teardown_dma_ops(struct device *dev)
242{ 242{
243} 243}
244
245#define PREALLOC_DMA_DEBUG_ENTRIES 4096
246
247static int __init dma_debug_do_init(void)
248{
249 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
250 return 0;
251}
252core_initcall(dma_debug_do_init);
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8c398fedbbb6..c26bf83f44ca 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1165,15 +1165,6 @@ int arm_dma_supported(struct device *dev, u64 mask)
1165 return __dma_supported(dev, mask, false); 1165 return __dma_supported(dev, mask, false);
1166} 1166}
1167 1167
1168#define PREALLOC_DMA_DEBUG_ENTRIES 4096
1169
1170static int __init dma_debug_do_init(void)
1171{
1172 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
1173 return 0;
1174}
1175core_initcall(dma_debug_do_init);
1176
1177#ifdef CONFIG_ARM_DMA_USE_IOMMU 1168#ifdef CONFIG_ARM_DMA_USE_IOMMU
1178 1169
1179static int __dma_info_to_prot(enum dma_data_direction dir, unsigned long attrs) 1170static int __dma_info_to_prot(enum dma_data_direction dir, unsigned long attrs)
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index a96ec0181818..db01f2709842 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -508,16 +508,6 @@ static int __init arm64_dma_init(void)
508} 508}
509arch_initcall(arm64_dma_init); 509arch_initcall(arm64_dma_init);
510 510
511#define PREALLOC_DMA_DEBUG_ENTRIES 4096
512
513static int __init dma_debug_do_init(void)
514{
515 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
516 return 0;
517}
518fs_initcall(dma_debug_do_init);
519
520
521#ifdef CONFIG_IOMMU_DMA 511#ifdef CONFIG_IOMMU_DMA
522#include <linux/dma-iommu.h> 512#include <linux/dma-iommu.h>
523#include <linux/platform_device.h> 513#include <linux/platform_device.h>
diff --git a/arch/c6x/kernel/dma.c b/arch/c6x/kernel/dma.c
index 9fff8be75f58..31e1a9ec3a9c 100644
--- a/arch/c6x/kernel/dma.c
+++ b/arch/c6x/kernel/dma.c
@@ -136,14 +136,3 @@ const struct dma_map_ops c6x_dma_ops = {
136 .sync_sg_for_cpu = c6x_dma_sync_sg_for_cpu, 136 .sync_sg_for_cpu = c6x_dma_sync_sg_for_cpu,
137}; 137};
138EXPORT_SYMBOL(c6x_dma_ops); 138EXPORT_SYMBOL(c6x_dma_ops);
139
140/* Number of entries preallocated for DMA-API debugging */
141#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
142
143static int __init dma_init(void)
144{
145 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
146
147 return 0;
148}
149fs_initcall(dma_init);
diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c
index f2d57e66fd86..7a471d8d67d4 100644
--- a/arch/ia64/kernel/dma-mapping.c
+++ b/arch/ia64/kernel/dma-mapping.c
@@ -9,16 +9,6 @@ int iommu_detected __read_mostly;
9const struct dma_map_ops *dma_ops; 9const struct dma_map_ops *dma_ops;
10EXPORT_SYMBOL(dma_ops); 10EXPORT_SYMBOL(dma_ops);
11 11
12#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
13
14static int __init dma_init(void)
15{
16 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
17
18 return 0;
19}
20fs_initcall(dma_init);
21
22const struct dma_map_ops *dma_get_ops(struct device *dev) 12const struct dma_map_ops *dma_get_ops(struct device *dev)
23{ 13{
24 return dma_ops; 14 return dma_ops;
diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c
index c91e8cef98dd..3145e7dc8ab1 100644
--- a/arch/microblaze/kernel/dma.c
+++ b/arch/microblaze/kernel/dma.c
@@ -184,14 +184,3 @@ const struct dma_map_ops dma_nommu_ops = {
184 .sync_sg_for_device = dma_nommu_sync_sg_for_device, 184 .sync_sg_for_device = dma_nommu_sync_sg_for_device,
185}; 185};
186EXPORT_SYMBOL(dma_nommu_ops); 186EXPORT_SYMBOL(dma_nommu_ops);
187
188/* Number of entries preallocated for DMA-API debugging */
189#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
190
191static int __init dma_init(void)
192{
193 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
194
195 return 0;
196}
197fs_initcall(dma_init);
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index dcafa43613b6..f9fef0028ca2 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -402,13 +402,3 @@ static const struct dma_map_ops mips_default_dma_map_ops = {
402 402
403const struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops; 403const struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops;
404EXPORT_SYMBOL(mips_dma_map_ops); 404EXPORT_SYMBOL(mips_dma_map_ops);
405
406#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
407
408static int __init mips_dma_init(void)
409{
410 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
411
412 return 0;
413}
414fs_initcall(mips_dma_init);
diff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c
index a945f00011b4..ec7fd45704d2 100644
--- a/arch/openrisc/kernel/dma.c
+++ b/arch/openrisc/kernel/dma.c
@@ -247,14 +247,3 @@ const struct dma_map_ops or1k_dma_map_ops = {
247 .sync_single_for_device = or1k_sync_single_for_device, 247 .sync_single_for_device = or1k_sync_single_for_device,
248}; 248};
249EXPORT_SYMBOL(or1k_dma_map_ops); 249EXPORT_SYMBOL(or1k_dma_map_ops);
250
251/* Number of entries preallocated for DMA-API debugging */
252#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
253
254static int __init dma_init(void)
255{
256 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
257
258 return 0;
259}
260fs_initcall(dma_init);
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index da20569de9d4..138157deeadf 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -309,8 +309,6 @@ int dma_set_coherent_mask(struct device *dev, u64 mask)
309} 309}
310EXPORT_SYMBOL(dma_set_coherent_mask); 310EXPORT_SYMBOL(dma_set_coherent_mask);
311 311
312#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
313
314int dma_set_mask(struct device *dev, u64 dma_mask) 312int dma_set_mask(struct device *dev, u64 dma_mask)
315{ 313{
316 if (ppc_md.dma_set_mask) 314 if (ppc_md.dma_set_mask)
@@ -361,7 +359,6 @@ EXPORT_SYMBOL_GPL(dma_get_required_mask);
361 359
362static int __init dma_init(void) 360static int __init dma_init(void)
363{ 361{
364 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
365#ifdef CONFIG_PCI 362#ifdef CONFIG_PCI
366 dma_debug_add_bus(&pci_bus_type); 363 dma_debug_add_bus(&pci_bus_type);
367#endif 364#endif
diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
index 10abf5ed6187..d387a0fbdd7e 100644
--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -668,15 +668,6 @@ void zpci_dma_exit(void)
668 kmem_cache_destroy(dma_region_table_cache); 668 kmem_cache_destroy(dma_region_table_cache);
669} 669}
670 670
671#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
672
673static int __init dma_debug_do_init(void)
674{
675 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
676 return 0;
677}
678fs_initcall(dma_debug_do_init);
679
680const struct dma_map_ops s390_pci_dma_ops = { 671const struct dma_map_ops s390_pci_dma_ops = {
681 .alloc = s390_dma_alloc, 672 .alloc = s390_dma_alloc,
682 .free = s390_dma_free, 673 .free = s390_dma_free,
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 8ce98691d822..35ea3099a3b6 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -20,18 +20,9 @@
20#include <asm/cacheflush.h> 20#include <asm/cacheflush.h>
21#include <asm/addrspace.h> 21#include <asm/addrspace.h>
22 22
23#define PREALLOC_DMA_DEBUG_ENTRIES 4096
24
25const struct dma_map_ops *dma_ops; 23const struct dma_map_ops *dma_ops;
26EXPORT_SYMBOL(dma_ops); 24EXPORT_SYMBOL(dma_ops);
27 25
28static int __init dma_init(void)
29{
30 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
31 return 0;
32}
33fs_initcall(dma_init);
34
35void *dma_generic_alloc_coherent(struct device *dev, size_t size, 26void *dma_generic_alloc_coherent(struct device *dev, size_t size,
36 dma_addr_t *dma_handle, gfp_t gfp, 27 dma_addr_t *dma_handle, gfp_t gfp,
37 unsigned long attrs) 28 unsigned long attrs)
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 76cb57750dda..84cfc5a428d6 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -74,8 +74,6 @@ obj-$(CONFIG_SPARC64) += pcr.o
74obj-$(CONFIG_SPARC64) += nmi.o 74obj-$(CONFIG_SPARC64) += nmi.o
75obj-$(CONFIG_SPARC64_SMP) += cpumap.o 75obj-$(CONFIG_SPARC64_SMP) += cpumap.o
76 76
77obj-y += dma.o
78
79obj-$(CONFIG_PCIC_PCI) += pcic.o 77obj-$(CONFIG_PCIC_PCI) += pcic.o
80obj-$(CONFIG_LEON_PCI) += leon_pci.o 78obj-$(CONFIG_LEON_PCI) += leon_pci.o
81obj-$(CONFIG_SPARC_GRPCI2)+= leon_pci_grpci2.o 79obj-$(CONFIG_SPARC_GRPCI2)+= leon_pci_grpci2.o
diff --git a/arch/sparc/kernel/dma.c b/arch/sparc/kernel/dma.c
deleted file mode 100644
index f73e7597c971..000000000000
--- a/arch/sparc/kernel/dma.c
+++ /dev/null
@@ -1,13 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/kernel.h>
3#include <linux/dma-mapping.h>
4#include <linux/dma-debug.h>
5
6#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 15)
7
8static int __init dma_init(void)
9{
10 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
11 return 0;
12}
13fs_initcall(dma_init);
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 77625b60a510..bcbaa2e8031e 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -55,9 +55,6 @@ struct device x86_dma_fallback_dev = {
55}; 55};
56EXPORT_SYMBOL(x86_dma_fallback_dev); 56EXPORT_SYMBOL(x86_dma_fallback_dev);
57 57
58/* Number of entries preallocated for DMA-API debugging */
59#define PREALLOC_DMA_DEBUG_ENTRIES 65536
60
61void __init pci_iommu_alloc(void) 58void __init pci_iommu_alloc(void)
62{ 59{
63 struct iommu_table_entry *p; 60 struct iommu_table_entry *p;
@@ -189,7 +186,6 @@ EXPORT_SYMBOL(arch_dma_supported);
189static int __init pci_iommu_init(void) 186static int __init pci_iommu_init(void)
190{ 187{
191 struct iommu_table_entry *p; 188 struct iommu_table_entry *p;
192 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
193 189
194#ifdef CONFIG_PCI 190#ifdef CONFIG_PCI
195 dma_debug_add_bus(&pci_bus_type); 191 dma_debug_add_bus(&pci_bus_type);
diff --git a/arch/xtensa/kernel/pci-dma.c b/arch/xtensa/kernel/pci-dma.c
index 732631ce250f..392b4a80ebc2 100644
--- a/arch/xtensa/kernel/pci-dma.c
+++ b/arch/xtensa/kernel/pci-dma.c
@@ -261,12 +261,3 @@ const struct dma_map_ops xtensa_dma_map_ops = {
261 .mapping_error = xtensa_dma_mapping_error, 261 .mapping_error = xtensa_dma_mapping_error,
262}; 262};
263EXPORT_SYMBOL(xtensa_dma_map_ops); 263EXPORT_SYMBOL(xtensa_dma_map_ops);
264
265#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
266
267static int __init xtensa_dma_init(void)
268{
269 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
270 return 0;
271}
272fs_initcall(xtensa_dma_init);
diff --git a/include/linux/dma-debug.h b/include/linux/dma-debug.h
index c7d844f09c3a..a785f2507159 100644
--- a/include/linux/dma-debug.h
+++ b/include/linux/dma-debug.h
@@ -30,8 +30,6 @@ struct bus_type;
30 30
31extern void dma_debug_add_bus(struct bus_type *bus); 31extern void dma_debug_add_bus(struct bus_type *bus);
32 32
33extern void dma_debug_init(u32 num_entries);
34
35extern int dma_debug_resize_entries(u32 num_entries); 33extern int dma_debug_resize_entries(u32 num_entries);
36 34
37extern void debug_dma_map_page(struct device *dev, struct page *page, 35extern void debug_dma_map_page(struct device *dev, struct page *page,
@@ -100,10 +98,6 @@ static inline void dma_debug_add_bus(struct bus_type *bus)
100{ 98{
101} 99}
102 100
103static inline void dma_debug_init(u32 num_entries)
104{
105}
106
107static inline int dma_debug_resize_entries(u32 num_entries) 101static inline int dma_debug_resize_entries(u32 num_entries)
108{ 102{
109 return 0; 103 return 0;
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 7f5cdc1e6b29..712a897174e4 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -41,6 +41,11 @@
41#define HASH_FN_SHIFT 13 41#define HASH_FN_SHIFT 13
42#define HASH_FN_MASK (HASH_SIZE - 1) 42#define HASH_FN_MASK (HASH_SIZE - 1)
43 43
44/* allow architectures to override this if absolutely required */
45#ifndef PREALLOC_DMA_DEBUG_ENTRIES
46#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
47#endif
48
44enum { 49enum {
45 dma_debug_single, 50 dma_debug_single,
46 dma_debug_page, 51 dma_debug_page,
@@ -1004,18 +1009,16 @@ void dma_debug_add_bus(struct bus_type *bus)
1004 bus_register_notifier(bus, nb); 1009 bus_register_notifier(bus, nb);
1005} 1010}
1006 1011
1007/* 1012static int dma_debug_init(void)
1008 * Let the architectures decide how many entries should be preallocated.
1009 */
1010void dma_debug_init(u32 num_entries)
1011{ 1013{
1014 u32 num_entries;
1012 int i; 1015 int i;
1013 1016
1014 /* Do not use dma_debug_initialized here, since we really want to be 1017 /* Do not use dma_debug_initialized here, since we really want to be
1015 * called to set dma_debug_initialized 1018 * called to set dma_debug_initialized
1016 */ 1019 */
1017 if (global_disable) 1020 if (global_disable)
1018 return; 1021 return 0;
1019 1022
1020 for (i = 0; i < HASH_SIZE; ++i) { 1023 for (i = 0; i < HASH_SIZE; ++i) {
1021 INIT_LIST_HEAD(&dma_entry_hash[i].list); 1024 INIT_LIST_HEAD(&dma_entry_hash[i].list);
@@ -1026,17 +1029,19 @@ void dma_debug_init(u32 num_entries)
1026 pr_err("DMA-API: error creating debugfs entries - disabling\n"); 1029 pr_err("DMA-API: error creating debugfs entries - disabling\n");
1027 global_disable = true; 1030 global_disable = true;
1028 1031
1029 return; 1032 return 0;
1030 } 1033 }
1031 1034
1032 if (req_entries) 1035 if (req_entries)
1033 num_entries = req_entries; 1036 num_entries = req_entries;
1037 else
1038 num_entries = PREALLOC_DMA_DEBUG_ENTRIES;
1034 1039
1035 if (prealloc_memory(num_entries) != 0) { 1040 if (prealloc_memory(num_entries) != 0) {
1036 pr_err("DMA-API: debugging out of memory error - disabled\n"); 1041 pr_err("DMA-API: debugging out of memory error - disabled\n");
1037 global_disable = true; 1042 global_disable = true;
1038 1043
1039 return; 1044 return 0;
1040 } 1045 }
1041 1046
1042 nr_total_entries = num_free_entries; 1047 nr_total_entries = num_free_entries;
@@ -1044,7 +1049,9 @@ void dma_debug_init(u32 num_entries)
1044 dma_debug_initialized = true; 1049 dma_debug_initialized = true;
1045 1050
1046 pr_info("DMA-API: debugging enabled by kernel config\n"); 1051 pr_info("DMA-API: debugging enabled by kernel config\n");
1052 return 0;
1047} 1053}
1054core_initcall(dma_debug_init);
1048 1055
1049static __init int dma_debug_cmdline(char *str) 1056static __init int dma_debug_cmdline(char *str)
1050{ 1057{