lightnvm: free memory when gennvm register fails
[firefly-linux-kernel-4.4.55.git] / drivers / of / of_reserved_mem.c
index 49703916a30e04a0aadb67cea0d6ccce71d68f4e..be77e75c587db95c55a51e556f228f97810e051c 100644 (file)
@@ -124,6 +124,10 @@ static int __init __reserved_mem_alloc_size(unsigned long node,
                align = dt_mem_next_cell(dt_root_addr_cells, &prop);
        }
 
+       /* Need adjust the alignment to satisfy the CMA requirement */
+       if (IS_ENABLED(CONFIG_CMA) && of_flat_dt_is_compatible(node, "shared-dma-pool"))
+               align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order));
+
        prop = of_get_flat_dt_prop(node, "alloc-ranges", &len);
        if (prop) {