Merge tag 'sound-4.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[firefly-linux-kernel-4.4.55.git] / drivers / of / of_reserved_mem.c
index 62f467b8ccae940a931a2a08ce530a9a14f46a1f..1a3556a9e9ea126b451b2a3c68e0407135af242f 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) {
 
@@ -202,7 +206,13 @@ static int __init __rmem_cmp(const void *a, const void *b)
 {
        const struct reserved_mem *ra = a, *rb = b;
 
-       return ra->base - rb->base;
+       if (ra->base < rb->base)
+               return -1;
+
+       if (ra->base > rb->base)
+               return 1;
+
+       return 0;
 }
 
 static void __init __rmem_check_for_overlap(void)
@@ -226,10 +236,9 @@ static void __init __rmem_check_for_overlap(void)
 
                        this_end = this->base + this->size;
                        next_end = next->base + next->size;
-                       WARN(1,
-                            "Reserved memory: OVERLAP DETECTED!\n%s (%pa--%pa) overlaps with %s (%pa--%pa)\n",
-                            this->name, &this->base, &this_end,
-                            next->name, &next->base, &next_end);
+                       pr_err("Reserved memory: OVERLAP DETECTED!\n%s (%pa--%pa) overlaps with %s (%pa--%pa)\n",
+                              this->name, &this->base, &this_end,
+                              next->name, &next->base, &next_end);
                }
        }
 }