linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: Align CMA sizes to PAGE_SIZE
@ 2014-02-01  0:23 Laura Abbott
  2014-02-04 18:00 ` Catalin Marinas
  0 siblings, 1 reply; 2+ messages in thread
From: Laura Abbott @ 2014-02-01  0:23 UTC (permalink / raw)
  To: linux-arm-kernel

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 <will.deacon@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
---
 arch/arm64/mm/dma-mapping.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 864b256..be2696e 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -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)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] arm64: Align CMA sizes to PAGE_SIZE
  2014-02-01  0:23 [PATCH] arm64: Align CMA sizes to PAGE_SIZE Laura Abbott
@ 2014-02-04 18:00 ` Catalin Marinas
  0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2014-02-04 18:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Feb 01, 2014 at 12:23:54AM +0000, Laura Abbott wrote:
> 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 <will.deacon@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
> ---
>  arch/arm64/mm/dma-mapping.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
> index 864b256..be2696e 100644
> --- a/arch/arm64/mm/dma-mapping.c
> +++ b/arch/arm64/mm/dma-mapping.c
> @@ -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.

-- 
Catalin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-04 18:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-01  0:23 [PATCH] arm64: Align CMA sizes to PAGE_SIZE Laura Abbott
2014-02-04 18:00 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).