Consolidate zone adjustment
Subsystems (5)
cover Consolidate zone adjustment
This patch mini-series consolidates the adjustment to system zones which some of our platforms require. Rather than having each platform/machine class specify ISA_DMA_THRESHOLD, MAX_DMA_ADDRESS and an arch_adjust_zones function, they really only need to provide a single sizing definition, which in this series will be called ARM_DMA_ZONE_SIZE.
arch/arm/common/sa1111.c | 8 ------- arch/arm/include/asm/dma.h | 4 ++- arch/arm/include/asm/memory.h | 10 ++------ arch/arm/mach-davinci/include/mach/memory.h | 18 +---------------- arch/arm/mach-h720x/include/mach/memory.h | 3 +- arch/arm/mach-ixp4xx/common-pci.c | 23 ---------------------- arch/arm/mach-ixp4xx/include/mach/memory.h | 12 +--------- arch/arm/mach-pxa/cm-x2xx-pci.c | 27 -------------------------- arch/arm/mach-pxa/include/mach/memory.h | 10 +------- arch/arm/mach-realview/core.c | 19 ------------------ arch/arm/mach-realview/include/mach/memory.h | 9 +------ arch/arm/mach-sa1100/include/mach/memory.h | 12 +---------- arch/arm/mach-shark/include/mach/memory.h | 20 +------------------ arch/arm/mm/init.c | 23 +++++++++++++++++++++- 14 files changed, 38 insertions(+), 160 deletions(-)
PATCH 1/2 ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS
The values of ISA_DMA_THRESHOLD and MAX_DMA_ADDRESS are related; one is the physical/bus address, the other is the virtual address. Both need to be kept in step, so rather than having platforms define both, allow them to define a single macro which sets both of these macros appropraitely.
--- arch/arm/include/asm/dma.h | 4 +++- arch/arm/include/asm/memory.h | 4 +++- arch/arm/mach-davinci/include/mach/memory.h | 3 +-- arch/arm/mach-h720x/include/mach/memory.h | 3 +-- arch/arm/mach-ixp4xx/include/mach/memory.h | 3 +-- arch/arm/mach-pxa/include/mach/memory.h | 3 +-- arch/arm/mach-realview/include/mach/memory.h | 3 +-- arch/arm/mach-sa1100/include/mach/memory.h | 3 +-- arch/arm/mach-shark/include/mach/memory.h | 3 +-- 9 files changed, 13 insertions(+), 16 deletions(-)
arch/arm/include/asm/dma.h +3 -1
@@ -6,8 +6,10 @@/* * This is the maximum virtual address which can be DMA'd from. */ -#ifndef MAX_DMA_ADDRESS +#ifndef ARM_DMA_ZONE_SIZE #define MAX_DMA_ADDRESS 0xffffffff +#else +#define MAX_DMA_ADDRESS (PAGE_OFFSET + ARM_DMA_ZONE_SIZE)#endif #ifdef CONFIG_ISA_DMA_API
arch/arm/include/asm/memory.h +3 -1
@@ -209,8 +209,10 @@ static inline unsigned long __phys_to_virt(unsigned long x)* allocations. This must be the smallest DMA mask in the system, * so a successful GFP_DMA allocation will always satisfy this. */ -#ifndef ISA_DMA_THRESHOLD +#ifndef ARM_DMA_ZONE_SIZE #define ISA_DMA_THRESHOLD (0xffffffffULL) +#else +#define ISA_DMA_THRESHOLD (PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)#endif #ifndef arch_adjust_zones
arch/arm/mach-davinci/include/mach/memory.h +1 -2
@@ -59,8 +59,7 @@ __arch_adjust_zones(unsigned long *size, unsigned long *holes)#define arch_adjust_zones (zone_size, holes) \ if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + (128<<20) - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + (128<<20)) +#define ARM_DMA_ZONE_SIZE SZ_128M#endif
arch/arm/mach-h720x/include/mach/memory.h +1 -2
@@ -13,7 +13,6 @@* There should not be more than (0xd0000000 - 0xc0000000) * bytes of RAM. */ -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_256M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_256M) +#define ARM_DMA_ZONE_SIZE SZ_256M#endif
arch/arm/mach-ixp4xx/include/mach/memory.h +1 -2
@@ -21,8 +21,7 @@ void ixp4xx_adjust_zones(unsigned long *size, unsigned long *holes);#define arch_adjust_zones (size, holes) \ ixp4xx_adjust_zones(size, holes) -#define ISA_DMA_THRESHOLD (SZ_64M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_64M) +#define ARM_DMA_ZONE_SIZE SZ_64M#endif
arch/arm/mach-pxa/include/mach/memory.h +1 -2
@@ -23,8 +23,7 @@ void cmx2xx_pci_adjust_zones(unsigned long *size, unsigned long *holes);#define arch_adjust_zones (size, holes) \ cmx2xx_pci_adjust_zones(size, holes) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_64M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_64M) +#define ARM_DMA_ZONE_SIZE SZ_64M#endif #endif
arch/arm/mach-realview/include/mach/memory.h +1 -2
@@ -34,8 +34,7 @@ extern void realview_adjust_zones(unsigned long *size, unsigned long *hole);#define arch_adjust_zones (size, hole) \ realview_adjust_zones(size, hole) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_256M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_256M) +#define ARM_DMA_ZONE_SIZE SZ_256M#endif #ifdef CONFIG_SPARSEMEM
arch/arm/mach-sa1100/include/mach/memory.h +1 -2
@@ -22,8 +22,7 @@ void sa1111_adjust_zones(unsigned long *size, unsigned long *holes);#define arch_adjust_zones (size, holes) \ sa1111_adjust_zones(size, holes) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_1M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_1M) +#define ARM_DMA_ZONE_SIZE SZ_1M#endif #endif
arch/arm/mach-shark/include/mach/memory.h +1 -2
@@ -32,8 +32,7 @@ static inline void __arch_adjust_zones(unsigned long *zone_size, unsigned long *#define arch_adjust_zones (size, holes) \ __arch_adjust_zones(size, holes) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_4M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_4M) +#define ARM_DMA_ZONE_SIZE SZ_4M#endif
Signature · 1 line
1.7.4.4
PATCH 2/2 ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes
In reply to Russell King - ARM LinuxRather than each platform providing its own function to adjust the zone sizes, use the new ARM_DMA_ZONE_SIZE definition to perform this adjustment. This ensures that the actual DMA zone size and the ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS definitions are consistent with each other, and moves this complexity out of the platform code.
--- arch/arm/common/sa1111.c | 8 ------- arch/arm/include/asm/memory.h | 6 ----- arch/arm/mach-davinci/include/mach/memory.h | 15 -------------- arch/arm/mach-ixp4xx/common-pci.c | 23 ---------------------- arch/arm/mach-ixp4xx/include/mach/memory.h | 9 +------- arch/arm/mach-pxa/cm-x2xx-pci.c | 27 -------------------------- arch/arm/mach-pxa/include/mach/memory.h | 7 +----- arch/arm/mach-realview/core.c | 19 ------------------ arch/arm/mach-realview/include/mach/memory.h | 6 +---- arch/arm/mach-sa1100/include/mach/memory.h | 9 -------- arch/arm/mach-shark/include/mach/memory.h | 17 ---------------- arch/arm/mm/init.c | 23 +++++++++++++++++++++- 12 files changed, 25 insertions(+), 144 deletions(-)
arch/arm/common/sa1111.c +0 -8
@@ -185,14 +185,6 @@ static struct sa1111_dev_info sa1111_devices[] = { }, }; -void __init sa1111_adjust_zones (unsigned long *size,unsigned long *holes) -{ -unsigned int sz =SZ_1M >>PAGE_SHIFT ; - - size[1 ] = size[0 ] - sz; - size[0 ] = sz; -} -/* * SA1111 interrupt support. Since clearing an IRQ while there are * active IRQs causes the interrupt output to pulse, the upper levels
arch/arm/include/asm/memory.h +0 -6
@@ -215,12 +215,6 @@ static inline unsigned long __phys_to_virt(unsigned long x)#define ISA_DMA_THRESHOLD (PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)#endif -#ifndef arch_adjust_zones -#define arch_adjust_zones (size,holes) do { } while (0) -#elif !defined(CONFIG_ZONE_DMA ) -#error "custom arch_adjust_zones() requires CONFIG_ZONE_DMA" -#endif -/* * PFNs are used to describe any physical page; this means * PFN 0 == physical address 0.
arch/arm/mach-davinci/include/mach/memory.h +0 -15
@@ -41,26 +41,11 @@*/ #define CONSISTENT_DMA_SIZE (14<<20) -#ifndef __ASSEMBLY__/* * Restrict DMA-able region to workaround silicon bug. The bug * restricts buffers available for DMA to video hardware to be * below 128M */ -static inline void -__arch_adjust_zones (unsigned long *size,unsigned long *holes) -{ -unsigned int sz = (128 <<20 ) >>PAGE_SHIFT ; - - size[1 ] = size[0 ] - sz; - size[0 ] = sz; -} - -#define arch_adjust_zones (zone_size, holes) \ - if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes) -#define ARM_DMA_ZONE_SIZE SZ_128M -#endif -#endif /* __ASM_ARCH_MEMORY_H */
arch/arm/mach-ixp4xx/common-pci.c +0 -23
@@ -342,29 +342,6 @@ int dma_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size)return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >=SZ_64M ); } -/* -* Only first 64MB of memory can be accessed via PCI. -* We use GFP_DMA to allocate safe buffers to do map/unmap. -* This is really ugly and we need a better way of specifying -* DMA-capable regions of memory. -*/ -void __init ixp4xx_adjust_zones (unsigned long *zone_size, -unsigned long *zhole_size) -{ -unsigned int sz =SZ_64M >>PAGE_SHIFT ; - -/* -* Only adjust if > 64M on current system -*/ -if (zone_size[0 ] <= sz) -return ; - - zone_size[1 ] = zone_size[0 ] - sz; - zone_size[0 ] = sz; - zhole_size[1 ] = zhole_size[0 ]; - zhole_size[0 ] =0 ; -} -void __init ixp4xx_pci_preinit (void ) {unsigned long cpuid =read_cpuid_id ();
arch/arm/mach-ixp4xx/include/mach/memory.h +1 -8
@@ -14,15 +14,8 @@*/ #define PLAT_PHYS_OFFSET UL(0x00000000) -#if !defined(__ASSEMBLY__) && defined(CONFIG_PCI ) - -void ixp4xx_adjust_zones (unsigned long *size,unsigned long *holes); - -#define arch_adjust_zones (size, holes) \ - ixp4xx_adjust_zones(size, holes) - +#ifdef CONFIG_PCI #define ARM_DMA_ZONE_SIZE SZ_64M -#endif #endif
arch/arm/mach-pxa/cm-x2xx-pci.c +0 -27
@@ -29,33 +29,6 @@unsigned long it8152_base_address;static int cmx2xx_it8152_irq_gpio; -/* -* Only first 64MB of memory can be accessed via PCI. -* We use GFP_DMA to allocate safe buffers to do map/unmap. -* This is really ugly and we need a better way of specifying -* DMA-capable regions of memory. -*/ -void __init cmx2xx_pci_adjust_zones (unsigned long *zone_size, -unsigned long *zhole_size) -{ -unsigned int sz =SZ_64M >>PAGE_SHIFT ; - -if (machine_is_armcore ()) { -pr_info ("Adjusting zones for CM-X2XX\n" ); - -/* -* Only adjust if > 64M on current system -*/ -if (zone_size[0 ] <= sz) -return ; - - zone_size[1 ] = zone_size[0 ] - sz; - zone_size[0 ] = sz; - zhole_size[1 ] = zhole_size[0 ]; - zhole_size[0 ] =0 ; - } -} -static void cmx2xx_it8152_irq_demux (unsigned int irq,struct irq_desc *desc) {/* clear our parent irq */
arch/arm/mach-pxa/include/mach/memory.h +1 -6
@@ -17,12 +17,7 @@*/ #define PLAT_PHYS_OFFSET UL(0xa0000000) -#if !defined(__ASSEMBLY__) && defined(CONFIG_MACH_ARMCORE ) && defined(CONFIG_PCI ) -void cmx2xx_pci_adjust_zones (unsigned long *size,unsigned long *holes); - -#define arch_adjust_zones (size, holes) \ - cmx2xx_pci_adjust_zones(size, holes) - +#if defined(CONFIG_MACH_ARMCORE ) && defined(CONFIG_PCI )#define ARM_DMA_ZONE_SIZE SZ_64M#endif
arch/arm/mach-realview/core.c +0 -19
@@ -56,25 +56,6 @@#include "core.h" -#ifdef CONFIG_ZONE_DMA -/* -* Adjust the zones if there are restrictions for DMA access. -*/ -void __init realview_adjust_zones (unsigned long *size,unsigned long *hole) -{ -unsigned long dma_size =SZ_256M >>PAGE_SHIFT ; - -if (!machine_is_realview_pbx () || size[0 ] <= dma_size) -return ; - - size[ZONE_NORMAL ] = size[0 ] - dma_size; - size[ZONE_DMA ] = dma_size; - hole[ZONE_NORMAL ] = hole[0 ]; - hole[ZONE_DMA ] =0 ; -} -#endif - -#define REALVIEW_FLASHCTRL (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)static int realview_flash_init (void )
arch/arm/mach-realview/include/mach/memory.h +1 -5
@@ -29,11 +29,7 @@#define PLAT_PHYS_OFFSET UL(0x00000000)#endif -#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA ) -extern void realview_adjust_zones (unsigned long *size,unsigned long *hole); -#define arch_adjust_zones (size, hole) \ - realview_adjust_zones(size, hole) - +#ifdef CONFIG_ZONE_DMA #define ARM_DMA_ZONE_SIZE SZ_256M#endif
arch/arm/mach-sa1100/include/mach/memory.h +0 -9
@@ -14,17 +14,8 @@*/ #define PLAT_PHYS_OFFSET UL(0xc0000000) -#ifndef __ASSEMBLY__ -#ifdef CONFIG_SA1111 -void sa1111_adjust_zones (unsigned long *size,unsigned long *holes); - -#define arch_adjust_zones (size, holes) \ - sa1111_adjust_zones(size, holes) -#define ARM_DMA_ZONE_SIZE SZ_1M - -#endif #endif /*
arch/arm/mach-shark/include/mach/memory.h +0 -17
@@ -17,25 +17,8 @@*/ #define PLAT_PHYS_OFFSET UL(0x08000000) -#ifndef __ASSEMBLY__ - -static inline void __arch_adjust_zones (unsigned long *zone_size,unsigned long *zhole_size) -{ -/* Only the first 4 MB (=1024 Pages) are usable for DMA */ -/* See dev / -> .properties in OpenFirmware. */ - zone_size[1 ] = zone_size[0 ] -1024 ; - zone_size[0 ] =1024 ; - zhole_size[1 ] = zhole_size[0 ]; - zhole_size[0 ] =0 ; -} - -#define arch_adjust_zones (size, holes) \ - __arch_adjust_zones(size, holes) -#define ARM_DMA_ZONE_SIZE SZ_4M -#endif -/* * Cache flushing area */
arch/arm/mm/init.c +22 -1
@@ -201,6 +201,20 @@ static void __init arm_bootmem_init(unsigned long start_pfn, } } +#ifdef CONFIG_ZONE_DMA +static void __init arm_adjust_dma_zone (unsigned long *size,unsigned long *hole, +unsigned long dma_size) +{ +if (size[0 ] <= dma_size) +return ; + + size[ZONE_NORMAL ] = size[0 ] - dma_size; + size[ZONE_DMA ] = dma_size; + hole[ZONE_NORMAL ] = hole[0 ]; + hole[ZONE_DMA ] =0 ; +} +#endif +static void __init arm_bootmem_free (unsigned long min,unsigned long max_low,unsigned long max_high) {
@@ -243,11 +257,18 @@ static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,#endif } +#ifdef ARM_DMA_ZONE_SIZE +#ifndef CONFIG_ZONE_DMA +#error ARM_DMA_ZONE_SIZE set but no DMA zone to limit allocations +#endif +/* * Adjust the sizes according to any special requirements for * this machine type. */ -arch_adjust_zones (zone_size, zhole_size); +arm_adjust_dma_zone (zone_size, zhole_size, +ARM_DMA_ZONE_SIZE >>PAGE_SHIFT ); +#endif free_area_init_node (0 , zone_size, min, zhole_size); }
Signature · 1 line
1.7.4.4
PATCH 2/2 ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes
Quoted 5 lines · Russell King - ARM Linux
Rather than each platform providing its own function to adjust the zone sizes, use the new
ARM_DMA_ZONE_SIZEdefinition to perform this adjustment. This ensures that the actual DMA zone size and the ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS definitions are consistent with each other, and moves this complexity out of the platform code.
...
Quoted 6 lines
arch/arm/mach-realview/include/mach/memory.h +0
-0@@ -29,11 +29,7 @@#define PLAT_PHYS_OFFSET UL(0x00000000)
arch/arm/mach-realview/include/mach/memory.h line 34
Quoted 10 lines
arch/arm/mach-realview/include/mach/memory.h +1
-5#endif -#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA ) -extern void realview_adjust_zones (unsigned long *size,unsigned long *hole); -#define arch_adjust_zones (size, hole) \ - realview_adjust_zones(size, hole) - +#ifdef CONFIG_ZONE_DMA #define ARM_DMA_ZONE_SIZE SZ_256M#endif
We only use ZONE_DMA for PBX and realview_adjust_zones() does this check. We end up with limiting the DMA zone to 256MB on all RealView platforms if we compile a single kernel image that includes PBX. Not a big problem though:
PATCH 1/2 ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS
In reply to Russell King - ARM LinuxQuoted 7 lines · Russell King - ARM Linux
The values of
ISA_DMA_THRESHOLDandMAX_DMA_ADDRESSare related; one is the physical/bus address, the other is the virtual address. Both need to be kept in step, so rather than having platforms define both, allow them to define a single macro which sets both of these macros appropraitely.Signed-off-by Russell King <[email protected]>
PATCH 2/2 ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes
In reply to Catalin MarinasQuoted 15 lines · Catalin Marinas
Quoted 5 lines · Russell King - ARM Linux
Rather than each platform providing its own function to adjust the zone sizes, use the new
ARM_DMA_ZONE_SIZEdefinition to perform this adjustment. This ensures that the actual DMA zone size and the ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS definitions are consistent with each other, and moves this complexity out of the platform code....
Quoted 8 lines
arch/arm/mach-realview/include/mach/memory.h +0
-0@@ -29,11 +29,7 @@#define PLAT_PHYS_OFFSET UL(0x00000000)#endif
Quoted 13 lines
arch/arm/mach-realview/include/mach/memory.h line 34
Quoted 8 lines
arch/arm/mach-realview/include/mach/memory.h +1
-5-#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA ) -extern void realview_adjust_zones (unsigned long *size,unsigned long *hole); -#define arch_adjust_zones (size, hole) \ - realview_adjust_zones(size, hole) - +#ifdef CONFIG_ZONE_DMA #define ARM_DMA_ZONE_SIZE SZ_256M#endif We only use
ZONE_DMAfor PBX andrealview_adjust_zones()does this check. We end up with limiting the DMA zone to 256MB on all RealView platforms if we compile a single kernel image that includes PBX. Not a big problem though:
You've already implicitly limited it by the ISA_DMA_THRESHOLD/ MAX_DMA_ADDRESS definition - what's left is an inconsistent relative size of those definitions and the actual DMA zone. That inconsistency can cause the DMA allocator to fail unexpectedly as it assumes that GFP_DMA will return a page which will satisfy ISA_DMA_THRESHOLD.
Quoted 1 line
Acked-by Catalin Marinas <[email protected]>
Thanks.
PATCH 1/2 ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS
In reply to Russell King - ARM LinuxQuoted 7 lines · Russell King - ARM Linux
The values of
ISA_DMA_THRESHOLDandMAX_DMA_ADDRESSare related; one is the physical/bus address, the other is the virtual address. Both need to be kept in step, so rather than having platforms define both, allow them to define a single macro which sets both of these macros appropraitely.Signed-off-by Russell King <[email protected]>
Quoted 144 lines
--- arch/arm/include/asm/dma.h | 4 +++- arch/arm/include/asm/memory.h | 4 +++- arch/arm/mach-davinci/include/mach/memory.h | 3 +-- arch/arm/mach-h720x/include/mach/memory.h | 3 +-- arch/arm/mach-ixp4xx/include/mach/memory.h | 3 +-- arch/arm/mach-pxa/include/mach/memory.h | 3 +-- arch/arm/mach-realview/include/mach/memory.h | 3 +-- arch/arm/mach-sa1100/include/mach/memory.h | 3 +-- arch/arm/mach-shark/include/mach/memory.h | 3 +-- 9 files changed, 13 insertions(+), 16 deletions(-)arch/arm/include/asm/dma.h +3
-1@@ -6,8 +6,10 @@/* * This is the maximum virtual address which can be DMA'd from. */ -#ifndef MAX_DMA_ADDRESS +#ifndef ARM_DMA_ZONE_SIZE #define MAX_DMA_ADDRESS 0xffffffff +#else +#define MAX_DMA_ADDRESS (PAGE_OFFSET + ARM_DMA_ZONE_SIZE)#endif #ifdef CONFIG_ISA_DMA_API arch/arm/include/asm/memory.h +3
-1@@ -209,8 +209,10 @@ static inline unsigned long __phys_to_virt(unsigned long x)* allocations. This must be the smallest DMA mask in the system, * so a successful GFP_DMA allocation will always satisfy this. */ -#ifndef ISA_DMA_THRESHOLD +#ifndef ARM_DMA_ZONE_SIZE #define ISA_DMA_THRESHOLD (0xffffffffULL) +#else +#define ISA_DMA_THRESHOLD (PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)#endif #ifndef arch_adjust_zonesarch/arm/mach-davinci/include/mach/memory.h +1
-2@@ -59,8 +59,7 @@ __arch_adjust_zones(unsigned long *size, unsigned long *holes)#define arch_adjust_zones (zone_size, holes) \ if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + (128<<20) - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + (128<<20)) +#define ARM_DMA_ZONE_SIZE SZ_128M#endif arch/arm/mach-h720x/include/mach/memory.h +1
-2@@ -13,7 +13,6 @@* There should not be more than (0xd0000000 - 0xc0000000) * bytes of RAM. */ -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_256M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_256M) +#define ARM_DMA_ZONE_SIZE SZ_256M#endif arch/arm/mach-ixp4xx/include/mach/memory.h +1
-2@@ -21,8 +21,7 @@ void ixp4xx_adjust_zones(unsigned long *size, unsigned long *holes);#define arch_adjust_zones (size, holes) \ ixp4xx_adjust_zones(size, holes) -#define ISA_DMA_THRESHOLD (SZ_64M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_64M) +#define ARM_DMA_ZONE_SIZE SZ_64M#endif arch/arm/mach-pxa/include/mach/memory.h +1
-2@@ -23,8 +23,7 @@ void cmx2xx_pci_adjust_zones(unsigned long *size, unsigned long *holes);#define arch_adjust_zones (size, holes) \ cmx2xx_pci_adjust_zones(size, holes) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_64M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_64M) +#define ARM_DMA_ZONE_SIZE SZ_64M#endif #endif arch/arm/mach-realview/include/mach/memory.h +1
-2@@ -34,8 +34,7 @@ extern void realview_adjust_zones(unsigned long *size, unsigned long *hole);#define arch_adjust_zones (size, hole) \ realview_adjust_zones(size, hole) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_256M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_256M) +#define ARM_DMA_ZONE_SIZE SZ_256M#endif #ifdef CONFIG_SPARSEMEM arch/arm/mach-sa1100/include/mach/memory.h +1
-2@@ -22,8 +22,7 @@ void sa1111_adjust_zones(unsigned long *size, unsigned long *holes);#define arch_adjust_zones (size, holes) \ sa1111_adjust_zones(size, holes) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_1M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_1M) +#define ARM_DMA_ZONE_SIZE SZ_1M#endif #endif arch/arm/mach-shark/include/mach/memory.h +1
-2@@ -32,8 +32,7 @@ static inline void __arch_adjust_zones(unsigned long *zone_size, unsigned long *#define arch_adjust_zones (size, holes) \ __arch_adjust_zones(size, holes) -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_4M - 1) -#define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_4M) +#define ARM_DMA_ZONE_SIZE SZ_4M#endif Signature · 1 line
1.7.4.4
PATCH 2/2 ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes
In reply to Russell King - ARM LinuxQuoted 7 lines · Russell King - ARM Linux
Rather than each platform providing its own function to adjust the zone sizes, use the new
ARM_DMA_ZONE_SIZEdefinition to perform this adjustment. This ensures that the actual DMA zone size and the ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS definitions are consistent with each other, and moves this complexity out of the platform code.Signed-off-by Russell King <[email protected]>
Quoted 340 lines
--- arch/arm/common/sa1111.c | 8 ------- arch/arm/include/asm/memory.h | 6 ----- arch/arm/mach-davinci/include/mach/memory.h | 15 -------------- arch/arm/mach-ixp4xx/common-pci.c | 23 ---------------------- arch/arm/mach-ixp4xx/include/mach/memory.h | 9 +------- arch/arm/mach-pxa/cm-x2xx-pci.c | 27 -------------------------- arch/arm/mach-pxa/include/mach/memory.h | 7 +----- arch/arm/mach-realview/core.c | 19 ------------------ arch/arm/mach-realview/include/mach/memory.h | 6 +---- arch/arm/mach-sa1100/include/mach/memory.h | 9 -------- arch/arm/mach-shark/include/mach/memory.h | 17 ---------------- arch/arm/mm/init.c | 23 +++++++++++++++++++++- 12 files changed, 25 insertions(+), 144 deletions(-)arch/arm/common/sa1111.c +0
-8@@ -185,14 +185,6 @@ static struct sa1111_dev_info sa1111_devices[] = { }, }; -void __init sa1111_adjust_zones (unsigned long *size,unsigned long *holes) -{ -unsigned int sz =SZ_1M >>PAGE_SHIFT ; - - size[1 ] = size[0 ] - sz; - size[0 ] = sz; -} -/* * SA1111 interrupt support. Since clearing an IRQ while there are * active IRQs causes the interrupt output to pulse, the upper levels arch/arm/include/asm/memory.h +0
-6@@ -215,12 +215,6 @@ static inline unsigned long __phys_to_virt(unsigned long x)#define ISA_DMA_THRESHOLD (PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)#endif -#ifndef arch_adjust_zones -#define arch_adjust_zones (size,holes) do { } while (0) -#elif !defined(CONFIG_ZONE_DMA ) -#error "custom arch_adjust_zones() requires CONFIG_ZONE_DMA" -#endif -/* * PFNs are used to describe any physical page; this means * PFN 0 == physical address 0. arch/arm/mach-davinci/include/mach/memory.h +0
-15@@ -41,26 +41,11 @@*/ #define CONSISTENT_DMA_SIZE (14<<20) -#ifndef __ASSEMBLY__/* * Restrict DMA-able region to workaround silicon bug. The bug * restricts buffers available for DMA to video hardware to be * below 128M */ -static inline void -__arch_adjust_zones (unsigned long *size,unsigned long *holes) -{ -unsigned int sz = (128 <<20 ) >>PAGE_SHIFT ; - - size[1 ] = size[0 ] - sz; - size[0 ] = sz; -} - -#define arch_adjust_zones (zone_size, holes) \ - if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes) -#define ARM_DMA_ZONE_SIZE SZ_128M -#endif -#endif /* __ASM_ARCH_MEMORY_H */ arch/arm/mach-ixp4xx/common-pci.c +0
-23@@ -342,29 +342,6 @@ int dma_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size)return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >=SZ_64M ); } -/* -* Only first 64MB of memory can be accessed via PCI. -* We use GFP_DMA to allocate safe buffers to do map/unmap. -* This is really ugly and we need a better way of specifying -* DMA-capable regions of memory. -*/ -void __init ixp4xx_adjust_zones (unsigned long *zone_size, -unsigned long *zhole_size) -{ -unsigned int sz =SZ_64M >>PAGE_SHIFT ; - -/* -* Only adjust if > 64M on current system -*/ -if (zone_size[0 ] <= sz) -return ; - - zone_size[1 ] = zone_size[0 ] - sz; - zone_size[0 ] = sz; - zhole_size[1 ] = zhole_size[0 ]; - zhole_size[0 ] =0 ; -} -void __init ixp4xx_pci_preinit (void ) {unsigned long cpuid =read_cpuid_id ();arch/arm/mach-ixp4xx/include/mach/memory.h +1
-8@@ -14,15 +14,8 @@*/ #define PLAT_PHYS_OFFSET UL(0x00000000) -#if !defined(__ASSEMBLY__) && defined(CONFIG_PCI ) - -void ixp4xx_adjust_zones (unsigned long *size,unsigned long *holes); - -#define arch_adjust_zones (size, holes) \ - ixp4xx_adjust_zones(size, holes) - +#ifdef CONFIG_PCI #define ARM_DMA_ZONE_SIZE SZ_64M -#endif #endif arch/arm/mach-pxa/cm-x2xx-pci.c +0
-27@@ -29,33 +29,6 @@unsigned long it8152_base_address;static int cmx2xx_it8152_irq_gpio; -/* -* Only first 64MB of memory can be accessed via PCI. -* We use GFP_DMA to allocate safe buffers to do map/unmap. -* This is really ugly and we need a better way of specifying -* DMA-capable regions of memory. -*/ -void __init cmx2xx_pci_adjust_zones (unsigned long *zone_size, -unsigned long *zhole_size) -{ -unsigned int sz =SZ_64M >>PAGE_SHIFT ; - -if (machine_is_armcore ()) { -pr_info ("Adjusting zones for CM-X2XX\n" ); - -/* -* Only adjust if > 64M on current system -*/ -if (zone_size[0 ] <= sz) -return ; - - zone_size[1 ] = zone_size[0 ] - sz; - zone_size[0 ] = sz; - zhole_size[1 ] = zhole_size[0 ]; - zhole_size[0 ] =0 ; - } -} -static void cmx2xx_it8152_irq_demux (unsigned int irq,struct irq_desc *desc) {/* clear our parent irq */ arch/arm/mach-pxa/include/mach/memory.h +1
-6@@ -17,12 +17,7 @@*/ #define PLAT_PHYS_OFFSET UL(0xa0000000) -#if !defined(__ASSEMBLY__) && defined(CONFIG_MACH_ARMCORE ) && defined(CONFIG_PCI ) -void cmx2xx_pci_adjust_zones (unsigned long *size,unsigned long *holes); - -#define arch_adjust_zones (size, holes) \ - cmx2xx_pci_adjust_zones(size, holes) - +#if defined(CONFIG_MACH_ARMCORE ) && defined(CONFIG_PCI )#define ARM_DMA_ZONE_SIZE SZ_64M#endif arch/arm/mach-realview/core.c +0
-19@@ -56,25 +56,6 @@#include "core.h" -#ifdef CONFIG_ZONE_DMA -/* -* Adjust the zones if there are restrictions for DMA access. -*/ -void __init realview_adjust_zones (unsigned long *size,unsigned long *hole) -{ -unsigned long dma_size =SZ_256M >>PAGE_SHIFT ; - -if (!machine_is_realview_pbx () || size[0 ] <= dma_size) -return ; - - size[ZONE_NORMAL ] = size[0 ] - dma_size; - size[ZONE_DMA ] = dma_size; - hole[ZONE_NORMAL ] = hole[0 ]; - hole[ZONE_DMA ] =0 ; -} -#endif - -#define REALVIEW_FLASHCTRL (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)static int realview_flash_init (void )arch/arm/mach-realview/include/mach/memory.h +1
-5@@ -29,11 +29,7 @@#define PLAT_PHYS_OFFSET UL(0x00000000)#endif -#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA ) -extern void realview_adjust_zones (unsigned long *size,unsigned long *hole); -#define arch_adjust_zones (size, hole) \ - realview_adjust_zones(size, hole) - +#ifdef CONFIG_ZONE_DMA #define ARM_DMA_ZONE_SIZE SZ_256M#endif arch/arm/mach-sa1100/include/mach/memory.h +0
-9@@ -14,17 +14,8 @@*/ #define PLAT_PHYS_OFFSET UL(0xc0000000) -#ifndef __ASSEMBLY__ -#ifdef CONFIG_SA1111 -void sa1111_adjust_zones (unsigned long *size,unsigned long *holes); - -#define arch_adjust_zones (size, holes) \ - sa1111_adjust_zones(size, holes) -#define ARM_DMA_ZONE_SIZE SZ_1M - -#endif #endif /* arch/arm/mach-shark/include/mach/memory.h +0
-17@@ -17,25 +17,8 @@*/ #define PLAT_PHYS_OFFSET UL(0x08000000) -#ifndef __ASSEMBLY__ - -static inline void __arch_adjust_zones (unsigned long *zone_size,unsigned long *zhole_size) -{ -/* Only the first 4 MB (=1024 Pages) are usable for DMA */ -/* See dev / -> .properties in OpenFirmware. */ - zone_size[1 ] = zone_size[0 ] -1024 ; - zone_size[0 ] =1024 ; - zhole_size[1 ] = zhole_size[0 ]; - zhole_size[0 ] =0 ; -} - -#define arch_adjust_zones (size, holes) \ - __arch_adjust_zones(size, holes) -#define ARM_DMA_ZONE_SIZE SZ_4M -#endif -/* * Cache flushing area */ arch/arm/mm/init.c +22
-1@@ -201,6 +201,20 @@ static void __init arm_bootmem_init(unsigned long start_pfn, } } +#ifdef CONFIG_ZONE_DMA +static void __init arm_adjust_dma_zone (unsigned long *size,unsigned long *hole, +unsigned long dma_size) +{ +if (size[0 ] <= dma_size) +return ; + + size[ZONE_NORMAL ] = size[0 ] - dma_size; + size[ZONE_DMA ] = dma_size; + hole[ZONE_NORMAL ] = hole[0 ]; + hole[ZONE_DMA ] =0 ; +} +#endif +static void __init arm_bootmem_free (unsigned long min,unsigned long max_low,unsigned long max_high) {@@ -243,11 +257,18 @@ static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,#endif } +#ifdef ARM_DMA_ZONE_SIZE +#ifndef CONFIG_ZONE_DMA +#error ARM_DMA_ZONE_SIZE set but no DMA zone to limit allocations +#endif +/* * Adjust the sizes according to any special requirements for * this machine type. */ -arch_adjust_zones (zone_size, zhole_size); +arm_adjust_dma_zone (zone_size, zhole_size, +ARM_DMA_ZONE_SIZE >>PAGE_SHIFT ); +#endif free_area_init_node (0 , zone_size, min, zhole_size); }Signature · 1 line
1.7.4.4
cover Consolidate zone adjustment
In reply to Russell King - ARM LinuxQuoted 6 lines · Russell King - ARM Linux
This patch mini-series consolidates the adjustment to system zones which some of our platforms require. Rather than having each platform/machine class specify
ISA_DMA_THRESHOLD,MAX_DMA_ADDRESSand anarch_adjust_zonesfunction, they really only need to provide a single sizing definition, which in this series will be calledARM_DMA_ZONE_SIZE.
Boot tested this series on DaVinci DA850.
Thanks,
Sekhar