Skip to content

Commit 1cc8e34

Browse files
LiuHui-Jasonrobherring
authored andcommitted
drivers: of: of_reserved_mem: fixup the alignment with CMA setup
There is an alignment mismatch issue between the of_reserved_mem and the CMA setup requirement. The of_reserved_mem will try to get the alignment value from the DTS and pass it to __memblock_alloc_base to do the memory block base allocation, but the alignment value specified in the DTS may not satisfy the CAM setup requirement since CMA setup required the alignment as the following in the code: align = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order); The sanity check in the function of rmem_cma_setup will fail if the alignment does not setup correctly and thus CMA will fail to setup. This patch is to fixup the alignment to meet the CMA setup required. Mailing-list-thread: https://lkml.org/lkml/2015/11/9/138 Signed-off-by: Jason Liu <r64343@freescale.com> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Grant Likely <grant.likely@linaro.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: stable@vger.kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 85a1c77 commit 1cc8e34

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/of/of_reserved_mem.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ static int __init __reserved_mem_alloc_size(unsigned long node,
124124
align = dt_mem_next_cell(dt_root_addr_cells, &prop);
125125
}
126126

127+
/* Need adjust the alignment to satisfy the CMA requirement */
128+
if (IS_ENABLED(CONFIG_CMA) && of_flat_dt_is_compatible(node, "shared-dma-pool"))
129+
align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order));
130+
127131
prop = of_get_flat_dt_prop(node, "alloc-ranges", &len);
128132
if (prop) {
129133

0 commit comments

Comments
 (0)