From: Cho KyongHo Date: Mon, 15 Oct 2018 04:47:18 +0000 (+0900) Subject: [RAMEN9610-10855] android: ion: fix missing alignment for CMA heap X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8a4fb9f40f0f82670a43bec73551e3e777295f6e;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [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 --- 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);