From c11b3c06ea0e747388af42f5f00f4215b33a4c5e Mon Sep 17 00:00:00 2001 From: CMY Date: Thu, 20 Mar 2014 10:30:01 +0800 Subject: [PATCH] rk: ion: judge __GFP_ZERO flag to decide whether to call __dma_clear_buffer in the __alloc_from_contiguous function --- arch/arm/mm/dma-mapping.c | 13 +++++++------ drivers/staging/android/ion/ion_cma_heap.c | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) mode change 100644 => 100755 arch/arm/mm/dma-mapping.c diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c old mode 100644 new mode 100755 index ef3e0f3aac96..6e8952bcbc0e --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -255,7 +255,7 @@ static void __dma_free_buffer(struct page *page, size_t size) static void *__alloc_from_contiguous(struct device *dev, size_t size, pgprot_t prot, struct page **ret_page, - const void *caller); + int clean, const void *caller); static void *__alloc_remap_buffer(struct device *dev, size_t size, gfp_t gfp, pgprot_t prot, struct page **ret_page, @@ -360,7 +360,7 @@ static int __init atomic_pool_init(void) if (IS_ENABLED(CONFIG_CMA)) ptr = __alloc_from_contiguous(NULL, pool->size, prot, &page, - atomic_pool_init); + 1, atomic_pool_init); else ptr = __alloc_remap_buffer(NULL, pool->size, gfp, prot, &page, atomic_pool_init); @@ -557,7 +557,7 @@ static int __free_from_pool(void *start, size_t size) static void *__alloc_from_contiguous(struct device *dev, size_t size, pgprot_t prot, struct page **ret_page, - const void *caller) + int clean, const void *caller) { unsigned long order = get_order(size); size_t count = size >> PAGE_SHIFT; @@ -568,7 +568,8 @@ static void *__alloc_from_contiguous(struct device *dev, size_t size, if (!page) return NULL; - __dma_clear_buffer(page, size); + if (clean) + __dma_clear_buffer(page, size); if (PageHighMem(page)) { ptr = __dma_alloc_remap(page, size, GFP_KERNEL, prot, caller); @@ -611,7 +612,7 @@ static inline pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot) #define __get_dma_pgprot(attrs, prot) __pgprot(0) #define __alloc_remap_buffer(dev, size, gfp, prot, ret, c) NULL #define __alloc_from_pool(size, ret_page) NULL -#define __alloc_from_contiguous(dev, size, prot, ret, c) NULL +#define __alloc_from_contiguous(dev, size, prot, ret, clean, c) NULL #define __free_from_pool(cpu_addr, size) 0 #define __free_from_contiguous(dev, page, cpu_addr, size) do { } while (0) #define __dma_free_remap(cpu_addr, size) do { } while (0) @@ -673,7 +674,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, else if (!IS_ENABLED(CONFIG_CMA)) addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller); else - addr = __alloc_from_contiguous(dev, size, prot, &page, caller); + addr = __alloc_from_contiguous(dev, size, prot, &page, !!(gfp & __GFP_ZERO), caller); if (addr) *handle = pfn_to_dma(dev, page_to_pfn(page)); diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index bd606ca4eb80..2bd0bac988f3 100755 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -86,7 +86,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, if (!ION_IS_CACHED(flags)) { info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle), - GFP_HIGHUSER | __GFP_ZERO); + GFP_HIGHUSER/* | __GFP_ZERO*/); } else { info->cpu_addr = dma_alloc_nonconsistent(dev, len, &(info->handle), GFP_HIGHUSER | __GFP_ZERO/*0*/); -- 2.34.1