powerpc/lmb-size: Use addr #size-cells value when fetching lmb-size
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Wed, 7 Oct 2020 11:48:36 +0000 (17:18 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 8 Oct 2020 01:50:52 +0000 (12:50 +1100)
Make it consistent with other usages.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201007114836.282468-5-aneesh.kumar@linux.ibm.com
arch/powerpc/mm/book3s64/radix_pgtable.c
arch/powerpc/platforms/pseries/hotplug-memory.c

index 78c5afe9835982fe96292561a3ebf7a46c972b11..f8e9eb49d46bd31eeb946bac274e479af5bf651d 100644 (file)
@@ -498,7 +498,7 @@ static int __init probe_memory_block_size(unsigned long node, const char *uname,
                                          depth, void *data)
 {
        unsigned long *mem_block_size = (unsigned long *)data;
-       const __be64 *prop;
+       const __be32 *prop;
        int len;
 
        if (depth != 1)
@@ -508,13 +508,14 @@ static int __init probe_memory_block_size(unsigned long node, const char *uname,
                return 0;
 
        prop = of_get_flat_dt_prop(node, "ibm,lmb-size", &len);
-       if (!prop || len < sizeof(__be64))
+
+       if (!prop || len < dt_root_size_cells * sizeof(__be32))
                /*
                 * Nothing in the device tree
                 */
                *mem_block_size = MIN_MEMORY_BLOCK_SIZE;
        else
-               *mem_block_size = be64_to_cpup(prop);
+               *mem_block_size = of_read_number(prop, dt_root_size_cells);
        return 1;
 }
 
index ca5589a1ec7f6db9064f15fceb65c384bd46f3e6..4e18653a3804e19b4a7dbb80cdf949a58926a2ab 100644 (file)
@@ -30,12 +30,17 @@ unsigned long pseries_memory_block_size(void)
 
        np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
        if (np) {
-               const __be64 *size;
+               int len;
+               int size_cells;
+               const __be32 *prop;
 
-               size = of_get_property(np, "ibm,lmb-size", NULL);
-               if (size)
-                       memblock_size = be64_to_cpup(size);
+               size_cells = of_n_size_cells(np);
+
+               prop = of_get_property(np, "ibm,lmb-size", &len);
+               if (prop && len >= size_cells * sizeof(__be32))
+                       memblock_size = of_read_number(prop, size_cells);
                of_node_put(np);
+
        } else  if (machine_is(pseries)) {
                /* This fallback really only applies to pseries */
                unsigned int memzero_size = 0;