Commit 8b5369ea authored by Nicolas Saenz Julienne's avatar Nicolas Saenz Julienne Committed by Catalin Marinas
Browse files

dma/direct: turn ARCH_ZONE_DMA_BITS into a variable



Some architectures, notably ARM, are interested in tweaking this
depending on their runtime DMA addressing limitations.

Acked-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 4686da51
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -38,6 +38,4 @@ extern int pfn_valid(unsigned long);

#include <asm-generic/getorder.h>

#define ARCH_ZONE_DMA_BITS 30

#endif
+7 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/sort.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
#include <linux/dma-direct.h>
#include <linux/dma-mapping.h>
#include <linux/dma-contiguous.h>
#include <linux/efi.h>
@@ -41,6 +42,8 @@
#include <asm/tlb.h>
#include <asm/alternative.h>

#define ARM64_ZONE_DMA_BITS	30

/*
 * We need to be able to catch inadvertent references to memstart_addr
 * that occur (potentially in generic code) before arm64_memblock_init()
@@ -440,8 +443,10 @@ void __init arm64_memblock_init(void)

	early_init_fdt_scan_reserved_mem();

	if (IS_ENABLED(CONFIG_ZONE_DMA))
		arm64_dma_phys_limit = max_zone_phys(ARCH_ZONE_DMA_BITS);
	if (IS_ENABLED(CONFIG_ZONE_DMA)) {
		zone_dma_bits = ARM64_ZONE_DMA_BITS;
		arm64_dma_phys_limit = max_zone_phys(ARM64_ZONE_DMA_BITS);
	}

	if (IS_ENABLED(CONFIG_ZONE_DMA32))
		arm64_dma32_phys_limit = max_zone_phys(32);
+0 −9
Original line number Diff line number Diff line
@@ -329,13 +329,4 @@ struct vm_area_struct;
#endif /* __ASSEMBLY__ */
#include <asm/slice.h>

/*
 * Allow 30-bit DMA for very limited Broadcom wifi chips on many powerbooks.
 */
#ifdef CONFIG_PPC32
#define ARCH_ZONE_DMA_BITS 30
#else
#define ARCH_ZONE_DMA_BITS 31
#endif

#endif /* _ASM_POWERPC_PAGE_H */
+15 −5
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/memremap.h>
#include <linux/dma-direct.h>

#include <asm/pgalloc.h>
#include <asm/prom.h>
@@ -201,10 +202,10 @@ static int __init mark_nonram_nosave(void)
 * everything else. GFP_DMA32 page allocations automatically fall back to
 * ZONE_DMA.
 *
 * By using 31-bit unconditionally, we can exploit ARCH_ZONE_DMA_BITS to
 * inform the generic DMA mapping code.  32-bit only devices (if not handled
 * by an IOMMU anyway) will take a first dip into ZONE_NORMAL and get
 * otherwise served by ZONE_DMA.
 * By using 31-bit unconditionally, we can exploit zone_dma_bits to inform the
 * generic DMA mapping code.  32-bit only devices (if not handled by an IOMMU
 * anyway) will take a first dip into ZONE_NORMAL and get otherwise served by
 * ZONE_DMA.
 */
static unsigned long max_zone_pfns[MAX_NR_ZONES];

@@ -237,9 +238,18 @@ void __init paging_init(void)
	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
	       (long int)((top_of_ram - total_ram) >> 20));

	/*
	 * Allow 30-bit DMA for very limited Broadcom wifi chips on many
	 * powerbooks.
	 */
	if (IS_ENABLED(CONFIG_PPC32))
		zone_dma_bits = 30;
	else
		zone_dma_bits = 31;

#ifdef CONFIG_ZONE_DMA
	max_zone_pfns[ZONE_DMA]	= min(max_low_pfn,
				      1UL << (ARCH_ZONE_DMA_BITS - PAGE_SHIFT));
				      1UL << (zone_dma_bits - PAGE_SHIFT));
#endif
	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
#ifdef CONFIG_HIGHMEM
+0 −2
Original line number Diff line number Diff line
@@ -177,8 +177,6 @@ static inline int devmem_is_allowed(unsigned long pfn)
#define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | \
				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)

#define ARCH_ZONE_DMA_BITS	31

#include <asm-generic/memory_model.h>
#include <asm-generic/getorder.h>

Loading