arm: dma-mapping: support DMA_ATTR_ALLOC_EXACT_SIZE
Vandana Salve [Thu, 21 Nov 2013 11:18:20 +0000 (16:18 +0530)]
This new attribute can handle allocation & release of
memory of exact sizes by making call to attr version
of dma_alloc_from_coherent/dma_release_from_coherent

bug 1380639

Change-Id: I2af8c8131ff552ae5e0ac3a628139318b3395a73
Signed-off-by: Vandana Salve <vsalve@nvidia.com>
Reviewed-on: http://git-master/r/334000
Reviewed-by: Hiroshi Doyu <hdoyu@nvidia.com>
Tested-by: Hiroshi Doyu <hdoyu@nvidia.com>

arch/arm/mm/dma-mapping.c

index 665e5c1..713ec2e 100644 (file)
@@ -696,7 +696,8 @@ void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
        pgprot_t prot = __get_dma_pgprot(attrs, pgprot_kernel);
        void *memory;
 
-       if (dma_alloc_from_coherent(dev, size, handle, &memory))
+       if (dma_alloc_from_coherent_attr(dev, size, handle,
+                       &memory, attrs))
                return memory;
 
        return __dma_alloc(dev, size, handle, gfp, prot, false,
@@ -709,8 +710,9 @@ static void *arm_coherent_dma_alloc(struct device *dev, size_t size,
        pgprot_t prot = __get_dma_pgprot(attrs, pgprot_kernel);
        void *memory;
 
-       if (dma_alloc_from_coherent(dev, size, handle, &memory))
-               return memory;
+       if (dma_alloc_from_coherent_attr(dev, size, handle,
+                       &memory, attrs))
+                       return memory;
 
        return __dma_alloc(dev, size, handle, gfp, prot, true,
                           __builtin_return_address(0));
@@ -755,7 +757,7 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
 {
        struct page *page = pfn_to_page(dma_to_pfn(dev, handle));
 
-       if (dma_release_from_coherent(dev, get_order(size), cpu_addr))
+       if (dma_release_from_coherent_attr(dev, size, cpu_addr, attrs))
                return;
 
        size = PAGE_ALIGN(size);