Skip to content

Commit 800a85d

Browse files
Laurent Pinchartmszyprow
authored andcommitted
mm: cma: Always consider a 0 base address reservation as dynamic
The fixed parameter to cma_declare_contiguous() tells the function whether the given base address must be honoured or should be considered as a hint only. The API considers a zero base address as meaning any base address, which must never be considered as a fixed value. Part of the implementation correctly checks both fixed and base != 0, but two locations check the fixed value only. Set fixed to false when base is 0 to fix that and simplify the code. Signed-off-by: Laurent Pinchart <[email protected]> Acked-by: Michal Nazarewicz <[email protected]> Signed-off-by: Marek Szyprowski <[email protected]>
1 parent f022d8c commit 800a85d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mm/cma.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ int __init cma_declare_contiguous(phys_addr_t base,
245245
size = ALIGN(size, alignment);
246246
limit &= ~(alignment - 1);
247247

248+
if (!base)
249+
fixed = false;
250+
248251
/* size should be aligned with order_per_bit */
249252
if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
250253
return -EINVAL;
@@ -268,7 +271,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
268271
}
269272

270273
/* Reserve memory */
271-
if (base && fixed) {
274+
if (fixed) {
272275
if (memblock_is_region_reserved(base, size) ||
273276
memblock_reserve(base, size) < 0) {
274277
ret = -EBUSY;

0 commit comments

Comments
 (0)