diff mbox

cma: fix limit adjustment in dma_declare_contiguous()

Message ID 1326142392-5060-1-git-send-email-mans.rullgard@linaro.org
State New
Headers show

Commit Message

Mans Rullgard Jan. 9, 2012, 8:53 p.m. UTC
The upper limit needs to be rounded down to a multiple of the
alignment, not up.

Signed-off-by: Mans Rullgard <mans.rullgard@linaro.org>
---
 drivers/base/dma-contiguous.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Marek Szyprowski Jan. 10, 2012, 9:51 a.m. UTC | #1
Hello,

On Monday, January 09, 2012 9:53 PM Mans Rullgard wrote:

> The upper limit needs to be rounded down to a multiple of the
> alignment, not up.
> 
> Signed-off-by: Mans Rullgard <mans.rullgard@linaro.org>

Thanks for spotting this issue! I will add this change to the next version of CMA patches.

> ---
>  drivers/base/dma-contiguous.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
> index 924c052..e10120f 100644
> --- a/drivers/base/dma-contiguous.c
> +++ b/drivers/base/dma-contiguous.c
> @@ -256,7 +256,7 @@ int __init dma_declare_contiguous(struct device *dev, unsigned long size,
>  	alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
>  	base = ALIGN(base, alignment);
>  	size = ALIGN(size, alignment);
> -	limit = ALIGN(limit, alignment);
> +	limit &= ~(alignment - 1);
> 
>  	/* Reserve memory */
>  	if (base) {
> --

Best regards
diff mbox

Patch

diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 924c052..e10120f 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -256,7 +256,7 @@  int __init dma_declare_contiguous(struct device *dev, unsigned long size,
 	alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
 	base = ALIGN(base, alignment);
 	size = ALIGN(size, alignment);
-	limit = ALIGN(limit, alignment);
+	limit &= ~(alignment - 1);
 
 	/* Reserve memory */
 	if (base) {