summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Fontenot <nfont@linux.vnet.ibm.com>2017-12-01 19:46:53 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2018-01-16 10:23:48 +0300
commitb88fc309d6ad0abee74053b4a8f78a1a4ed5e5db (patch)
treec45bfbe471a4d5630b7471e465ae63c4b4e92b5f
parent22508f3dc985f6ed948293297f728605075fe6a7 (diff)
downloadlinux-b88fc309d6ad0abee74053b4a8f78a1a4ed5e5db.tar.xz
powerpc/numa: Look up associativity array in of_drconf_to_nid_single
Look up the associativity arrays in of_drconf_to_nid_single when deriving the nid for a LMB instead of having it passed in as a parameter. Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/mm/numa.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index baba6403488b..d25278adaead 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -509,26 +509,30 @@ static int of_get_assoc_arrays(struct assoc_arrays *aa)
* This is like of_node_to_nid_single() for memory represented in the
* ibm,dynamic-reconfiguration-memory node.
*/
-static int of_drconf_to_nid_single(struct of_drconf_cell *drmem,
- struct assoc_arrays *aa)
+static int of_drconf_to_nid_single(struct of_drconf_cell *drmem)
{
+ struct assoc_arrays aa = { .arrays = NULL };
int default_nid = 0;
int nid = default_nid;
- int index;
+ int rc, index;
+
+ rc = of_get_assoc_arrays(&aa);
+ if (rc)
+ return default_nid;
- if (min_common_depth > 0 && min_common_depth <= aa->array_sz &&
+ if (min_common_depth > 0 && min_common_depth <= aa.array_sz &&
!(drmem->flags & DRCONF_MEM_AI_INVALID) &&
- drmem->aa_index < aa->n_arrays) {
- index = drmem->aa_index * aa->array_sz + min_common_depth - 1;
- nid = of_read_number(&aa->arrays[index], 1);
+ drmem->aa_index < aa.n_arrays) {
+ index = drmem->aa_index * aa.array_sz + min_common_depth - 1;
+ nid = of_read_number(&aa.arrays[index], 1);
if (nid == 0xffff || nid >= MAX_NUMNODES)
nid = default_nid;
if (nid > 0) {
- index = drmem->aa_index * aa->array_sz;
+ index = drmem->aa_index * aa.array_sz;
initialize_distance_lookup_table(nid,
- &aa->arrays[index]);
+ &aa.arrays[index]);
}
}
@@ -664,10 +668,9 @@ static inline int __init read_usm_ranges(const __be32 **usm)
static void __init parse_drconf_memory(struct device_node *memory)
{
const __be32 *uninitialized_var(dm), *usm;
- unsigned int n, rc, ranges, is_kexec_kdump = 0;
+ unsigned int n, ranges, is_kexec_kdump = 0;
unsigned long lmb_size, base, size, sz;
int nid;
- struct assoc_arrays aa = { .arrays = NULL };
n = of_get_drconf_memory(memory, &dm);
if (!n)
@@ -677,10 +680,6 @@ static void __init parse_drconf_memory(struct device_node *memory)
if (!lmb_size)
return;
- rc = of_get_assoc_arrays(&aa);
- if (rc)
- return;
-
/* check if this is a kexec/kdump kernel */
usm = of_get_usable_memory();
if (usm != NULL)
@@ -711,7 +710,7 @@ static void __init parse_drconf_memory(struct device_node *memory)
base = read_n_cells(n_mem_addr_cells, &usm);
size = read_n_cells(n_mem_size_cells, &usm);
}
- nid = of_drconf_to_nid_single(&drmem, &aa);
+ nid = of_drconf_to_nid_single(&drmem);
fake_numa_create_new_node(
((base + size) >> PAGE_SHIFT),
&nid);
@@ -999,9 +998,8 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
unsigned long scn_addr)
{
const __be32 *dm;
- unsigned int drconf_cell_cnt, rc;
+ unsigned int drconf_cell_cnt;
unsigned long lmb_size;
- struct assoc_arrays aa;
int nid = -1;
drconf_cell_cnt = of_get_drconf_memory(memory, &dm);
@@ -1012,10 +1010,6 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
if (!lmb_size)
return -1;
- rc = of_get_assoc_arrays(&aa);
- if (rc)
- return -1;
-
for (; drconf_cell_cnt != 0; --drconf_cell_cnt) {
struct of_drconf_cell drmem;
@@ -1031,7 +1025,7 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
|| (scn_addr >= (drmem.base_addr + lmb_size)))
continue;
- nid = of_drconf_to_nid_single(&drmem, &aa);
+ nid = of_drconf_to_nid_single(&drmem);
break;
}