From b2deb61a8a83d11e2c347062c70bd9373453c483 Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Mon, 15 Oct 2018 13:47:18 +0900 Subject: [PATCH] [RAMEN9610-10855] android: ion: fix missing alignment for CMA heap CMA heap may have special alignment requirement but alignment to the buffer allocation was missing for buffer length. Alignment to the base address is correctly performed, by the way. Change-Id: Ida598ac599e15f825c888aaa93aa5f5e6a2f248a Signed-off-by: Cho KyongHo --- drivers/staging/android/ion/ion_cma_heap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index ffb1c9e65274..699194bf30a3 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -47,8 +47,8 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, struct sg_table *table; struct page *pages; unsigned long size = PAGE_ALIGN(len); - unsigned long nr_pages = size >> PAGE_SHIFT; unsigned long align = cma_heap->align_order; + unsigned long nr_pages = ALIGN(size >> PAGE_SHIFT, 1 << align); bool cacheflush = !(flags & ION_FLAG_CACHED) || ((flags & ION_FLAG_SYNC_FORCE) != 0); bool protected = cma_heap->secure && (flags & ION_FLAG_PROTECTED); @@ -127,7 +127,8 @@ static void ion_cma_free(struct ion_buffer *buffer) struct ion_cma_heap *cma_heap = to_cma_heap(buffer->heap); bool protected = cma_heap->secure && (buffer->flags & ION_FLAG_PROTECTED); - unsigned long nr_pages = PAGE_ALIGN(buffer->size) >> PAGE_SHIFT; + unsigned long nr_pages = ALIGN(PAGE_ALIGN(buffer->size) >> PAGE_SHIFT, + 1 << cma_heap->align_order); if (protected) ion_buffer_unprotect(buffer->priv_virt); -- 2.20.1