Skip to content

Commit

Permalink
mm: cma: Always consider a 0 base address reservation as dynamic
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Laurent Pinchart authored and mszyprow committed Oct 27, 2014
1 parent f022d8c commit 800a85d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mm/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ int __init cma_declare_contiguous(phys_addr_t base,
size = ALIGN(size, alignment);
limit &= ~(alignment - 1);

if (!base)
fixed = false;

/* size should be aligned with order_per_bit */
if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
return -EINVAL;
Expand All @@ -268,7 +271,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
}

/* Reserve memory */
if (base && fixed) {
if (fixed) {
if (memblock_is_region_reserved(base, size) ||
memblock_reserve(base, size) < 0) {
ret = -EBUSY;
Expand Down

0 comments on commit 800a85d

Please sign in to comment.