The patch titled Subject: mm: cma: fix CMA aligned offset calculation has been added to the -mm tree. Its filename is mm-cma-fix-cma-aligned-offset-calculation.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-cma-fix-cma-aligned-offset-calculation.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-cma-fix-cma-aligned-offset-calculation.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Danesh Petigara <dpetigara@xxxxxxxxxxxx> Subject: mm: cma: fix CMA aligned offset calculation The CMA aligned offset calculation is incorrect for non-zero order_per_bit values. For example, if cma->order_per_bit=1, cma->base_pfn= 0x2f800000 and align_order=12, the function returns a value of 0x17c00 instead of 0x400. This patch fixes the CMA aligned offset calculation. Signed-off-by: Danesh Petigara <dpetigara@xxxxxxxxxxxx> Reviewed-by: Gregory Fong <gregory.0xf0@xxxxxxxxx> Acked-by: Michal Nazarewicz <mina86@xxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/cma.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff -puN mm/cma.c~mm-cma-fix-cma-aligned-offset-calculation mm/cma.c --- a/mm/cma.c~mm-cma-fix-cma-aligned-offset-calculation +++ a/mm/cma.c @@ -64,15 +64,17 @@ static unsigned long cma_bitmap_aligned_ return (1UL << (align_order - cma->order_per_bit)) - 1; } +/* + * Find a PFN aligned to the specified order and return an offset represented in + * order_per_bits. + */ static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order) { - unsigned int alignment; - if (align_order <= cma->order_per_bit) return 0; - alignment = 1UL << (align_order - cma->order_per_bit); - return ALIGN(cma->base_pfn, alignment) - - (cma->base_pfn >> cma->order_per_bit); + + return (ALIGN(cma->base_pfn, (1UL << align_order)) + - cma->base_pfn) >> cma->order_per_bit; } static unsigned long cma_bitmap_maxno(struct cma *cma) _ Patches currently in -mm which might be from dpetigara@xxxxxxxxxxxx are mm-cma-fix-cma-aligned-offset-calculation.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html