]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mm: cma: align to physical address, not CMA region position
authorGregory Fong <gregory.0xf0@gmail.com>
Sat, 13 Dec 2014 00:54:48 +0000 (16:54 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 2 Sep 2017 05:05:45 +0000 (07:05 +0200)
commit3c61cc0ec1c20f75f39fabe17ee2dd21dffe3435
tree063893e824a5ad29d5ee57dd4cf0746977e2947b
parentfa69da4573fe24e83c3a773069aae5651f6747c6
mm: cma: align to physical address, not CMA region position

commit b5be83e308f70e16c63c4e520ea7bb03ef57c46f upstream.

The alignment in cma_alloc() was done w.r.t. the bitmap.  This is a
problem when, for example:

- a device requires 16M (order 12) alignment
- the CMA region is not 16 M aligned

In such a case, can result with the CMA region starting at, say,
0x2f800000 but any allocation you make from there will be aligned from
there.  Requesting an allocation of 32 M with 16 M alignment will result
in an allocation from 0x2f800000 to 0x31800000, which doesn't work very
well if your strange device requires 16M alignment.

Change to use bitmap_find_next_zero_area_off() to account for the
difference in alignment at reserve-time and alloc-time.

Signed-off-by: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/cma.c