From b88fc309d6ad0abee74053b4a8f78a1a4ed5e5db Mon Sep 17 00:00:00 2001 From: Nathan Fontenot Date: Fri, 1 Dec 2017 10:46:53 -0600 Subject: [PATCH] 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 Signed-off-by: Michael Ellerman --- arch/powerpc/mm/numa.c | 40 +++++++++++++++++----------------------- 1 file 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; } -- 2.34.1