[RAMEN9610-10855] android: ion: fix missing alignment for CMA heap
authorCho KyongHo <pullip.cho@samsung.com>
Mon, 15 Oct 2018 04:47:18 +0000 (13:47 +0900)
committerhskang <hs1218.kang@samsung.com>
Tue, 15 Jan 2019 06:22:54 +0000 (15:22 +0900)
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 <pullip.cho@samsung.com>
drivers/staging/android/ion/ion_cma_heap.c

index ffb1c9e652749284a225d34c031213636de89ec2..699194bf30a3bcda0255240cbc537122b48a1404 100644 (file)
@@ -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);