]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
Xilinx: ARM: Adding DMA zone to avoid DMA into lower 512K
authorJohn Linn <john.linn@xilinx.com>
Thu, 2 Jun 2011 21:20:04 +0000 (15:20 -0600)
committerJohn Linn <john.linn@xilinx.com>
Wed, 15 Jun 2011 19:37:34 +0000 (13:37 -0600)
The lower 512K of memory can not be DMAed into. A new
memory zone is added with a hole in the lower memory to
avoid this memory.

We were previously able to see an issue with USB when copying
a large file to the USB memory stick and some debug showed
that some buffers were coming from lower memory. When the
kernel releases init memory which is low this is possible.

arch/arm/Kconfig
arch/arm/mach-xilinx/include/mach/memory.h
arch/arm/mach-xilinx/xilinx.c

index cc1581931b89f674de55e5ed1a3e30a044ee8556..14af6b7c48a1cbdc9c56b4e6732957c86c9fcff2 100644 (file)
@@ -878,6 +878,7 @@ config ARCH_XILINX
        select ARM_AMBA
        select ISA_DMA_API
        select ARCH_REQUIRE_GPIOLIB
+       select ZONE_DMA
        help
          Support for Xilinx FPGAs with Cortex A9 based processors
 
index 6d472ecec8eed5939c496c7f6404f79414ad9bf4..e5b018561568a8791214fdacab8e4df9b345d7ac 100644 (file)
 
 #include <mach/hardware.h>
 
+#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA)
+extern void xilinx_adjust_zones(unsigned long *, unsigned long *);
+#define arch_adjust_zones(size, holes) \
+       xilinx_adjust_zones(size, holes)
+#endif
+
 /*
  * Virtual view <-> DMA view memory address translations
  * This macro is used to translate the virtual address to an address
index a6a17282ec715b98a82ab3291587930f06d8725d..c32ea61579e4ef43c9a8cb0bc8d01c505b8ee58e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/mmzone.h>
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -165,6 +166,35 @@ static struct of_device_id xilinx_of_bus_ids[] __initdata = {
         {}
 };
 
+#define DMA_ZONE_PAGES                 (SZ_32M >> PAGE_SHIFT)
+#define DMA_ZONE_HOLE_PAGES    (SZ_512K >> PAGE_SHIFT)
+
+/* Setup a special DMA memory zone to deal with the fact the from 0 - 512K cannot
+ * be DMA-ed into. The size of the DMA zone is a bit arbitrary but doesn't hurt to
+ * be larger as the memory allocator will use the DMA zone for normal if needed.
+ */
+void xilinx_adjust_zones(unsigned long *zone_size, unsigned long *zhole_size)
+{
+       /* the normal zone has already been setup when this function is called and is
+        * assumed to be the only zone, this code is a bit confusing
+        */
+
+       printk("Xilinx: Adjusting memory zones to add DMA zone\n");
+
+       /* setup the zone sizes reducing the normal zone by the size
+        * of the DMA zone
+        */
+       zone_size[ZONE_NORMAL] = zone_size[0] - DMA_ZONE_PAGES;
+       zone_size[ZONE_DMA] = DMA_ZONE_PAGES;
+
+       /* setup the holes in each zone, the normal zone has the same hole it had
+        * on entry to this function which should be no hole
+        * the dma zone has a hole where DMA can't be done
+        */
+       zhole_size[ZONE_NORMAL] = zhole_size[0];
+       zhole_size[ZONE_DMA] = DMA_ZONE_HOLE_PAGES;     
+}
+
 static void __init board_init(void)
 {
 #ifdef CONFIG_CACHE_L2X0