void arch_teardown_dma_ops(struct device *dev)
 {
 }
-
-#define PREALLOC_DMA_DEBUG_ENTRIES     4096
-
-static int __init dma_debug_do_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-       return 0;
-}
-core_initcall(dma_debug_do_init);
 
        return __dma_supported(dev, mask, false);
 }
 
-#define PREALLOC_DMA_DEBUG_ENTRIES     4096
-
-static int __init dma_debug_do_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-       return 0;
-}
-core_initcall(dma_debug_do_init);
-
 #ifdef CONFIG_ARM_DMA_USE_IOMMU
 
 static int __dma_info_to_prot(enum dma_data_direction dir, unsigned long attrs)
 
 }
 arch_initcall(arm64_dma_init);
 
-#define PREALLOC_DMA_DEBUG_ENTRIES     4096
-
-static int __init dma_debug_do_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-       return 0;
-}
-fs_initcall(dma_debug_do_init);
-
-
 #ifdef CONFIG_IOMMU_DMA
 #include <linux/dma-iommu.h>
 #include <linux/platform_device.h>
 
        .sync_sg_for_cpu        = c6x_dma_sync_sg_for_cpu,
 };
 EXPORT_SYMBOL(c6x_dma_ops);
-
-/* Number of entries preallocated for DMA-API debugging */
-#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
-
-static int __init dma_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-
-       return 0;
-}
-fs_initcall(dma_init);
 
 const struct dma_map_ops *dma_ops;
 EXPORT_SYMBOL(dma_ops);
 
-#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
-
-static int __init dma_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-
-       return 0;
-}
-fs_initcall(dma_init);
-
 const struct dma_map_ops *dma_get_ops(struct device *dev)
 {
        return dma_ops;
 
        .sync_sg_for_device     = dma_nommu_sync_sg_for_device,
 };
 EXPORT_SYMBOL(dma_nommu_ops);
-
-/* Number of entries preallocated for DMA-API debugging */
-#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
-
-static int __init dma_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-
-       return 0;
-}
-fs_initcall(dma_init);
 
 
 const struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops;
 EXPORT_SYMBOL(mips_dma_map_ops);
-
-#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
-
-static int __init mips_dma_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-
-       return 0;
-}
-fs_initcall(mips_dma_init);
 
        .sync_single_for_device = or1k_sync_single_for_device,
 };
 EXPORT_SYMBOL(or1k_dma_map_ops);
-
-/* Number of entries preallocated for DMA-API debugging */
-#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
-
-static int __init dma_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-
-       return 0;
-}
-fs_initcall(dma_init);
 
 }
 EXPORT_SYMBOL(dma_set_coherent_mask);
 
-#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
-
 int dma_set_mask(struct device *dev, u64 dma_mask)
 {
        if (ppc_md.dma_set_mask)
 
 static int __init dma_init(void)
 {
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
 #ifdef CONFIG_PCI
        dma_debug_add_bus(&pci_bus_type);
 #endif
 
        kmem_cache_destroy(dma_region_table_cache);
 }
 
-#define PREALLOC_DMA_DEBUG_ENTRIES     (1 << 16)
-
-static int __init dma_debug_do_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-       return 0;
-}
-fs_initcall(dma_debug_do_init);
-
 const struct dma_map_ops s390_pci_dma_ops = {
        .alloc          = s390_dma_alloc,
        .free           = s390_dma_free,
 
 #include <asm/cacheflush.h>
 #include <asm/addrspace.h>
 
-#define PREALLOC_DMA_DEBUG_ENTRIES     4096
-
 const struct dma_map_ops *dma_ops;
 EXPORT_SYMBOL(dma_ops);
 
-static int __init dma_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-       return 0;
-}
-fs_initcall(dma_init);
-
 void *dma_generic_alloc_coherent(struct device *dev, size_t size,
                                 dma_addr_t *dma_handle, gfp_t gfp,
                                 unsigned long attrs)
 
 obj-$(CONFIG_SPARC64)  += nmi.o
 obj-$(CONFIG_SPARC64_SMP) += cpumap.o
 
-obj-y                     += dma.o
-
 obj-$(CONFIG_PCIC_PCI)    += pcic.o
 obj-$(CONFIG_LEON_PCI)    += leon_pci.o
 obj-$(CONFIG_SPARC_GRPCI2)+= leon_pci_grpci2.o
 
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0
-#include <linux/kernel.h>
-#include <linux/dma-mapping.h>
-#include <linux/dma-debug.h>
-
-#define PREALLOC_DMA_DEBUG_ENTRIES       (1 << 15)
-
-static int __init dma_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-       return 0;
-}
-fs_initcall(dma_init);
 
 };
 EXPORT_SYMBOL(x86_dma_fallback_dev);
 
-/* Number of entries preallocated for DMA-API debugging */
-#define PREALLOC_DMA_DEBUG_ENTRIES       65536
-
 void __init pci_iommu_alloc(void)
 {
        struct iommu_table_entry *p;
 static int __init pci_iommu_init(void)
 {
        struct iommu_table_entry *p;
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
 
 #ifdef CONFIG_PCI
        dma_debug_add_bus(&pci_bus_type);
 
        .mapping_error = xtensa_dma_mapping_error,
 };
 EXPORT_SYMBOL(xtensa_dma_map_ops);
-
-#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
-
-static int __init xtensa_dma_init(void)
-{
-       dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
-       return 0;
-}
-fs_initcall(xtensa_dma_init);
 
 
 extern void dma_debug_add_bus(struct bus_type *bus);
 
-extern void dma_debug_init(u32 num_entries);
-
 extern int dma_debug_resize_entries(u32 num_entries);
 
 extern void debug_dma_map_page(struct device *dev, struct page *page,
 {
 }
 
-static inline void dma_debug_init(u32 num_entries)
-{
-}
-
 static inline int dma_debug_resize_entries(u32 num_entries)
 {
        return 0;
 
 #define HASH_FN_SHIFT   13
 #define HASH_FN_MASK    (HASH_SIZE - 1)
 
+/* allow architectures to override this if absolutely required */
+#ifndef PREALLOC_DMA_DEBUG_ENTRIES
+#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
+#endif
+
 enum {
        dma_debug_single,
        dma_debug_page,
        bus_register_notifier(bus, nb);
 }
 
-/*
- * Let the architectures decide how many entries should be preallocated.
- */
-void dma_debug_init(u32 num_entries)
+static int dma_debug_init(void)
 {
+       u32 num_entries;
        int i;
 
        /* Do not use dma_debug_initialized here, since we really want to be
         * called to set dma_debug_initialized
         */
        if (global_disable)
-               return;
+               return 0;
 
        for (i = 0; i < HASH_SIZE; ++i) {
                INIT_LIST_HEAD(&dma_entry_hash[i].list);
                pr_err("DMA-API: error creating debugfs entries - disabling\n");
                global_disable = true;
 
-               return;
+               return 0;
        }
 
        if (req_entries)
                num_entries = req_entries;
+       else
+               num_entries = PREALLOC_DMA_DEBUG_ENTRIES;
 
        if (prealloc_memory(num_entries) != 0) {
                pr_err("DMA-API: debugging out of memory error - disabled\n");
                global_disable = true;
 
-               return;
+               return 0;
        }
 
        nr_total_entries = num_free_entries;
        dma_debug_initialized = true;
 
        pr_info("DMA-API: debugging enabled by kernel config\n");
+       return 0;
 }
+core_initcall(dma_debug_init);
 
 static __init int dma_debug_cmdline(char *str)
 {