#define dmb() __asm__ __volatile__ ("" : : : "memory")
  #endif
  
- #if defined(CONFIG_ARM_DMA_MEM_BUFFERABLE) || defined(CONFIG_SMP)
- #define mb()          dmb()
+ #ifdef CONFIG_ARCH_HAS_BARRIERS
+ #include <mach/barriers.h>
 -#elif __LINUX_ARM_ARCH__ >= 7 || defined(CONFIG_SMP)
++#elif defined(CONFIG_ARM_DMA_MEM_BUFFERABLE) || defined(CONFIG_SMP)
+ #define mb()          do { dsb(); outer_sync(); } while (0)
  #define rmb()         dmb()
- #define wmb()         dmb()
+ #define wmb()         mb()
  #else
  #define mb()  do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
  #define rmb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
 
  config CACHE_L2X0
        bool "Enable the L2x0 outer cache controller"
        depends on REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP || MACH_REALVIEW_PB1176 || \
 -                 REALVIEW_EB_A9MP || ARCH_MX35 || ARCH_MX31 || MACH_REALVIEW_PBX || ARCH_NOMADIK || ARCH_OMAP4
 +                 REALVIEW_EB_A9MP || ARCH_MX35 || ARCH_MX31 || MACH_REALVIEW_PBX || \
 +                 ARCH_NOMADIK || ARCH_OMAP4 || ARCH_U8500 || ARCH_VEXPRESS_CA9X4
        default y
        select OUTER_CACHE
+       select OUTER_CACHE_SYNC
        help
          This option enables the L2x0 PrimeCell.
  
        default 6 if ARM_L1_CACHE_SHIFT_6
        default 5
  
 +config ARM_DMA_MEM_BUFFERABLE
 +      bool "Use non-cacheable memory for DMA" if CPU_V6 && !CPU_V7
 +      default y if CPU_V6 || CPU_V7
 +      help
 +        Historically, the kernel has used strongly ordered mappings to
 +        provide DMA coherent memory.  With the advent of ARMv7, mapping
 +        memory with differing types results in unpredictable behaviour,
 +        so on these CPUs, this option is forced on.
 +
 +        Multiple mappings with differing attributes is also unpredictable
 +        on ARMv6 CPUs, but since they do not have aggressive speculative
 +        prefetch, no harm appears to occur.
 +
 +        However, drivers may be missing the necessary barriers for ARMv6,
 +        and therefore turning this on may result in unpredictable driver
 +        behaviour.  Therefore, we offer this as an option.
 +
 +        You are recommended say 'Y' here and debug any affected drivers.
++
+ config ARCH_HAS_BARRIERS
+       bool
+       help
+         This option allows the use of custom mandatory barriers
+         included via the mach/barriers.h file.
 
        outer_cache.inv_range = l2x0_inv_range;
        outer_cache.clean_range = l2x0_clean_range;
        outer_cache.flush_range = l2x0_flush_range;
+       outer_cache.sync = l2x0_cache_sync;
  
 -      printk(KERN_INFO "L2X0 cache controller enabled\n");
 +      printk(KERN_INFO "%s cache controller enabled\n", type);
 +      printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x\n",
 +                       ways, cache_id, aux);
  }