Skip to contentSkip to conversation

ARM: change ARM_DMA_ZONE_SIZE into a variable

PATCH New Nicolas Pitre 6 participants 33 messages Jul 6, 2011 – Jul 9, 2011

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Having this value defined at compile time prevents multiple machines with conflicting definitions to coexist. Move it to a variable in preparation for having a per machine value selected at run time. This is relevant only when CONFIG_ZONE_DMA is selected.

---
 arch/arm/include/asm/dma.h    |    7 ++++---
 arch/arm/include/asm/memory.h |    7 +++++--
 arch/arm/mm/init.c            |   20 +++++++++++++-------
 3 files changed, 22 insertions(+), 12 deletions(-)
arch/arm/include/asm/dma.h +4 -3
index 4200554..1d34c11 100644
@@ -6,10 +6,11 @@
 /*
  * This is the maximum virtual address which can be DMA'd from.
  */
-#ifndef ARM_DMA_ZONE_SIZE
-#define MAX_DMA_ADDRESS	0xffffffff
+#ifndef CONFIG_ZONE_DMA
+#define MAX_DMA_ADDRESS	0xffffffffUL
 #else
-#define MAX_DMA_ADDRESS	(PAGE_OFFSET + ARM_DMA_ZONE_SIZE)
+extern unsigned long arm_dma_zone_size;
+#define MAX_DMA_ADDRESS	(PAGE_OFFSET + arm_dma_zone_size)
 #endif
 
 #ifdef CONFIG_ISA_DMA_API
arch/arm/include/asm/memory.h +5 -2
index af44a8f..deb2eaa 100644
@@ -209,10 +209,13 @@ 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 ARM_DMA_ZONE_SIZE
+#ifndef CONFIG_ZONE_DMA
 #define ISA_DMA_THRESHOLD	(0xffffffffULL)
 #else
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
+#define ISA_DMA_THRESHOLD	({ \
+	extern unsigned long arm_dma_zone_size; \
+	arm_dma_zone_size ? \
+		(PHYS_OFFSET + arm_dma_zone_size - 1) : 0xffffffffULL; })
 #endif
 
 /*
arch/arm/mm/init.c +13 -7
index c19571c..a14caff 100644
@@ -34,6 +34,15 @@
 
 #include "mm.h"
 
+#ifdef CONFIG_ZONE_DMA
+#ifdef ARM_DMA_ZONE_SIZE
+unsigned long arm_dma_zone_size = ARM_DMA_ZONE_SIZE;
+#else
+unsigned long arm_dma_zone_size __read_mostly;
+#endif
+EXPORT_SYMBOL(arm_dma_zone_size);
+#endif
+
 static unsigned long phys_initrd_start __initdata = 0;
 static unsigned long phys_initrd_size __initdata = 0;
 
@@ -267,17 +276,14 @@ 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
-
+#ifdef CONFIG_ZONE_DMA
 	/*
 	 * Adjust the sizes according to any special requirements for
 	 * this machine type.
 	 */
-	arm_adjust_dma_zone(zone_size, zhole_size,
-		ARM_DMA_ZONE_SIZE >> PAGE_SHIFT);
+	if (arm_dma_zone_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
#1 lore raw

PATCH 2/10 ARM: add dma_zone_size to the machine_desc structure

---
 arch/arm/include/asm/mach/arch.h |    4 ++++
 arch/arm/kernel/setup.c          |    6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)
arch/arm/include/asm/mach/arch.h +4 -0
index 946f4d7..7b79a00 100644
@@ -23,6 +23,10 @@ struct machine_desc {
 
 	unsigned int		nr_irqs;	/* number of IRQs */
 
+#ifdef CONFIG_ZONE_DMA
+	unsigned long dma_zone_size;		/* size of DMA-able area */
+#endif
+
 	unsigned int		video_start;	/* start of video RAM	*/
 	unsigned int		video_end;	/* end of video RAM	*/
 
arch/arm/kernel/setup.c +6 -0
index ed11fb0..e0db84d 100644
@@ -916,6 +916,12 @@ void __init setup_arch(char **cmdline_p)
 	cpu_init();
 	tcm_init();
 
+#ifdef CONFIG_ZONE_DMA
+	if (mdesc->dma_zone_size) {
+		extern unsigned long arm_dma_zone_size;
+		arm_dma_zone_size = mdesc->dma_zone_size;
+	}
+#endif
 #ifdef CONFIG_MULTI_IRQ_HANDLER
 	handle_arch_irq = mdesc->handle_irq;
 #endif
Signature · 1 line
1.7.4
#2 lore raw

PATCH 2/10 ARM: add dma_zone_size to the machine_desc structure

Quoted 11 lines · Nicolas Pitre
---
 arch/arm/include/asm/mach/arch.h |    4 ++++
 arch/arm/kernel/setup.c          |    6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)
arch/arm/include/asm/mach/arch.h +0 -0
index 946f4d7..7b79a00 100644

arch/arm/include/asm/mach/arch.h struct machine_desc { · line 27

Quoted 5 lines
arch/arm/include/asm/mach/arch.h +2 -0
@@ -23,6 +23,10 @@ struct machine_desc {
 
 	unsigned int		nr_irqs;	/* number of IRQs */
 
+#ifdef CONFIG_ZONE_DMA
+	unsigned long dma_zone_size;		/* size of DMA-able area */

Please try to keep the formatting the same.

#3 lore raw

PATCH 2/10 ARM: add dma_zone_size to the machine_desc structure

Quoted 13 lines · Russell King - ARM Linux
Quoted 12 lines · Nicolas Pitre
---
 arch/arm/include/asm/mach/arch.h |    4 ++++
 arch/arm/kernel/setup.c          |    6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)
arch/arm/include/asm/mach/arch.h +0 -0
index 946f4d7..7b79a00 100644
@@ -23,6 +23,10 @@ struct machine_desc {
 
Quoted 6 lines

arch/arm/include/asm/mach/arch.h struct machine_desc { · line 27

Quoted 4 lines
arch/arm/include/asm/mach/arch.h +2 -0
 	unsigned int		nr_irqs;	/* number of IRQs */
 
+#ifdef CONFIG_ZONE_DMA
+	unsigned long dma_zone_size;		/* size of DMA-able area */

Please try to keep the formatting the same.

Oops, sure. That's what might happens when your "screen" is effectively a unidimensional 40x1 character display. Fixed.

Nicolas

#4 lore raw

PATCH 3/10 ARM: mach-davinci: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

In reply to Nicolas Pitre
---
 arch/arm/mach-davinci/board-da830-evm.c     |    1 +
 arch/arm/mach-davinci/board-da850-evm.c     |    1 +
 arch/arm/mach-davinci/board-dm355-evm.c     |    1 +
 arch/arm/mach-davinci/board-dm355-leopard.c |    1 +
 arch/arm/mach-davinci/board-dm365-evm.c     |    1 +
 arch/arm/mach-davinci/board-dm644x-evm.c    |    1 +
 arch/arm/mach-davinci/board-dm646x-evm.c    |    2 ++
 arch/arm/mach-davinci/board-mityomapl138.c  |    1 +
 arch/arm/mach-davinci/board-neuros-osd2.c   |    1 +
 arch/arm/mach-davinci/board-omapl138-hawk.c |    1 +
 arch/arm/mach-davinci/board-sffsdr.c        |    1 +
 arch/arm/mach-davinci/board-tnetv107x-evm.c |    1 +
 arch/arm/mach-davinci/include/mach/memory.h |    7 -------
 13 files changed, 13 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +1 -0
index 8bc3701..84fd7868 100644
@@ -681,4 +681,5 @@ MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM")
 	.init_irq	= cp_intc_init,
 	.timer		= &davinci_timer,
 	.init_machine	= da830_evm_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/board-da850-evm.c +1 -0
index a7b41bf..29671ef 100644
@@ -1261,4 +1261,5 @@ MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
 	.init_irq	= cp_intc_init,
 	.timer		= &davinci_timer,
 	.init_machine	= da850_evm_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/board-dm355-evm.c +1 -0
index 6e7cad13..241a6bd 100644
@@ -356,4 +356,5 @@ MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM")
 	.init_irq     = davinci_irq_init,
 	.timer	      = &davinci_timer,
 	.init_machine = dm355_evm_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/board-dm355-leopard.c +1 -0
index 543f991..bee284c 100644
@@ -275,4 +275,5 @@ MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard")
 	.init_irq     = davinci_irq_init,
 	.timer	      = &davinci_timer,
 	.init_machine = dm355_leopard_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/board-dm365-evm.c +1 -0
index c67f684..9844fa4 100644
@@ -617,5 +617,6 @@ MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM")
 	.init_irq	= davinci_irq_init,
 	.timer		= &davinci_timer,
 	.init_machine	= dm365_evm_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
 
arch/arm/mach-davinci/board-dm644x-evm.c +1 -0
index 556bbd4..95607a1 100644
@@ -717,4 +717,5 @@ MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
 	.init_irq     = davinci_irq_init,
 	.timer	      = &davinci_timer,
 	.init_machine = davinci_evm_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/board-dm646x-evm.c +2 -0
index f6ac9ba..6d03643 100644
@@ -802,6 +802,7 @@ MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
 	.init_irq     = davinci_irq_init,
 	.timer        = &davinci_timer,
 	.init_machine = evm_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
 
 MACHINE_START(DAVINCI_DM6467TEVM, "DaVinci DM6467T EVM")
@@ -810,5 +811,6 @@ MACHINE_START(DAVINCI_DM6467TEVM, "DaVinci DM6467T EVM")
 	.init_irq     = davinci_irq_init,
 	.timer        = &davinci_timer,
 	.init_machine = evm_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
 
arch/arm/mach-davinci/board-mityomapl138.c +1 -0
index 606a6f2..b8d59ca 100644
@@ -570,4 +570,5 @@ MACHINE_START(MITYOMAPL138, "MityDSP-L138/MityARM-1808")
 	.init_irq	= cp_intc_init,
 	.timer		= &davinci_timer,
 	.init_machine	= mityomapl138_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/board-neuros-osd2.c +1 -0
index 3e7be2d..d60a800 100644
@@ -277,4 +277,5 @@ MACHINE_START(NEUROS_OSD2, "Neuros OSD2")
 	.init_irq	= davinci_irq_init,
 	.timer		= &davinci_timer,
 	.init_machine = davinci_ntosd2_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/board-omapl138-hawk.c +1 -0
index 67c38d0..237332a 100644
@@ -343,4 +343,5 @@ MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard")
 	.init_irq	= cp_intc_init,
 	.timer		= &davinci_timer,
 	.init_machine	= omapl138_hawk_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/board-sffsdr.c +1 -0
index 61ac96d..5f4385c 100644
@@ -156,4 +156,5 @@ MACHINE_START(SFFSDR, "Lyrtech SFFSDR")
 	.init_irq     = davinci_irq_init,
 	.timer	      = &davinci_timer,
 	.init_machine = davinci_sffsdr_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/board-tnetv107x-evm.c +1 -0
index 1a656e8..7828920 100644
@@ -282,4 +282,5 @@ MACHINE_START(TNETV107X, "TNETV107X EVM")
 	.init_irq	= cp_intc_init,
 	.timer		= &davinci_timer,
 	.init_machine	= tnetv107x_evm_board_init,
+	.dma_zone_size	= SZ_128M,
 MACHINE_END
arch/arm/mach-davinci/include/mach/memory.h +0 -7
index 491249e..7873194 100644
@@ -41,11 +41,4 @@
  */
 #define CONSISTENT_DMA_SIZE (14<<20)
 
-/*
- * Restrict DMA-able region to workaround silicon bug.  The bug
- * restricts buffers available for DMA to video hardware to be
- * below 128M
- */
-#define ARM_DMA_ZONE_SIZE	SZ_128M
-
 #endif /* __ASM_ARCH_MEMORY_H */
Signature · 1 line
1.7.4
#5 lore raw

PATCH 4/10 ARM: mach-h720x: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

In reply to Nicolas Pitre
---
 arch/arm/mach-h720x/h7201-eval.c          |    1 +
 arch/arm/mach-h720x/h7202-eval.c          |    1 +
 arch/arm/mach-h720x/include/mach/memory.h |    7 -------
 3 files changed, 2 insertions(+), 7 deletions(-)
arch/arm/mach-h720x/h7201-eval.c +1 -0
index 629454d..65f1bea 100644
@@ -33,4 +33,5 @@ MACHINE_START(H7201, "Hynix GMS30C7201")
 	.map_io		= h720x_map_io,
 	.init_irq	= h720x_init_irq,
 	.timer		= &h7201_timer,
+	.dma_zone_size	= SZ_256M,
 MACHINE_END
arch/arm/mach-h720x/h7202-eval.c +1 -0
index e9f46b6..884584a 100644
@@ -76,4 +76,5 @@ MACHINE_START(H7202, "Hynix HMS30C7202")
 	.init_irq	= h7202_init_irq,
 	.timer		= &h7202_timer,
 	.init_machine	= init_eval_h7202,
+	.dma_zone_size	= SZ_256M,
 MACHINE_END
arch/arm/mach-h720x/include/mach/memory.h +0 -7
index b0b3bae..96dcf50 100644
@@ -8,11 +8,4 @@
 #define __ASM_ARCH_MEMORY_H
 
 #define PLAT_PHYS_OFFSET	UL(0x40000000)
-/*
- * This is the maximum DMA address that can be DMAd to.
- * There should not be more than (0xd0000000 - 0xc0000000)
- * bytes of RAM.
- */
-#define ARM_DMA_ZONE_SIZE	SZ_256M
-
 #endif
Signature · 1 line
1.7.4
#6 lore raw

PATCH 5/10 ARM: mach-ixp4xx: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

In reply to Nicolas Pitre
---
 arch/arm/mach-ixp4xx/avila-setup.c         |    6 ++++++
 arch/arm/mach-ixp4xx/coyote-setup.c        |    3 +++
 arch/arm/mach-ixp4xx/dsmg600-setup.c       |    3 +++
 arch/arm/mach-ixp4xx/fsg-setup.c           |    3 +++
 arch/arm/mach-ixp4xx/gateway7001-setup.c   |    3 +++
 arch/arm/mach-ixp4xx/goramo_mlr.c          |    3 +++
 arch/arm/mach-ixp4xx/gtwx5715-setup.c      |    3 +++
 arch/arm/mach-ixp4xx/include/mach/memory.h |    4 ----
 arch/arm/mach-ixp4xx/ixdp425-setup.c       |   12 ++++++++++++
 arch/arm/mach-ixp4xx/nas100d-setup.c       |    3 +++
 arch/arm/mach-ixp4xx/nslu2-setup.c         |    3 +++
 arch/arm/mach-ixp4xx/vulcan-setup.c        |    3 +++
 arch/arm/mach-ixp4xx/wg302v2-setup.c       |    3 +++
 13 files changed, 48 insertions(+), 4 deletions(-)
arch/arm/mach-ixp4xx/avila-setup.c +6 -0
index 73745ff..05bf40d 100644
@@ -169,6 +169,9 @@ MACHINE_START(AVILA, "Gateworks Avila Network Platform")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= avila_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 
  /*
@@ -184,6 +187,9 @@ MACHINE_START(LOFT, "Giant Shoulder Inc Loft board")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= avila_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 #endif
 
arch/arm/mach-ixp4xx/coyote-setup.c +3 -0
index 355e3de..0adf01b 100644
@@ -114,6 +114,9 @@ MACHINE_START(ADI_COYOTE, "ADI Engineering Coyote")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= coyote_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 #endif
 
arch/arm/mach-ixp4xx/dsmg600-setup.c +3 -0
index d398229..3eb8861 100644
@@ -284,4 +284,7 @@ MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
 	.init_irq	= ixp4xx_init_irq,
 	.timer          = &dsmg600_timer,
 	.init_machine	= dsmg600_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
arch/arm/mach-ixp4xx/fsg-setup.c +3 -0
index 727ee39..d26bd4b 100644
@@ -275,5 +275,8 @@ MACHINE_START(FSG, "Freecom FSG-3")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= fsg_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 
arch/arm/mach-ixp4xx/gateway7001-setup.c +3 -0
index 9dc0b4e..85e179e 100644
@@ -101,5 +101,8 @@ MACHINE_START(GATEWAY7001, "Gateway 7001 AP")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= gateway7001_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 #endif
arch/arm/mach-ixp4xx/goramo_mlr.c +3 -0
index 3e8c0e3..34955e8 100644
@@ -501,4 +501,7 @@ MACHINE_START(GORAMO_MLR, "MultiLink")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= gmlr_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
arch/arm/mach-ixp4xx/gtwx5715-setup.c +3 -0
index 77abead..283e128 100644
@@ -169,6 +169,9 @@ MACHINE_START(GTWX5715, "Gemtek GTWX5715 (Linksys WRV54G)")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= gtwx5715_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 
 
arch/arm/mach-ixp4xx/include/mach/memory.h +0 -4
index 34e7940..4caf176 100644
@@ -14,8 +14,4 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0x00000000)
 
-#ifdef CONFIG_PCI
-#define ARM_DMA_ZONE_SIZE	SZ_64M
-#endif
-
 #endif
arch/arm/mach-ixp4xx/ixdp425-setup.c +12 -0
index dca4f7f..d89e11f 100644
@@ -258,6 +258,9 @@ MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= ixdp425_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 #endif
 
@@ -269,6 +272,9 @@ MACHINE_START(IXDP465, "Intel IXDP465 Development Platform")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= ixdp425_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 #endif
 
@@ -280,6 +286,9 @@ MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= ixdp425_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 #endif
 
@@ -291,5 +300,8 @@ MACHINE_START(KIXRP435, "Intel KIXRP435 Reference Platform")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= ixdp425_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 #endif
arch/arm/mach-ixp4xx/nas100d-setup.c +3 -0
index f18fee7..5cb107b 100644
@@ -319,4 +319,7 @@ MACHINE_START(NAS100D, "Iomega NAS 100d")
 	.init_irq	= ixp4xx_init_irq,
 	.timer          = &ixp4xx_timer,
 	.init_machine	= nas100d_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
arch/arm/mach-ixp4xx/nslu2-setup.c +3 -0
index f79b62e..446375d 100644
@@ -305,4 +305,7 @@ MACHINE_START(NSLU2, "Linksys NSLU2")
 	.init_irq	= ixp4xx_init_irq,
 	.timer          = &nslu2_timer,
 	.init_machine	= nslu2_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
arch/arm/mach-ixp4xx/vulcan-setup.c +3 -0
index 4e72cfd..4a2d4e7 100644
@@ -241,4 +241,7 @@ MACHINE_START(ARCOM_VULCAN, "Arcom/Eurotech Vulcan")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= vulcan_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
arch/arm/mach-ixp4xx/wg302v2-setup.c +3 -0
index 5d148c7..5397237 100644
@@ -102,5 +102,8 @@ MACHINE_START(WG302V2, "Netgear WG302 v2 / WAG302 v2")
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
 	.init_machine	= wg302v2_init,
+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
 #endif
Signature · 1 line
1.7.4
#7 lore raw

PATCH 5/10 ARM: mach-ixp4xx: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

Quoted 1 line · Nicolas Pitre

+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)

This won't fly. CONFIG has to be upper case. Multiple instances of that in this patch.

arch/arm/mach-ixp4xx/include/mach/memory.h line 19

Quoted 11 lines
arch/arm/mach-ixp4xx/include/mach/memory.h +0 -3
index 34e7940..4caf176 100644
@@ -14,8 +14,4 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0x00000000)
 
-#ifdef CONFIG_PCI
-#define ARM_DMA_ZONE_SIZE	SZ_64M
-#endif

And the addition of dependence on CONFIG_IXP4XX_INDIRECT_PCI needs someone from the IXP4xx folk to ACK as that's a functional change.

#8 lore raw

PATCH 5/10 ARM: mach-ixp4xx: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

Quoted 5 lines · Russell King - ARM Linux
Quoted 1 line · Nicolas Pitre

+#if defined(config_PCI) && !defined(CONFIG_IXP4XX_INDIRECT_PCI)

This won't fly. CONFIG has to be upper case. Multiple instances of that in this patch.

Okay... Obviously the fact that one's unidimensional 40x1 display made of mechanically raised pixels might have some of those pixels stuck in their set position is enough to confuse lower and upper case braille characters (yes I should have it fixed).

Fixed the code in the mean time, and compile tested it. turns out that an unrelated file doesn't compile:

arch/arm/mach-ixp4xx/common.c: In function 'ixp4xx_clocksource_init':
arch/arm/mach-ixp4xx/common.c:428:2: error: lvalue required as unary '&' operand

Quoted 8 lines
Quoted 8 lines
arch/arm/mach-ixp4xx/include/mach/memory.h +0 -0
index 34e7940..4caf176 100644
@@ -14,8 +14,4 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0x00000000)
 
Quoted 6 lines

arch/arm/mach-ixp4xx/include/mach/memory.h line 19

Quoted 3 lines
arch/arm/mach-ixp4xx/include/mach/memory.h +0 -3
-#ifdef CONFIG_PCI
-#define ARM_DMA_ZONE_SIZE	SZ_64M
-#endif

And the addition of dependence on CONFIG_IXP4XX_INDIRECT_PCI needs someone from the IXP4xx folk to ACK as that's a functional change.

The motivation for this change can be found in the Kconfig help text for IXP4XX_INDIRECT_PCI which looked pretty clear. But this would be best if done in a separate patch so I've reverted this patch to the single CONFIG_PCI dependency.

Nicolas

#9 lore raw

PATCH 6/10 ARM: mach-pxa: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

In reply to Nicolas Pitre
---
 arch/arm/mach-pxa/cm-x2xx.c             |    3 +++
 arch/arm/mach-pxa/include/mach/memory.h |    4 ----
 2 files changed, 3 insertions(+), 4 deletions(-)
arch/arm/mach-pxa/cm-x2xx.c +3 -0
index a109967..bc55d07 100644
@@ -518,4 +518,7 @@ MACHINE_START(ARMCORE, "Compulab CM-X2XX")
 	.init_irq	= cmx2xx_init_irq,
 	.timer		= &pxa_timer,
 	.init_machine	= cmx2xx_init,
+#ifdef CONFIG_PCI
+	.dma_zone_size	= SZ_64M,
+#endif
 MACHINE_END
arch/arm/mach-pxa/include/mach/memory.h +0 -4
index 07734f3..d05a597 100644
@@ -17,8 +17,4 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0xa0000000)
 
-#if defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI)
-#define ARM_DMA_ZONE_SIZE	SZ_64M
-#endif
-
 #endif
Signature · 1 line
1.7.4
#10 lore raw

PATCH 7/10 ARM: mach-realview: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

In reply to Nicolas Pitre
---
 arch/arm/mach-realview/include/mach/memory.h |    4 ----
 arch/arm/mach-realview/realview_eb.c         |    3 +++
 arch/arm/mach-realview/realview_pb1176.c     |    3 +++
 arch/arm/mach-realview/realview_pb11mp.c     |    3 +++
 arch/arm/mach-realview/realview_pba8.c       |    3 +++
 arch/arm/mach-realview/realview_pbx.c        |    3 +++
 6 files changed, 15 insertions(+), 4 deletions(-)
arch/arm/mach-realview/include/mach/memory.h +0 -4
index 1759fa6..2022e09 100644
@@ -29,10 +29,6 @@
 #define PLAT_PHYS_OFFSET		UL(0x00000000)
 #endif
 
-#ifdef CONFIG_ZONE_DMA
-#define ARM_DMA_ZONE_SIZE	SZ_256M
-#endif
-
 #ifdef CONFIG_SPARSEMEM
 
 /*
arch/arm/mach-realview/realview_eb.c +3 -0
index 10e75fa..006a11b 100644
@@ -470,4 +470,7 @@ MACHINE_START(REALVIEW_EB, "ARM-RealView EB")
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_eb_timer,
 	.init_machine	= realview_eb_init,
+#ifdef CONFIG_ZONE_DMA
+	.dma_zone_size	= SZ_128M,
+#endif
 MACHINE_END
arch/arm/mach-realview/realview_pb1176.c +3 -0
index eab6070..a43ca35 100644
@@ -365,4 +365,7 @@ MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176")
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pb1176_timer,
 	.init_machine	= realview_pb1176_init,
+#ifdef CONFIG_ZONE_DMA
+	.dma_zone_size	= SZ_128M,
+#endif
 MACHINE_END
arch/arm/mach-realview/realview_pb11mp.c +3 -0
index b2985fc..1f56fef 100644
@@ -367,4 +367,7 @@ MACHINE_START(REALVIEW_PB11MP, "ARM-RealView PB11MPCore")
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pb11mp_timer,
 	.init_machine	= realview_pb11mp_init,
+#ifdef CONFIG_ZONE_DMA
+	.dma_zone_size	= SZ_128M,
+#endif
 MACHINE_END
arch/arm/mach-realview/realview_pba8.c +3 -0
index fb68665..64374d7 100644
@@ -317,4 +317,7 @@ MACHINE_START(REALVIEW_PBA8, "ARM-RealView PB-A8")
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pba8_timer,
 	.init_machine	= realview_pba8_init,
+#ifdef CONFIG_ZONE_DMA
+	.dma_zone_size	= SZ_128M,
+#endif
 MACHINE_END
arch/arm/mach-realview/realview_pbx.c +3 -0
index 92ace2c..1f9eae6 100644
@@ -400,4 +400,7 @@ MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pbx_timer,
 	.init_machine	= realview_pbx_init,
+#ifdef CONFIG_ZONE_DMA
+	.dma_zone_size	= SZ_128M,
+#endif
 MACHINE_END
Signature · 1 line
1.7.4
#11 lore raw

PATCH 7/10 ARM: mach-realview: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

Quoted 3 lines · Nicolas Pitre
arch/arm/mach-realview/include/mach/memory.h +0 -3
-#ifdef CONFIG_ZONE_DMA
-#define ARM_DMA_ZONE_SIZE	SZ_256M
-#endif

...

Review

Quoted 5 lines
(quoted diff) +5 -0
+	.dma_zone_size	= SZ_128M,
+	.dma_zone_size	= SZ_128M,
+	.dma_zone_size	= SZ_128M,
+	.dma_zone_size	= SZ_128M,
+	.dma_zone_size	= SZ_128M,

Too small...

I think you're rushing to get these patches ready for the 3.1 merge window...

Given that these patches have only just appeared, and the number of sillies in them, they should wait for the next merge window _unless_ they get a thorough review and test.

#12 lore raw

PATCH 7/10 ARM: mach-realview: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

Quoted 5 lines · Russell King - ARM Linux
Quoted 3 lines · Nicolas Pitre
arch/arm/mach-realview/include/mach/memory.h +0 -3
-#ifdef CONFIG_ZONE_DMA
-#define ARM_DMA_ZONE_SIZE	SZ_256M
-#endif

...

Quoted 7 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+	.dma_zone_size	= SZ_128M,
+	.dma_zone_size	= SZ_128M,
+	.dma_zone_size	= SZ_128M,
+	.dma_zone_size	= SZ_128M,
+	.dma_zone_size	= SZ_128M,

Too small...

OK, fixed.

Quoted 2 lines

I think you're rushing to get these patches ready for the 3.1 merge window...

I'm not rushing anything. I've been working on and off on this series for over a month and simply just completed it now. Mechanical changes like this might sometimes have mistakes but they are usually pretty easy to spot by someone with a fresh look.

Quoted 3 lines

Given that these patches have only just appeared, and the number of sillies in them, they should wait for the next merge window _unless_ they get a thorough review and test.

I don't mind waiting for the next merge window. It is not like this is going to be the last of such patch series in order to enable a single zImage anyway. However the next merge window is probably going to see even more of those patches as a Linaro concerted effort is being organized to accelerate that work. Hence I was hoping to spread the patch load by submitting those ones now in order to reduce the size of the next windo's submission.

Nicolas

#13 lore raw

PATCH 8/10 ARM: mach-sa1100: move ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

In reply to Nicolas Pitre
---
 arch/arm/mach-sa1100/assabet.c             |    3 +++
 arch/arm/mach-sa1100/badge4.c              |    3 +++
 arch/arm/mach-sa1100/include/mach/memory.h |    4 ----
 arch/arm/mach-sa1100/jornada720.c          |    3 +++
 4 files changed, 9 insertions(+), 4 deletions(-)
arch/arm/mach-sa1100/assabet.c +3 -0
index 5778274..26257df 100644
@@ -453,4 +453,7 @@ MACHINE_START(ASSABET, "Intel-Assabet")
 	.init_irq	= sa1100_init_irq,
 	.timer		= &sa1100_timer,
 	.init_machine	= assabet_init,
+#ifdef CONFIG_SA1111
+	.dma_zone_size	= SZ_1M,
+#endif
 MACHINE_END
arch/arm/mach-sa1100/badge4.c +3 -0
index 4f19ff8..b4311b0 100644
@@ -306,4 +306,7 @@ MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4")
 	.map_io		= badge4_map_io,
 	.init_irq	= sa1100_init_irq,
 	.timer		= &sa1100_timer,
+#ifdef CONFIG_SA1111
+	.dma_zone_size	= SZ_1M,
+#endif
 MACHINE_END
arch/arm/mach-sa1100/include/mach/memory.h +0 -4
index cff31ee..12d3767 100644
@@ -14,10 +14,6 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0xc0000000)
 
-#ifdef CONFIG_SA1111
-#define ARM_DMA_ZONE_SIZE	SZ_1M
-#endif
-
 /*
  * Because of the wide memory address space between physical RAM banks on the
  * SA1100, it's much convenient to use Linux's SparseMEM support to implement
arch/arm/mach-sa1100/jornada720.c +3 -0
index 491ac9f..176c066 100644
@@ -369,4 +369,7 @@ MACHINE_START(JORNADA720, "HP Jornada 720")
 	.init_irq	= sa1100_init_irq,
 	.timer		= &sa1100_timer,
 	.init_machine	= jornada720_mach_init,
+#ifdef CONFIG_SA1111
+	.dma_zone_size	= SZ_1M,
+#endif
 MACHINE_END
Signature · 1 line
1.7.4
#14 lore raw

PATCH 9/10 ARM: mach-shark: move ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size

In reply to Nicolas Pitre
---
 arch/arm/mach-shark/core.c                |    1 +
 arch/arm/mach-shark/include/mach/memory.h |    2 --
 2 files changed, 1 insertions(+), 2 deletions(-)
arch/arm/mach-shark/core.c +1 -0
index 5cf7f94..ac2873c 100644
@@ -156,4 +156,5 @@ MACHINE_START(SHARK, "Shark")
 	.map_io		= shark_map_io,
 	.init_irq	= shark_init_irq,
 	.timer		= &shark_timer,
+	.dma_zone_size	= SZ_4M,
 MACHINE_END
arch/arm/mach-shark/include/mach/memory.h +0 -2
index 4c0831f8..1cf8d69 100644
@@ -17,8 +17,6 @@
  */
 #define PLAT_PHYS_OFFSET     UL(0x08000000)
 
-#define ARM_DMA_ZONE_SIZE	SZ_4M
-
 /*
  * Cache flushing area
  */
Signature · 1 line
1.7.4
#15 lore raw

PATCH 10/10 ARM: ARM_DMA_ZONE_SIZE is no more

In reply to Nicolas Pitre

One less dependency on mach/memory.h.

---
 arch/arm/include/asm/dma.h |    2 --
 arch/arm/mm/init.c         |    4 ----
 2 files changed, 0 insertions(+), 6 deletions(-)
arch/arm/include/asm/dma.h +0 -2
index 1d34c11..04c162f 100644
@@ -1,8 +1,6 @@
 #ifndef __ASM_ARM_DMA_H
 #define __ASM_ARM_DMA_H
 
-#include <asm/memory.h>
-
 /*
  * This is the maximum virtual address which can be DMA'd from.
  */
arch/arm/mm/init.c +0 -4
index a14caff..d7d9011 100644
@@ -35,11 +35,7 @@
 #include "mm.h"
 
 #ifdef CONFIG_ZONE_DMA
-#ifdef ARM_DMA_ZONE_SIZE
-unsigned long arm_dma_zone_size = ARM_DMA_ZONE_SIZE;
-#else
 unsigned long arm_dma_zone_size __read_mostly;
-#endif
 EXPORT_SYMBOL(arm_dma_zone_size);
 #endif
 
Signature · 1 line
1.7.4
#16 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

In reply to Nicolas Pitre

2011/7/6 Nicolas Pitre <[email protected]>:

Quoted 6 lines

Having this value defined at compile time prevents multiple machines with conflicting definitions to coexist. ?Move it to a variable in preparation for having a per machine value selected at run time. ?This is relevant only when CONFIG_ZONE_DMA is selected.

that is definitely good. i am not sure whether it will be better if dma zone becomes a property in memory node of DT.

        memory {
                reg = <0x00000000 0x20000000>;
                dma_zone = <0x00000000 0x10000000>;
        };
Quoted 96 lines

---

?arch/arm/include/asm/dma.h ? ?| ? ?7 ++++---
?arch/arm/include/asm/memory.h | ? ?7 +++++--
?arch/arm/mm/init.c ? ? ? ? ? ?| ? 20 +++++++++++++-------

?3 files changed, 22 insertions(+), 12 deletions(-)

arch/arm/include/asm/dma.h +0 -0
index 4200554..1d34c11 100644
@@ -6,10 +6,11 @@

?/*
?* This is the maximum virtual address which can be DMA'd from. ?*/

arch/arm/include/asm/dma.h +2 -2
-#ifndef ARM_DMA_ZONE_SIZE
-#define MAX_DMA_ADDRESS ? ? ? ?0xffffffff
+#ifndef CONFIG_ZONE_DMA
+#define MAX_DMA_ADDRESS ? ? ? ?0xffffffffUL

?#else

arch/arm/include/asm/dma.h +2 -1
-#define MAX_DMA_ADDRESS ? ? ? ?(PAGE_OFFSET + ARM_DMA_ZONE_SIZE)
+extern unsigned long arm_dma_zone_size;
+#define MAX_DMA_ADDRESS ? ? ? ?(PAGE_OFFSET + arm_dma_zone_size)

?#endif

?#ifdef CONFIG_ISA_DMA_API

arch/arm/include/asm/memory.h +0 -0
index af44a8f..deb2eaa 100644
@@ -209,10 +209,13 @@ 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. ?*/

arch/arm/include/asm/memory.h +1 -1
-#ifndef ARM_DMA_ZONE_SIZE
+#ifndef CONFIG_ZONE_DMA

?#define ISA_DMA_THRESHOLD ? ? ?(0xffffffffULL)
?#else

arch/arm/include/asm/memory.h +4 -1
-#define ISA_DMA_THRESHOLD ? ? ?(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
+#define ISA_DMA_THRESHOLD ? ? ?({ \
+ ? ? ? extern unsigned long arm_dma_zone_size; \
+ ? ? ? arm_dma_zone_size ? \
+ ? ? ? ? ? ? ? (PHYS_OFFSET + arm_dma_zone_size - 1) : 0xffffffffULL; })

?#endif

?/*

arch/arm/mm/init.c +0 -0
index c19571c..a14caff 100644
@@ -34,6 +34,15 @@
 

?#include "mm.h"

arch/arm/mm/init.c +9 -0
+#ifdef CONFIG_ZONE_DMA
+#ifdef ARM_DMA_ZONE_SIZE
+unsigned long arm_dma_zone_size = ARM_DMA_ZONE_SIZE;
+#else
+unsigned long arm_dma_zone_size __read_mostly;
+#endif
+EXPORT_SYMBOL(arm_dma_zone_size);
+#endif
+

?static unsigned long phys_initrd_start __initdata = 0; ?static unsigned long phys_initrd_size __initdata = 0;

arch/arm/mm/init.c +0 -0
@@ -267,17 +276,14 @@ static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,

?#endif
? ? ? ?}

arch/arm/mm/init.c +1 -5
-#ifdef ARM_DMA_ZONE_SIZE
-#ifndef CONFIG_ZONE_DMA
-#error ARM_DMA_ZONE_SIZE set but no DMA zone to limit allocations
-#endif
-
+#ifdef CONFIG_ZONE_DMA

? ? ? ?/*
? ? ? ? * Adjust the sizes according to any special requirements for ? ? ? ? * this machine type.
? ? ? ? */
- ? ? ? arm_adjust_dma_zone(zone_size, zhole_size,
- ? ? ? ? ? ? ? ARM_DMA_ZONE_SIZE >> PAGE_SHIFT);
+ ? ? ? if (arm_dma_zone_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); --
1.7.4

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#17 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 10 lines · Barry Song

2011/7/6 Nicolas Pitre <[email protected]>:

Quoted 6 lines

Having this value defined at compile time prevents multiple machines with conflicting definitions to coexist. ?Move it to a variable in preparation for having a per machine value selected at run time. ?This is relevant only when CONFIG_ZONE_DMA is selected.

that is definitely good. i am not sure whether it will be better if dma zone becomes a property in memory node of DT.

Certainly. But one thing at a time. This is the first step. Then, those machines that are converted to DT could more easily provide the information via this mechanism if they so desire.

Nicolas

#18 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 8 lines · Nicolas Pitre
Quoted 6 lines · Barry Song

2011/7/6 Nicolas Pitre <[email protected]>:

Quoted 5 lines

Having this value defined at compile time prevents multiple machines with conflicting definitions to coexist. ?Move it to a variable in preparation for having a per machine value selected at run time. ?This is relevant only when CONFIG_ZONE_DMA is selected.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

that is definitely good. i am not sure whether it will be better if dma zone becomes a property in memory node of DT.

Certainly. But one thing at a time. This is the first step. Then, those machines that are converted to DT could more easily provide the information via this mechanism if they so desire.

Actually, putting that information into DT is probably not right - you're describing something which is specific to Linux, not something which is due to hardware.

What I mean is that the DMA zone is a Linux specific thing. Another OS could have a different way of dealing with the DMA restrictions (it may be possible to allocate memory within a certain set of bounds.)

What is hardware specific is that the DMA devices can only address a limited range of memory. IMHO it's that which should be described in DT, not that we'll have a DMA zone of X bytes in size.

#19 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 22 lines · Russell King - ARM Linux
Quoted 8 lines · Nicolas Pitre
Quoted 6 lines · Barry Song

2011/7/6 Nicolas Pitre <[email protected]>:

Quoted 5 lines

Having this value defined at compile time prevents multiple machines with conflicting definitions to coexist. ?Move it to a variable in preparation for having a per machine value selected at run time. ?This is relevant only when CONFIG_ZONE_DMA is selected.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

that is definitely good. i am not sure whether it will be better if dma zone becomes a property in memory node of DT.

Certainly. But one thing at a time. This is the first step. Then, those machines that are converted to DT could more easily provide the information via this mechanism if they so desire.

Actually, putting that information into DT is probably not right - you're describing something which is specific to Linux, not something which is due to hardware.

Quoted 7 lines

What I mean is that the DMA zone is a Linux specific thing. Another OS could have a different way of dealing with the DMA restrictions (it may be possible to allocate memory within a certain set of bounds.)

What is hardware specific is that the DMA devices can only address a limited range of memory. IMHO it's that which should be described in DT, not that we'll have a DMA zone of X bytes in size.

I think that we all agree on the principle. I certainly never intended to suggest that the DMA zone size be stored as is in the device tree.

Nicolas

#20 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 6 lines · Nicolas Pitre
Quoted 3 lines

What is hardware specific is that the DMA devices can only address a limited range of memory. IMHO it's that which should be described in DT, not that we'll have a DMA zone of X bytes in size.

I think that we all agree on the principle. I certainly never intended to suggest that the DMA zone size be stored as is in the device tree.

There is a way to specify DMA address ranges in the device tree, though I forgot the exact format. It comes down to saying the device sees memory range XXX to YYY as its local address AAA to BBB. We could use that information at boot time to determine what the largest range of memory is that is visible by all devices (and hope that it's at the start of physical memory).

Arnd

#21 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 6 lines

-----Original Message-----
From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux-arm- kernel-bounces at lists.infradead.org] On Behalf Of Arnd Bergmann
Sent: Thursday, July 07, 2011 10:17 AM
To: linux-arm-kernel at lists.infradead.org
Cc: Nicolas Pitre; grant.likely at secretlab.ca; Russell King - ARM

Linux;

Quoted 5 lines

Barry Song
Subject: Re: [PATCH 01/10] ARM: change ARM_DMA_ZONE_SIZE into a variable

On Thursday 07 July 2011, Nicolas Pitre wrote:

Quoted 9 lines
Quoted 1 line
Quoted 1 line

What is hardware specific is that the DMA devices can only address

a

Quoted 1 line
Quoted 1 line

limited range of memory. IMHO it's that which should be described

in

Quoted 3 lines
Quoted 1 line

DT, not that we'll have a DMA zone of X bytes in size.

I think that we all agree on the principle. I certainly never

intended

Quoted 1 line

to suggest that the DMA zone size be stored as is in the device

tree.

Quoted 2 lines

There is a way to specify DMA address ranges in the device tree,

though

Quoted 5 lines

I forgot the exact format. It comes down to saying the device sees memory range XXX to YYY as its local address AAA to BBB. We could use that information at boot time to determine what the largest range of memory is that is visible by all devices (and hope that it's at the start of physical memory).

If I'm following this right....

We have a hole at the start of physical memory (when it's at 0) so that DMA can't DMA into it. Sounds like that won't work for us?

Thanks,
John

Quoted 7 lines

Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#22 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 8 lines · On Thursday 07 July 2011 19:08:38 John Linn wrote:
Quoted 1 line

There is a way to specify DMA address ranges in the device tree,

though

Quoted 5 lines

I forgot the exact format. It comes down to saying the device sees memory range XXX to YYY as its local address AAA to BBB. We could use that information at boot time to determine what the largest range of memory is that is visible by all devices (and hope that it's at the start of physical memory).

Quoted 4 lines

If I'm following this right....

We have a hole at the start of physical memory (when it's at 0) so that DMA can't DMA into it. Sounds like that won't work for us?

A whole in physical memory should not be a problem. It's only a problem if you have a device that can do DMA only to to some memory range that is not the start of your RAM, e.g. only the second 256MB but not the first.

Arnd

#23 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

In reply to John Linn
Quoted 4 lines · John Linn

If I'm following this right....

We have a hole at the start of physical memory (when it's at 0) so that DMA can't DMA into it. Sounds like that won't work for us?

That depends what you mean by that.

If you're saying that your physical RAM starts at some non-zero address, then that isn't a problem. We have lots of ARM platforms where that is true.

If you're saying that the first N MB of RAM can't be DMA'd to, then that is a problem as the kernel has no way to be told about that restriction. The best we can manage is to avoid freeing that memory into the normal allocation pools.

We do have a very small number of platforms where that's true, but we 'work around' that by having the kernel occupy that space. If N MB is less than sizeof(kernel) + 32K then you haven't lost much.

#24 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 5 lines

-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: Friday, July 08, 2011 3:00 AM
To: John Linn
Cc: Arnd Bergmann; linux-arm-kernel at lists.infradead.org; Nicolas

Pitre;

Quoted 8 lines

grant.likely at secretlab.ca; Barry Song
Subject: Re: [PATCH 01/10] ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 3 lines · John Linn

If I'm following this right....

We have a hole at the start of physical memory (when it's at 0) so

Quoted 8 lines

that

Quoted 1 line

DMA can't DMA into it. Sounds like that won't work for us?

That depends what you mean by that.

If you're saying that your physical RAM starts at some non-zero address,
then that isn't a problem. We have lots of ARM platforms where that

is

Quoted 8 lines

true.

If you're saying that the first N MB of RAM can't be DMA'd to, then that
is a problem as the kernel has no way to be told about that restriction.
The best we can manage is to avoid freeing that memory into the normal allocation pools.

Yes that is what I'm saying. Catalin and I had some conversation about this
previously (my apologies if I just didn't get it Catalin).

Quoted 4 lines

We do have a very small number of platforms where that's true, but we 'work around' that by having the kernel occupy that space. If N MB is less than sizeof(kernel) + 32K then you haven't lost much.

It's only at addresses 0 - 512K that's not DMA-able. I am using a DMA zone (with a hole at the front) to avoid this problem right now but maybe I'm not really understanding it and it's not working correctly. Testing looks good with the DMA zone.

I didn't like the other solution since we had to add another exception where the kernel frees it's memory (not to free it). But maybe this is really the right solution as Catalin had tried to explain to me.

Thanks for the input,
John

Please ignore any legal footer at the bottom of this email, this problem is still being worked.

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#25 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 4 lines · John Linn

It's only at addresses 0 - 512K that's not DMA-able. I am using a DMA zone (with a hole at the front) to avoid this problem right now but maybe I'm not really understanding it and it's not working correctly. Testing looks good with the DMA zone.

That's more or less what we do with Integrator platforms. It's very unlikely that a kernel will ever be smaller than 512K, so if you place it at 32K as normal, avoid freeing the .init text/data, and keep the first 32K reserved (the second 16K will be reserved for the swapper page table in any case) then you'll keep that memory away from anything that might hand it out for DMA purposes.

See free_initmem() for the integrator stuff avoiding .init freeing, and integrator_reserve() to keep the first 16K reserved.

#26 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann
Quoted 6 lines · Nicolas Pitre
Quoted 3 lines

What is hardware specific is that the DMA devices can only address a limited range of memory. IMHO it's that which should be described in DT, not that we'll have a DMA zone of X bytes in size.

I think that we all agree on the principle. I certainly never intended to suggest that the DMA zone size be stored as is in the device tree.

Quoted 6 lines

There is a way to specify DMA address ranges in the device tree, though I forgot the exact format. It comes down to saying the device sees memory range XXX to YYY as its local address AAA to BBB. We could use that information at boot time to determine what the largest range of memory is that is visible by all devices (and hope that it's at the start of physical memory).

It's called dma-ranges, and it has the same syntax as the ranges property. See section 2.3.9 on page 30 in ePAPR:

http://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf

This describes the hardware constraints, not the DMA zone size or any software decisions like that.

g.

#27 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

In reply to Nicolas Pitre
Quoted 2 lines · Nicolas Pitre
arch/arm/include/asm/dma.h +2 -0
+extern unsigned long arm_dma_zone_size;
+#define MAX_DMA_ADDRESS	(PAGE_OFFSET + arm_dma_zone_size)

...

arch/arm/include/asm/memory.h static inline unsigned long __phys_to_virt(unsigned long x) · line 218

Quoted 9 lines
arch/arm/include/asm/memory.h +5 -2
-#ifndef ARM_DMA_ZONE_SIZE
+#ifndef CONFIG_ZONE_DMA
 #define ISA_DMA_THRESHOLD	(0xffffffffULL)
 #else
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
+#define ISA_DMA_THRESHOLD	({ \
+	extern unsigned long arm_dma_zone_size; \
+	arm_dma_zone_size ? \
+		(PHYS_OFFSET + arm_dma_zone_size - 1) : 0xffffffffULL; })

These two usages do not agree. With unrestricted DMA, both MAX_DMA_ADDRESS and ISA_DMA_THRESHOLD should be 0xffffffff. However, you get that with arm_dma_zone_size=0 for ISA_DMA_THRESHOLD, which then gives a MAX_DMA_ADDRESS of PAGE_OFFSET. So this potentially changes the behaviour of these macros.

#28 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 4 lines · Russell King - ARM Linux
Quoted 2 lines · Nicolas Pitre
(quoted diff) +2 -0
+extern unsigned long arm_dma_zone_size;
+#define MAX_DMA_ADDRESS	(PAGE_OFFSET + arm_dma_zone_size)

...

Quoted 15 lines

Review

Quoted 9 lines
(quoted diff) +5 -2
-#ifndef ARM_DMA_ZONE_SIZE
+#ifndef CONFIG_ZONE_DMA
 #define ISA_DMA_THRESHOLD	(0xffffffffULL)
 #else
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
+#define ISA_DMA_THRESHOLD	({ \
+	extern unsigned long arm_dma_zone_size; \
+	arm_dma_zone_size ? \
+		(PHYS_OFFSET + arm_dma_zone_size - 1) : 0xffffffffULL; })

These two usages do not agree. With unrestricted DMA, both MAX_DMA_ADDRESS and ISA_DMA_THRESHOLD should be 0xffffffff. However, you get that with arm_dma_zone_size=0 for ISA_DMA_THRESHOLD, which then gives a MAX_DMA_ADDRESS of PAGE_OFFSET. So this potentially changes the behaviour of these macros.

Looking at what other architectures do, we have:

avr32, parisc, powerpc, sparc -> 0xffffffff

cris, frv, h8300, m68k, mips -> PAGE_OFFSET

microblaze, score, xtensa -> 0

So I wonder if this macro makes any sense when there is no DMA zone.

OTOH, since it is almost never used, it is best to make it behave like the original. Fixed tusly in my tree:

arch/arm/include/asm/dma.h +4 -2
index 1d34c11..fcf15de 100644
@@ -9,8 +9,10 @@
 #ifndef CONFIG_ZONE_DMA
 #define MAX_DMA_ADDRESS	0xffffffffUL
 #else
-extern unsigned long arm_dma_zone_size;
-#define MAX_DMA_ADDRESS	(PAGE_OFFSET + arm_dma_zone_size)
+#define MAX_DMA_ADDRESS	({ \
+	extern unsigned long arm_dma_zone_size; \
+	arm_dma_zone_size ? \
+		(PAGE_OFFSET + arm_dma_zone_size) : 0xffffffffUL; })
 #endif
 
 #ifdef CONFIG_ISA_DMA_API

Yet, excluding sound/oss/dmabuf.c, this is used by only 6 drivers in the whole tree which appear to be old ISA based drivers which would use a a DMA zone already. The exception is cs89x0.c, however MAX_DMA_ADDRESS is only used in the context of ISA DMA.

What is more worrisome is its usage in a few places in the mm code where it is always passed to __pa(). Certainly __pa(0xffffffff) is not going to produce sensible results.

One thing is for sure: ISA_DMA_THRESHOLD is not used anywhere in the whole tree except in arch/arm/mm/dma-mapping.c:get_coherent_dma_mask() and arch/arm/include/asm/dma-mapping.h:dma_supported() where its usage is certainly not ISA specific. Maybe this should be renamed?

Nicolas

#29 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 53 lines · Nicolas Pitre
Quoted 4 lines · Russell King - ARM Linux
Quoted 2 lines · Nicolas Pitre
(quoted diff) +2 -0
+extern unsigned long arm_dma_zone_size;
+#define MAX_DMA_ADDRESS	(PAGE_OFFSET + arm_dma_zone_size)

...

Quoted 15 lines

Review

Quoted 9 lines
(quoted diff) +5 -2
-#ifndef ARM_DMA_ZONE_SIZE
+#ifndef CONFIG_ZONE_DMA
 #define ISA_DMA_THRESHOLD	(0xffffffffULL)
 #else
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
+#define ISA_DMA_THRESHOLD	({ \
+	extern unsigned long arm_dma_zone_size; \
+	arm_dma_zone_size ? \
+		(PHYS_OFFSET + arm_dma_zone_size - 1) : 0xffffffffULL; })

These two usages do not agree. With unrestricted DMA, both MAX_DMA_ADDRESS and ISA_DMA_THRESHOLD should be 0xffffffff. However, you get that with arm_dma_zone_size=0 for ISA_DMA_THRESHOLD, which then gives a MAX_DMA_ADDRESS of PAGE_OFFSET. So this potentially changes the behaviour of these macros.

Looking at what other architectures do, we have:

avr32, parisc, powerpc, sparc -> 0xffffffff

cris, frv, h8300, m68k, mips -> PAGE_OFFSET

microblaze, score, xtensa -> 0

So I wonder if this macro makes any sense when there is no DMA zone.

OTOH, since it is almost never used, it is best to make it behave like the original. Fixed tusly in my tree:

arch/arm/include/asm/dma.h +4 -2
index 1d34c11..fcf15de 100644
@@ -9,8 +9,10 @@
 #ifndef CONFIG_ZONE_DMA
 #define MAX_DMA_ADDRESS	0xffffffffUL
 #else
-extern unsigned long arm_dma_zone_size;
-#define MAX_DMA_ADDRESS	(PAGE_OFFSET + arm_dma_zone_size)
+#define MAX_DMA_ADDRESS	({ \
+	extern unsigned long arm_dma_zone_size; \
+	arm_dma_zone_size ? \
+		(PAGE_OFFSET + arm_dma_zone_size) : 0xffffffffUL; })
 #endif
 
 #ifdef CONFIG_ISA_DMA_API
Quoted 4 lines

Yet, excluding sound/oss/dmabuf.c, this is used by only 6 drivers in the whole tree which appear to be old ISA based drivers which would use a a DMA zone already. The exception is cs89x0.c, however MAX_DMA_ADDRESS is only used in the context of ISA DMA.

Most drivers treat it as a virtual address, and it's used to determine whether a driver private bounce buffer needs to be used. Setting it to PAGE_OFFSET means that the bounce buffer will always be used. Setting it to all-ones means that the bounce buffer will never be used and some code will be optimized away. Intermediate settings means that we get run-time checks which aren't required on ARM platforms.

Quoted 3 lines

What is more worrisome is its usage in a few places in the mm code where it is always passed to __pa(). Certainly __pa(0xffffffff) is not going to produce sensible results.

The only real user there is bootmem, which hopefully will be killed off on ARM soon. In any case, I wouldn't worry about that at the moment because it's been that way for a long time and we haven't had any reports of badness from it.

Quoted 4 lines

One thing is for sure: ISA_DMA_THRESHOLD is not used anywhere in the whole tree except in arch/arm/mm/dma-mapping.c:get_coherent_dma_mask() and arch/arm/include/asm/dma-mapping.h:dma_supported() where its usage is certainly not ISA specific. Maybe this should be renamed?

It looks like ISA_DMA_THRESHOLD has become unused by most of the kernel, so yes, renaming it to "dma_zone_limit" would be more descriptive. We should probably make dma_supported() be out-of-line anyway (which then means that dma_zone_limit doesn't have to be exported to drivers) - and I think the DMA bounce stuff needs cleaning up in dma_set_mask().

#30 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 5 lines · Russell King - ARM Linux

It looks like ISA_DMA_THRESHOLD has become unused by most of the kernel, so yes, renaming it to "dma_zone_limit" would be more descriptive. We should probably make dma_supported() be out-of-line anyway (which then means that dma_zone_limit doesn't have to be exported to drivers) - and I think the DMA bounce stuff needs cleaning up in dma_set_mask().

... and I now have a patch which does this, pending testing. Once I've tested it I'll send it out.

#31 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

Quoted 9 lines · Russell King - ARM Linux
Quoted 5 lines · Russell King - ARM Linux

It looks like ISA_DMA_THRESHOLD has become unused by most of the kernel, so yes, renaming it to "dma_zone_limit" would be more descriptive. We should probably make dma_supported() be out-of-line anyway (which then means that dma_zone_limit doesn't have to be exported to drivers) - and I think the DMA bounce stuff needs cleaning up in dma_set_mask().

... and I now have a patch which does this, pending testing. Once I've tested it I'll send it out.

8<-----
From: Russell King <[email protected]>
ARM: dmabounce: simplify dma_set_mask()

Simplify the dmabounce specific code in dma_set_mask(). We can just omit setting the dma mask if dmabounce is enabled (we will have already set dma mask via callbacks when the device is created in that case.)

---
 arch/arm/include/asm/dma-mapping.h |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
arch/arm/include/asm/dma-mapping.h +2 -8
index 4ad2533..94662f4 100644
@@ -133,18 +133,12 @@ static inline int dma_supported(struct device *dev, u64 mask)
 
 static inline int dma_set_mask(struct device *dev, u64 dma_mask)
 {
-#ifdef CONFIG_DMABOUNCE
-	if (dev->archdata.dmabounce) {
-		if (dma_mask >= ISA_DMA_THRESHOLD)
-			return 0;
-		else
-			return -EIO;
-	}
-#endif
 	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
 		return -EIO;
 
+#ifndef CONFIG_DMABOUNCE
 	*dev->dma_mask = dma_mask;
+#endif
 
 	return 0;
 }
Signature · 1 line
1.7.4.4
#32 lore raw

PATCH 1/10 ARM: change ARM_DMA_ZONE_SIZE into a variable

In reply to Russell King - ARM Linux
Quoted 9 lines · Russell King - ARM Linux
Quoted 5 lines · Russell King - ARM Linux

It looks like ISA_DMA_THRESHOLD has become unused by most of the kernel, so yes, renaming it to "dma_zone_limit" would be more descriptive. We should probably make dma_supported() be out-of-line anyway (which then means that dma_zone_limit doesn't have to be exported to drivers) - and I think the DMA bounce stuff needs cleaning up in dma_set_mask().

... and I now have a patch which does this, pending testing. Once I've tested it I'll send it out.

8<--------
From: Russell King - ARM Linux <[email protected]>
ARM: dma: replace ISA_DMA_THRESHOLD with a variable

ISA_DMA_THRESHOLD has been unused by non-arch code, so lets now get rid of it from ARM by replacing it with arm_dma_zone_mask. Move dma_supported() and dma_set_mask() out of line, and have dma_supported() check this new variable instead.

---
 arch/arm/include/asm/dma-mapping.h |   29 ++---------------------------
 arch/arm/include/asm/memory.h      |   12 ------------
 arch/arm/mm/dma-mapping.c          |   35 ++++++++++++++++++++++++++++++++---
 arch/arm/mm/init.c                 |   10 ++++++++++
 arch/arm/mm/mm.h                   |    6 ++++++
 5 files changed, 50 insertions(+), 42 deletions(-)
arch/arm/include/asm/dma-mapping.h +2 -27
index 94662f4..7a21d0b 100644
@@ -115,33 +115,8 @@ static inline void __dma_page_dev_to_cpu(struct page *page, unsigned long off,
 		___dma_page_dev_to_cpu(page, off, size, dir);
 }
 
-/*
- * Return whether the given device DMA address mask can be supported
- * properly.  For example, if your device can only drive the low 24-bits
- * during bus mastering, then you would pass 0x00ffffff as the mask
- * to this function.
- *
- * FIXME: This should really be a platform specific issue - we should
- * return false if GFP_DMA allocations may not satisfy the supplied 'mask'.
- */
-static inline int dma_supported(struct device *dev, u64 mask)
-{
-	if (mask < ISA_DMA_THRESHOLD)
-		return 0;
-	return 1;
-}
-
-static inline int dma_set_mask(struct device *dev, u64 dma_mask)
-{
-	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
-		return -EIO;
-
-#ifndef CONFIG_DMABOUNCE
-	*dev->dma_mask = dma_mask;
-#endif
-
-	return 0;
-}
+extern int dma_supported(struct device *, u64);
+extern int dma_set_mask(struct device *, u64);
 
 /*
  * DMA errors are defined by all-bits-set in the DMA address.
arch/arm/include/asm/memory.h +0 -12
index af44a8f..b8de516 100644
@@ -204,18 +204,6 @@ static inline unsigned long __phys_to_virt(unsigned long x)
 #endif
 
 /*
- * The DMA mask corresponding to the maximum bus address allocatable
- * using GFP_DMA.  The default here places no restriction on DMA
- * allocations.  This must be the smallest DMA mask in the system,
- * so a successful GFP_DMA allocation will always satisfy this.
- */
-#ifndef ARM_DMA_ZONE_SIZE
-#define ISA_DMA_THRESHOLD	(0xffffffffULL)
-#else
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
-#endif
-
-/*
  * PFNs are used to describe any physical page; this means
  * PFN 0 == physical address 0.
  *
arch/arm/mm/dma-mapping.c +32 -3
index 82a093c..0a0a1e7 100644
@@ -25,9 +25,11 @@
 #include <asm/tlbflush.h>
 #include <asm/sizes.h>
 
+#include "mm.h"
+
 static u64 get_coherent_dma_mask(struct device *dev)
 {
-	u64 mask = ISA_DMA_THRESHOLD;
+	u64 mask = (u64)arm_dma_limit;
 
 	if (dev) {
 		mask = dev->coherent_dma_mask;
@@ -41,10 +43,10 @@ static u64 get_coherent_dma_mask(struct device *dev)
 			return 0;
 		}
 
-		if ((~mask) & ISA_DMA_THRESHOLD) {
+		if ((~mask) & (u64)arm_dma_limit) {
 			dev_warn(dev, "coherent DMA mask %#llx is smaller "
 				 "than system GFP_DMA mask %#llx\n",
-				 mask, (unsigned long long)ISA_DMA_THRESHOLD);
+				 mask, (u64)arm_dma_limit);
 			return 0;
 		}
 	}
@@ -657,6 +659,33 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
 }
 EXPORT_SYMBOL(dma_sync_sg_for_device);
 
+/*
+ * Return whether the given device DMA address mask can be supported
+ * properly.  For example, if your device can only drive the low 24-bits
+ * during bus mastering, then you would pass 0x00ffffff as the mask
+ * to this function.
+ */
+int dma_supported(struct device *dev, u64 mask)
+{
+	if (mask < (u64)arm_dma_limit)
+		return 0;
+	return 1;
+}
+EXPORT_SYMBOL(dma_supported);
+
+int dma_set_mask(struct device *dev, u64 dma_mask)
+{
+	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
+		return -EIO;
+
+#ifndef CONFIG_DMABOUNCE
+	*dev->dma_mask = dma_mask;
+#endif
+
+	return 0;
+}
+EXPORT_SYMBOL(dma_set_mask);
+
 #define PREALLOC_DMA_DEBUG_ENTRIES	4096
 
 static int __init dma_debug_do_init(void)
arch/arm/mm/init.c +10 -0
index c19571c..b9efa18 100644
@@ -212,6 +212,14 @@ static void __init arm_bootmem_init(unsigned long start_pfn,
 }
 
 #ifdef CONFIG_ZONE_DMA
+/*
+ * The DMA mask corresponding to the maximum bus address allocatable
+ * using GFP_DMA.  The default here places no restriction on DMA
+ * allocations.  This must be the smallest DMA mask in the system,
+ * so a successful GFP_DMA allocation will always satisfy this.
+ */
+u32 arm_dma_zone_size;
+
 static void __init arm_adjust_dma_zone(unsigned long *size, unsigned long *hole,
 	unsigned long dma_size)
 {
@@ -278,6 +286,8 @@ static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,
 	 */
 	arm_adjust_dma_zone(zone_size, zhole_size,
 		ARM_DMA_ZONE_SIZE >> PAGE_SHIFT);
+
+	arm_dma_limit = PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1;
 #endif
 
 	free_area_init_node(0, zone_size, min, zhole_size);
arch/arm/mm/mm.h +6 -0
index 5b3d7d5..0105667 100644
@@ -23,5 +23,11 @@ extern void __flush_dcache_page(struct address_space *mapping, struct page *page
 
 #endif
 
+#ifdef CONFIG_ZONE_DMA
+extern u32 arm_dma_limit;
+#else
+#define arm_dma_limit ((u32)~0)
+#endif
+
 void __init bootmem_init(void);
 void arm_mm_memblock_reserve(void);
Signature · 1 line
1.7.4.4