Skip to contentSkip to conversation

arm64: Align CMA sizes to PAGE_SIZE

PATCH Superseded Laura Abbott 2 participants 2 messages Feb 1, 2014 – Feb 4, 2014 arm64

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: Align CMA sizes to PAGE_SIZE

dma_alloc_from_contiguous takes number of pages for a size. Align up the dma size passed in to page size to avoid truncation and allocation failures on sizes less than PAGE_SIZE.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
---
 arch/arm64/mm/dma-mapping.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm64/mm/dma-mapping.c +2 -0
index 864b256..be2696e 100644
@@ -44,6 +44,8 @@ static void *arm64_swiotlb_alloc_coherent(struct device *dev, size_t size,
 		flags |= GFP_DMA32;
 	if (IS_ENABLED(CONFIG_CMA)) {
 		unsigned long pfn;
+
+		size = PAGE_ALIGN(size);
 		pfn = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
 							get_order(size));
 		if (!pfn)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
maintainer
#1 lore raw

PATCH 1/1 arm64: Align CMA sizes to PAGE_SIZE

Quoted 16 lines · Laura Abbott

dma_alloc_from_contiguous takes number of pages for a size. Align up the dma size passed in to page size to avoid truncation and allocation failures on sizes less than PAGE_SIZE.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
---
 arch/arm64/mm/dma-mapping.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm64/mm/dma-mapping.c +0 -0
index 864b256..be2696e 100644

arch/arm64/mm/dma-mapping.c static void *arm64_swiotlb_alloc_coherent(struct device *dev, size_t size, · line 50

Quoted 7 lines
arch/arm64/mm/dma-mapping.c +2 -0
@@ -44,6 +44,8 @@ static void *arm64_swiotlb_alloc_coherent(struct device *dev, size_t size,
 		flags |= GFP_DMA32;
 	if (IS_ENABLED(CONFIG_CMA)) {
 		unsigned long pfn;
+
+		size = PAGE_ALIGN(size);
 		pfn = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
 							get_order(size));

The patch looks ok, but it doesn't apply. In my kernel (3.14-rc1), dma_alloc_from_contiguous returns a struct page.

Thanks.

Signature · 1 line
Catalin