linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH V3 3/9] powerpc/numa: Look up associativity array in of_drconf_to_nid_single
Date: Fri, 01 Dec 2017 10:46:53 -0600	[thread overview]
Message-ID: <151214680997.64022.11558560567274075939.stgit@ltcalpine2-lp14.aus.stglabs.ibm.com> (raw)
In-Reply-To: <151214667699.64022.17601877129884655591.stgit@ltcalpine2-lp14.aus.stglabs.ibm.com>

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>
---
 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;
 	}
 

  parent reply	other threads:[~2017-12-01 17:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
2017-12-01 16:46 ` [PATCH V3 1/9] powerpc/numa: Look up device node in of_get_assoc_arrays() Nathan Fontenot
2018-01-17 13:30   ` [V3, " Michael Ellerman
2017-12-01 16:46 ` [PATCH V3 2/9] powerpc/numa: Look up device node in of_get_usable_memory() Nathan Fontenot
2017-12-01 16:46 ` Nathan Fontenot [this message]
2017-12-01 16:47 ` [PATCH V3 4/9] powerpc/mm: Separate ibm, dynamic-memory data from DT format Nathan Fontenot
2017-12-01 16:47 ` [PATCH V3 5/9] powerpc/numa: Update numa code use walk_drmem_lmbs Nathan Fontenot
2017-12-01 16:47 ` [PATCH V3 6/9] powerpc/pseries: Update memory hotplug code to use drmem LMB array Nathan Fontenot
2017-12-01 16:47 ` [PATCH V3 7/9] powerpc: Move of_drconf_cell struct to asm/drmem.h Nathan Fontenot
2017-12-01 16:47 ` [PATCH V3 8/9] powerpc/drmem: Add support for ibm, dynamic-memory-v2 property Nathan Fontenot
2018-01-17 13:30   ` [V3, " Michael Ellerman
2017-12-01 16:48 ` [PATCH V3 9/9] powerpc: Enable support of ibm,dynamic-memory-v2 Nathan Fontenot
2018-01-17 13:30   ` [V3,9/9] " Michael Ellerman
2017-12-04  5:13 ` [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Michael Ellerman
2018-02-14 21:30   ` Tyrel Datwyler
2018-02-14 21:50     ` Nathan Fontenot
2018-02-14 23:21     ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=151214680997.64022.11558560567274075939.stgit@ltcalpine2-lp14.aus.stglabs.ibm.com \
    --to=nfont@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).