Merge remote-tracking branch 'dma-public/for-v3.12-cma-dma' into for-next
authorMarek Szyprowski <m.szyprowski@samsung.com>
Mon, 15 Jul 2013 09:13:54 +0000 (11:13 +0200)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Mon, 15 Jul 2013 09:13:54 +0000 (11:13 +0200)
Conflicts:
mm/Kconfig

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
1  2 
arch/arm/mm/dma-mapping.c
drivers/base/Kconfig
drivers/base/Makefile
mm/Kconfig

index 7f9b1798c6cf12f08e55496b27082722e16a30f3,1fb40dc37ec29555dd87209af87ef89e49169ad6..dbddc07a3bbd9abc6d2ba9169085457d4fc86dc5
@@@ -250,7 -250,7 +250,7 @@@ static void __dma_free_buffer(struct pa
  
  #ifdef CONFIG_MMU
  #ifdef CONFIG_HUGETLB_PAGE
 -#error ARM Coherent DMA allocator does not (yet) support huge TLB
 +#warning ARM Coherent DMA allocator does not (yet) support huge TLB
  #endif
  
  static void *__alloc_from_contiguous(struct device *dev, size_t size,
@@@ -358,7 -358,7 +358,7 @@@ static int __init atomic_pool_init(void
        if (!pages)
                goto no_pages;
  
-       if (IS_ENABLED(CONFIG_CMA))
+       if (IS_ENABLED(CONFIG_DMA_CMA))
                ptr = __alloc_from_contiguous(NULL, pool->size, prot, &page,
                                              atomic_pool_init);
        else
@@@ -670,7 -670,7 +670,7 @@@ static void *__dma_alloc(struct device 
                addr = __alloc_simple_buffer(dev, size, gfp, &page);
        else if (!(gfp & __GFP_WAIT))
                addr = __alloc_from_pool(size, &page);
-       else if (!IS_ENABLED(CONFIG_CMA))
+       else if (!IS_ENABLED(CONFIG_DMA_CMA))
                addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller);
        else
                addr = __alloc_from_contiguous(dev, size, prot, &page, caller);
@@@ -759,7 -759,7 +759,7 @@@ static void __arm_dma_free(struct devic
                __dma_free_buffer(page, size);
        } else if (__free_from_pool(cpu_addr, size)) {
                return;
-       } else if (!IS_ENABLED(CONFIG_CMA)) {
+       } else if (!IS_ENABLED(CONFIG_DMA_CMA)) {
                __dma_free_remap(cpu_addr, size);
                __dma_free_buffer(page, size);
        } else {
@@@ -880,24 -880,10 +880,24 @@@ static void __dma_page_dev_to_cpu(struc
        dma_cache_maint_page(page, off, size, dir, dmac_unmap_area);
  
        /*
 -       * Mark the D-cache clean for this page to avoid extra flushing.
 +       * Mark the D-cache clean for these pages to avoid extra flushing.
         */
 -      if (dir != DMA_TO_DEVICE && off == 0 && size >= PAGE_SIZE)
 -              set_bit(PG_dcache_clean, &page->flags);
 +      if (dir != DMA_TO_DEVICE && size >= PAGE_SIZE) {
 +              unsigned long pfn;
 +              size_t left = size;
 +
 +              pfn = page_to_pfn(page) + off / PAGE_SIZE;
 +              off %= PAGE_SIZE;
 +              if (off) {
 +                      pfn++;
 +                      left -= PAGE_SIZE - off;
 +              }
 +              while (left >= PAGE_SIZE) {
 +                      page = pfn_to_page(pfn++);
 +                      set_bit(PG_dcache_clean, &page->flags);
 +                      left -= PAGE_SIZE;
 +              }
 +      }
  }
  
  /**
@@@ -1328,15 -1314,6 +1328,15 @@@ static void *arm_iommu_alloc_attrs(stru
        if (gfp & GFP_ATOMIC)
                return __iommu_alloc_atomic(dev, size, handle);
  
 +      /*
 +       * Following is a work-around (a.k.a. hack) to prevent pages
 +       * with __GFP_COMP being passed to split_page() which cannot
 +       * handle them.  The real problem is that this flag probably
 +       * should be 0 on ARM as it is not supported on this
 +       * platform; see CONFIG_HUGETLBFS.
 +       */
 +      gfp &= ~(__GFP_COMP);
 +
        pages = __iommu_alloc_buffer(dev, size, gfp, attrs);
        if (!pages)
                return NULL;
@@@ -1395,17 -1372,16 +1395,17 @@@ static int arm_iommu_mmap_attrs(struct 
  void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr,
                          dma_addr_t handle, struct dma_attrs *attrs)
  {
 -      struct page **pages = __iommu_get_pages(cpu_addr, attrs);
 +      struct page **pages;
        size = PAGE_ALIGN(size);
  
 -      if (!pages) {
 -              WARN(1, "trying to free invalid coherent area: %p\n", cpu_addr);
 +      if (__in_atomic_pool(cpu_addr, size)) {
 +              __iommu_free_atomic(dev, cpu_addr, handle, size);
                return;
        }
  
 -      if (__in_atomic_pool(cpu_addr, size)) {
 -              __iommu_free_atomic(dev, cpu_addr, handle, size);
 +      pages = __iommu_get_pages(cpu_addr, attrs);
 +      if (!pages) {
 +              WARN(1, "trying to free invalid coherent area: %p\n", cpu_addr);
                return;
        }
  
@@@ -1660,27 -1636,13 +1660,27 @@@ static dma_addr_t arm_coherent_iommu_ma
  {
        struct dma_iommu_mapping *mapping = dev->archdata.mapping;
        dma_addr_t dma_addr;
 -      int ret, len = PAGE_ALIGN(size + offset);
 +      int ret, prot, len = PAGE_ALIGN(size + offset);
  
        dma_addr = __alloc_iova(mapping, len);
        if (dma_addr == DMA_ERROR_CODE)
                return dma_addr;
  
 -      ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, 0);
 +      switch (dir) {
 +      case DMA_BIDIRECTIONAL:
 +              prot = IOMMU_READ | IOMMU_WRITE;
 +              break;
 +      case DMA_TO_DEVICE:
 +              prot = IOMMU_READ;
 +              break;
 +      case DMA_FROM_DEVICE:
 +              prot = IOMMU_WRITE;
 +              break;
 +      default:
 +              prot = 0;
 +      }
 +
 +      ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot);
        if (ret < 0)
                goto fail;
  
@@@ -1945,7 -1907,7 +1945,7 @@@ void arm_iommu_detach_device(struct dev
  
        iommu_detach_device(mapping->domain, dev);
        kref_put(&mapping->kref, release_iommu_mapping);
 -      mapping = NULL;
 +      dev->archdata.mapping = NULL;
        set_dma_ops(dev, NULL);
  
        pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));
diff --combined drivers/base/Kconfig
index 5daa2599ed48d3fad44223dc904d0cfdc2cbad09,10cd80af2aecc7f2908eee0033c4d151c24b84c1..e373671652b0914c10f3237ada35998be9de7fcf
@@@ -2,6 -2,7 +2,6 @@@ menu "Generic Driver Options
  
  config UEVENT_HELPER_PATH
        string "path to uevent helper"
 -      depends on HOTPLUG
        default ""
        help
          Path to uevent helper program forked by the kernel for
@@@ -22,6 -23,7 +22,6 @@@
  
  config DEVTMPFS
        bool "Maintain a devtmpfs filesystem to mount at /dev"
 -      depends on HOTPLUG
        help
          This creates a tmpfs/ramfs filesystem instance early at bootup.
          In this filesystem, the kernel driver core maintains device
@@@ -200,11 -202,9 +200,9 @@@ config DMA_SHARED_BUFFE
          APIs extension; the file's descriptor can then be passed on to other
          driver.
  
- config CMA
-       bool "Contiguous Memory Allocator"
-       depends on HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK
-       select MIGRATION
-       select MEMORY_ISOLATION
+ config DMA_CMA
+       bool "DMA Contiguous Memory Allocator"
+       depends on HAVE_DMA_CONTIGUOUS && CMA
        help
          This enables the Contiguous Memory Allocator which allows drivers
          to allocate big physically-contiguous blocks of memory for use with
          For more information see <include/linux/dma-contiguous.h>.
          If unsure, say "n".
  
- if CMA
- config CMA_DEBUG
-       bool "CMA debug messages (DEVELOPMENT)"
-       depends on DEBUG_KERNEL
-       help
-         Turns on debug messages in CMA.  This produces KERN_DEBUG
-         messages for every CMA call as well as various messages while
-         processing calls such as dma_alloc_from_contiguous().
-         This option does not affect warning and error messages.
+ if  DMA_CMA
  comment "Default contiguous memory area size:"
  
  config CMA_SIZE_MBYTES
diff --combined drivers/base/Makefile
index 48029aa477d94b1c6b01fe90b367a9e77e2e5dfe,5d93bb519753b5047750748f2d2e6ae56d9ebf5a..94e8a80e87f87e545638f257ead04c56f73f088b
@@@ -6,11 -6,11 +6,11 @@@ obj-y                 := core.o bus.o dd.o syscore.o 
                           attribute_container.o transport_class.o \
                           topology.o
  obj-$(CONFIG_DEVTMPFS)        += devtmpfs.o
- obj-$(CONFIG_CMA) += dma-contiguous.o
+ obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
  obj-y                 += power/
  obj-$(CONFIG_HAS_DMA) += dma-mapping.o
  obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
 -obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o
 +obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o reservation.o
  obj-$(CONFIG_ISA)     += isa.o
  obj-$(CONFIG_FW_LOADER)       += firmware_class.o
  obj-$(CONFIG_NUMA)    += node.o
diff --combined mm/Kconfig
index 8028dcc6615c6bbd533adf060ea3d9db36b9a48c,26a5f815cfc38a0a20d9a1e742045929181c34fc..256bfd0f6007dc3e40e6575318d120554d06a49e
@@@ -173,7 -173,7 +173,7 @@@ config HAVE_BOOTMEM_INFO_NOD
  config MEMORY_HOTPLUG
        bool "Allow for memory hot-add"
        depends on SPARSEMEM || X86_64_ACPI_NUMA
 -      depends on HOTPLUG && ARCH_ENABLE_MEMORY_HOTPLUG
 +      depends on ARCH_ENABLE_MEMORY_HOTPLUG
        depends on (IA64 || X86 || PPC_BOOK3S_64 || SUPERH || S390)
  
  config MEMORY_HOTPLUG_SPARSE
@@@ -478,44 -478,26 +478,68 @@@ config FRONTSWA
  
          If unsure, say Y to enable frontswap.
  
 +config ZBUD
 +      tristate
 +      default n
 +      help
 +        A special purpose allocator for storing compressed pages.
 +        It is designed to store up to two compressed pages per physical
 +        page.  While this design limits storage density, it has simple and
 +        deterministic reclaim properties that make it preferable to a higher
 +        density approach when reclaim will be used.
 +
 +config ZSWAP
 +      bool "Compressed cache for swap pages (EXPERIMENTAL)"
 +      depends on FRONTSWAP && CRYPTO=y
 +      select CRYPTO_LZO
 +      select ZBUD
 +      default n
 +      help
 +        A lightweight compressed cache for swap pages.  It takes
 +        pages that are in the process of being swapped out and attempts to
 +        compress them into a dynamically allocated RAM-based memory pool.
 +        This can result in a significant I/O reduction on swap device and,
 +        in the case where decompressing from RAM is faster that swap device
 +        reads, can also improve workload performance.
 +
 +        This is marked experimental because it is a new feature (as of
 +        v3.11) that interacts heavily with memory reclaim.  While these
 +        interactions don't cause any known issues on simple memory setups,
 +        they have not be fully explored on the large set of potential
 +        configurations and workloads that exist.
 +
 +config MEM_SOFT_DIRTY
 +      bool "Track memory changes"
 +      depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY
 +      select PROC_PAGE_MONITOR
 +      help
 +        This option enables memory changes tracking by introducing a
 +        soft-dirty bit on pte-s. This bit it set when someone writes
 +        into a page just as regular dirty bit, but unlike the latter
 +        it can be cleared by hands.
 +
 +        See Documentation/vm/soft-dirty.txt for more details.
++
+ config CMA
+       bool "Contiguous Memory Allocator"
+       depends on HAVE_MEMBLOCK
+       select MIGRATION
+       select MEMORY_ISOLATION
+       help
+         This enables the Contiguous Memory Allocator which allows other
+         subsystems to allocate big physically-contiguous blocks of memory.
+         CMA reserves a region of memory and allows only movable pages to
+         be allocated from it. This way, the kernel can use the memory for
+         pagecache and when a subsystem requests for contiguous area, the
+         allocated pages are migrated away to serve the contiguous request.
+         If unsure, say "n".
+ config CMA_DEBUG
+       bool "CMA debug messages (DEVELOPMENT)"
+       depends on DEBUG_KERNEL && CMA
+       help
+         Turns on debug messages in CMA.  This produces KERN_DEBUG
+         messages for every CMA call as well as various messages while
+         processing calls such as dma_alloc_from_contiguous().
+         This option does not affect warning and error messages.