Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes

Rather 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.

Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

+25 -144
-8
arch/arm/common/sa1111.c
··· 185 185 }, 186 186 }; 187 187 188 - void __init sa1111_adjust_zones(unsigned long *size, unsigned long *holes) 189 - { 190 - unsigned int sz = SZ_1M >> PAGE_SHIFT; 191 - 192 - size[1] = size[0] - sz; 193 - size[0] = sz; 194 - } 195 - 196 188 /* 197 189 * SA1111 interrupt support. Since clearing an IRQ while there are 198 190 * active IRQs causes the interrupt output to pulse, the upper levels
-6
arch/arm/include/asm/memory.h
··· 215 215 #define ISA_DMA_THRESHOLD (PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1) 216 216 #endif 217 217 218 - #ifndef arch_adjust_zones 219 - #define arch_adjust_zones(size,holes) do { } while (0) 220 - #elif !defined(CONFIG_ZONE_DMA) 221 - #error "custom arch_adjust_zones() requires CONFIG_ZONE_DMA" 222 - #endif 223 - 224 218 /* 225 219 * PFNs are used to describe any physical page; this means 226 220 * PFN 0 == physical address 0.
-15
arch/arm/mach-davinci/include/mach/memory.h
··· 41 41 */ 42 42 #define CONSISTENT_DMA_SIZE (14<<20) 43 43 44 - #ifndef __ASSEMBLY__ 45 44 /* 46 45 * Restrict DMA-able region to workaround silicon bug. The bug 47 46 * restricts buffers available for DMA to video hardware to be 48 47 * below 128M 49 48 */ 50 - static inline void 51 - __arch_adjust_zones(unsigned long *size, unsigned long *holes) 52 - { 53 - unsigned int sz = (128<<20) >> PAGE_SHIFT; 54 - 55 - size[1] = size[0] - sz; 56 - size[0] = sz; 57 - } 58 - 59 - #define arch_adjust_zones(zone_size, holes) \ 60 - if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes) 61 - 62 49 #define ARM_DMA_ZONE_SIZE SZ_128M 63 - 64 - #endif 65 50 66 51 #endif /* __ASM_ARCH_MEMORY_H */
-23
arch/arm/mach-ixp4xx/common-pci.c
··· 342 342 return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >= SZ_64M); 343 343 } 344 344 345 - /* 346 - * Only first 64MB of memory can be accessed via PCI. 347 - * We use GFP_DMA to allocate safe buffers to do map/unmap. 348 - * This is really ugly and we need a better way of specifying 349 - * DMA-capable regions of memory. 350 - */ 351 - void __init ixp4xx_adjust_zones(unsigned long *zone_size, 352 - unsigned long *zhole_size) 353 - { 354 - unsigned int sz = SZ_64M >> PAGE_SHIFT; 355 - 356 - /* 357 - * Only adjust if > 64M on current system 358 - */ 359 - if (zone_size[0] <= sz) 360 - return; 361 - 362 - zone_size[1] = zone_size[0] - sz; 363 - zone_size[0] = sz; 364 - zhole_size[1] = zhole_size[0]; 365 - zhole_size[0] = 0; 366 - } 367 - 368 345 void __init ixp4xx_pci_preinit(void) 369 346 { 370 347 unsigned long cpuid = read_cpuid_id();
+1 -8
arch/arm/mach-ixp4xx/include/mach/memory.h
··· 14 14 */ 15 15 #define PLAT_PHYS_OFFSET UL(0x00000000) 16 16 17 - #if !defined(__ASSEMBLY__) && defined(CONFIG_PCI) 18 - 19 - void ixp4xx_adjust_zones(unsigned long *size, unsigned long *holes); 20 - 21 - #define arch_adjust_zones(size, holes) \ 22 - ixp4xx_adjust_zones(size, holes) 23 - 17 + #ifdef CONFIG_PCI 24 18 #define ARM_DMA_ZONE_SIZE SZ_64M 25 - 26 19 #endif 27 20 28 21 #endif
-27
arch/arm/mach-pxa/cm-x2xx-pci.c
··· 29 29 unsigned long it8152_base_address; 30 30 static int cmx2xx_it8152_irq_gpio; 31 31 32 - /* 33 - * Only first 64MB of memory can be accessed via PCI. 34 - * We use GFP_DMA to allocate safe buffers to do map/unmap. 35 - * This is really ugly and we need a better way of specifying 36 - * DMA-capable regions of memory. 37 - */ 38 - void __init cmx2xx_pci_adjust_zones(unsigned long *zone_size, 39 - unsigned long *zhole_size) 40 - { 41 - unsigned int sz = SZ_64M >> PAGE_SHIFT; 42 - 43 - if (machine_is_armcore()) { 44 - pr_info("Adjusting zones for CM-X2XX\n"); 45 - 46 - /* 47 - * Only adjust if > 64M on current system 48 - */ 49 - if (zone_size[0] <= sz) 50 - return; 51 - 52 - zone_size[1] = zone_size[0] - sz; 53 - zone_size[0] = sz; 54 - zhole_size[1] = zhole_size[0]; 55 - zhole_size[0] = 0; 56 - } 57 - } 58 - 59 32 static void cmx2xx_it8152_irq_demux(unsigned int irq, struct irq_desc *desc) 60 33 { 61 34 /* clear our parent irq */
+1 -6
arch/arm/mach-pxa/include/mach/memory.h
··· 17 17 */ 18 18 #define PLAT_PHYS_OFFSET UL(0xa0000000) 19 19 20 - #if !defined(__ASSEMBLY__) && defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI) 21 - void cmx2xx_pci_adjust_zones(unsigned long *size, unsigned long *holes); 22 - 23 - #define arch_adjust_zones(size, holes) \ 24 - cmx2xx_pci_adjust_zones(size, holes) 25 - 20 + #if defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI) 26 21 #define ARM_DMA_ZONE_SIZE SZ_64M 27 22 #endif 28 23
-19
arch/arm/mach-realview/core.c
··· 56 56 57 57 #include "core.h" 58 58 59 - #ifdef CONFIG_ZONE_DMA 60 - /* 61 - * Adjust the zones if there are restrictions for DMA access. 62 - */ 63 - void __init realview_adjust_zones(unsigned long *size, unsigned long *hole) 64 - { 65 - unsigned long dma_size = SZ_256M >> PAGE_SHIFT; 66 - 67 - if (!machine_is_realview_pbx() || size[0] <= dma_size) 68 - return; 69 - 70 - size[ZONE_NORMAL] = size[0] - dma_size; 71 - size[ZONE_DMA] = dma_size; 72 - hole[ZONE_NORMAL] = hole[0]; 73 - hole[ZONE_DMA] = 0; 74 - } 75 - #endif 76 - 77 - 78 59 #define REALVIEW_FLASHCTRL (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET) 79 60 80 61 static int realview_flash_init(void)
+1 -5
arch/arm/mach-realview/include/mach/memory.h
··· 29 29 #define PLAT_PHYS_OFFSET UL(0x00000000) 30 30 #endif 31 31 32 - #if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA) 33 - extern void realview_adjust_zones(unsigned long *size, unsigned long *hole); 34 - #define arch_adjust_zones(size, hole) \ 35 - realview_adjust_zones(size, hole) 36 - 32 + #ifdef CONFIG_ZONE_DMA 37 33 #define ARM_DMA_ZONE_SIZE SZ_256M 38 34 #endif 39 35
-9
arch/arm/mach-sa1100/include/mach/memory.h
··· 14 14 */ 15 15 #define PLAT_PHYS_OFFSET UL(0xc0000000) 16 16 17 - #ifndef __ASSEMBLY__ 18 - 19 17 #ifdef CONFIG_SA1111 20 - void sa1111_adjust_zones(unsigned long *size, unsigned long *holes); 21 - 22 - #define arch_adjust_zones(size, holes) \ 23 - sa1111_adjust_zones(size, holes) 24 - 25 18 #define ARM_DMA_ZONE_SIZE SZ_1M 26 - 27 - #endif 28 19 #endif 29 20 30 21 /*
-17
arch/arm/mach-shark/include/mach/memory.h
··· 17 17 */ 18 18 #define PLAT_PHYS_OFFSET UL(0x08000000) 19 19 20 - #ifndef __ASSEMBLY__ 21 - 22 - static inline void __arch_adjust_zones(unsigned long *zone_size, unsigned long *zhole_size) 23 - { 24 - /* Only the first 4 MB (=1024 Pages) are usable for DMA */ 25 - /* See dev / -> .properties in OpenFirmware. */ 26 - zone_size[1] = zone_size[0] - 1024; 27 - zone_size[0] = 1024; 28 - zhole_size[1] = zhole_size[0]; 29 - zhole_size[0] = 0; 30 - } 31 - 32 - #define arch_adjust_zones(size, holes) \ 33 - __arch_adjust_zones(size, holes) 34 - 35 20 #define ARM_DMA_ZONE_SIZE SZ_4M 36 - 37 - #endif 38 21 39 22 /* 40 23 * Cache flushing area
+22 -1
arch/arm/mm/init.c
··· 201 201 } 202 202 } 203 203 204 + #ifdef CONFIG_ZONE_DMA 205 + static void __init arm_adjust_dma_zone(unsigned long *size, unsigned long *hole, 206 + unsigned long dma_size) 207 + { 208 + if (size[0] <= dma_size) 209 + return; 210 + 211 + size[ZONE_NORMAL] = size[0] - dma_size; 212 + size[ZONE_DMA] = dma_size; 213 + hole[ZONE_NORMAL] = hole[0]; 214 + hole[ZONE_DMA] = 0; 215 + } 216 + #endif 217 + 204 218 static void __init arm_bootmem_free(unsigned long min, unsigned long max_low, 205 219 unsigned long max_high) 206 220 { ··· 257 243 #endif 258 244 } 259 245 246 + #ifdef ARM_DMA_ZONE_SIZE 247 + #ifndef CONFIG_ZONE_DMA 248 + #error ARM_DMA_ZONE_SIZE set but no DMA zone to limit allocations 249 + #endif 250 + 260 251 /* 261 252 * Adjust the sizes according to any special requirements for 262 253 * this machine type. 263 254 */ 264 - arch_adjust_zones(zone_size, zhole_size); 255 + arm_adjust_dma_zone(zone_size, zhole_size, 256 + ARM_DMA_ZONE_SIZE >> PAGE_SHIFT); 257 + #endif 265 258 266 259 free_area_init_node(0, zone_size, min, zhole_size); 267 260 }