aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-04-16 11:22:28 -0400
committerChristoph Hellwig <hch@lst.de>2018-05-08 07:02:42 -0400
commit15b28bbcd567a9199481ecfef39702b258f9baff (patch)
treedb5428916f2f231b602bad88b202ffc7540afd16 /lib
parent325ef1857fff8b2049322921e19421b6c5ad74e5 (diff)
dma-debug: move initialization to common code
Most mainstream architectures are using 65536 entries, so lets stick to that. If someone is really desperate to override it that can still be done through <asm/dma-mapping.h>, but I'd rather see a really good rationale for that. dma_debug_init is now called as a core_initcall, which for many architectures means much earlier, and provides dma-debug functionality earlier in the boot process. This should be safe as it only relies on the memory allocator already being available. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/dma-debug.c21
1 files changed, 14 insertions, 7 deletions
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{