LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au
Cc: Nathan Lynch <nathanl@linux.ibm.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	Hari Bathini <hbathini@linux.ibm.com>
Subject: [RFC PATCH 2/3] powerpc/numa: Use global variable instead of fetching again
Date: Thu,  6 Aug 2020 18:06:03 +0530	[thread overview]
Message-ID: <20200806123604.248361-2-aneesh.kumar@linux.ibm.com> (raw)
In-Reply-To: <20200806123604.248361-1-aneesh.kumar@linux.ibm.com>

use mem_addr_cells/mem_size_cells instead of fetching the values
again from device tree.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 arch/powerpc/mm/numa.c | 36 ++++++++++--------------------------
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 77d41d9775d2..c420872acd61 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -52,7 +52,6 @@ EXPORT_SYMBOL(node_to_cpumask_map);
 EXPORT_SYMBOL(node_data);
 
 static int min_common_depth;
-static int n_mem_addr_cells, n_mem_size_cells;
 static int form1_affinity;
 
 #define MAX_DISTANCE_REF_POINTS 4
@@ -355,19 +354,6 @@ static int __init find_min_common_depth(void)
 	return -1;
 }
 
-static void __init get_n_mem_cells(int *n_addr_cells, int *n_size_cells)
-{
-	struct device_node *memory = NULL;
-
-	memory = of_find_node_by_type(memory, "memory");
-	if (!memory)
-		panic("numa.c: No memory nodes found!");
-
-	*n_addr_cells = of_n_addr_cells(memory);
-	*n_size_cells = of_n_size_cells(memory);
-	of_node_put(memory);
-}
-
 /*  dt_mem_next_cell is __init  */
 static unsigned long read_n_cells(int n, const __be32 **buf)
 {
@@ -639,12 +625,12 @@ static inline int __init read_usm_ranges(const __be32 **usm)
 	 * a counter followed by that many (base, size) duple.
 	 * read the counter from linux,drconf-usable-memory
 	 */
-	return read_n_cells(n_mem_size_cells, usm);
+	return read_n_cells(mem_size_cells, usm);
 }
 
 /*
  * Extract NUMA information from the ibm,dynamic-reconfiguration-memory
- * node.  This assumes n_mem_{addr,size}_cells have been set.
+ * node.  This assumes mem_{addr,size}_cells have been set.
  */
 static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb,
 					const __be32 **usm,
@@ -677,8 +663,8 @@ static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb,
 
 	do {
 		if (is_kexec_kdump) {
-			base = read_n_cells(n_mem_addr_cells, usm);
-			size = read_n_cells(n_mem_size_cells, usm);
+			base = read_n_cells(mem_addr_cells, usm);
+			size = read_n_cells(mem_size_cells, usm);
 		}
 
 		nid = of_drconf_to_nid_single(lmb);
@@ -741,8 +727,6 @@ static int __init parse_numa_properties(void)
 		node_set_online(nid);
 	}
 
-	get_n_mem_cells(&n_mem_addr_cells, &n_mem_size_cells);
-
 	for_each_node_by_type(memory, "memory") {
 		unsigned long start;
 		unsigned long size;
@@ -759,11 +743,11 @@ static int __init parse_numa_properties(void)
 			continue;
 
 		/* ranges in cell */
-		ranges = (len >> 2) / (n_mem_addr_cells + n_mem_size_cells);
+		ranges = (len >> 2) / (mem_addr_cells + mem_size_cells);
 new_range:
 		/* these are order-sensitive, and modify the buffer pointer */
-		start = read_n_cells(n_mem_addr_cells, &memcell_buf);
-		size = read_n_cells(n_mem_size_cells, &memcell_buf);
+		start = read_n_cells(mem_addr_cells, &memcell_buf);
+		size = read_n_cells(mem_size_cells, &memcell_buf);
 
 		/*
 		 * Assumption: either all memory nodes or none will
@@ -1042,11 +1026,11 @@ static int hot_add_node_scn_to_nid(unsigned long scn_addr)
 			continue;
 
 		/* ranges in cell */
-		ranges = (len >> 2) / (n_mem_addr_cells + n_mem_size_cells);
+		ranges = (len >> 2) / (mem_addr_cells + mem_size_cells);
 
 		while (ranges--) {
-			start = read_n_cells(n_mem_addr_cells, &memcell_buf);
-			size = read_n_cells(n_mem_size_cells, &memcell_buf);
+			start = read_n_cells(mem_addr_cells, &memcell_buf);
+			size = read_n_cells(mem_size_cells, &memcell_buf);
 
 			if ((scn_addr < start) || (scn_addr >= (start + size)))
 				continue;
-- 
2.26.2


  reply	other threads:[~2020-08-06 12:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06 12:36 [RFC PATCH 1/3] powerpc/mem: Store the dt_root_size/addr cell values for later usage Aneesh Kumar K.V
2020-08-06 12:36 ` Aneesh Kumar K.V [this message]
2020-08-06 12:36 ` [RFC PATCH 3/3] powerpc/lmb-size: Use addr #size-cells value when fetching lmb-size Aneesh Kumar K.V
2020-08-06 12:52 ` [RFC PATCH] powerpc/drmem: use global variable instead of fetching again Aneesh Kumar K.V
2020-08-17 17:31   ` Hari Bathini

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=20200806123604.248361-2-aneesh.kumar@linux.ibm.com \
    --to=aneesh.kumar@linux.ibm.com \
    --cc=hbathini@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=nathanl@linux.ibm.com \
    /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