linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Bogendoerfer <tbogendoerfer@suse.de>
To: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	James Hogan <jhogan@kernel.org>,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 10/14] MIPS: SGI-IP27: Use specific get_region_shift
Date: Thu,  9 Jan 2020 13:33:47 +0100	[thread overview]
Message-ID: <20200109123353.5656-11-tbogendoerfer@suse.de> (raw)
In-Reply-To: <20200109123353.5656-1-tbogendoerfer@suse.de>

IP35 has a different way to find out regions, so we move the IP27
implementation to IP27 specific file.

Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 arch/mips/include/asm/sn/sn0/hubni.h |  8 +++++++
 arch/mips/sgi-ip27/ip27-memory.c     | 36 ++++++++++------------------
 2 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/arch/mips/include/asm/sn/sn0/hubni.h b/arch/mips/include/asm/sn/sn0/hubni.h
index b73c4bee65f2..b8253142cb83 100644
--- a/arch/mips/include/asm/sn/sn0/hubni.h
+++ b/arch/mips/include/asm/sn/sn0/hubni.h
@@ -250,6 +250,14 @@ typedef union	hubni_port_error_u {
 #define NI_LLP_CB_MAX		0xff
 #define NI_LLP_SN_MAX		0xff
 
+static inline int get_region_shift(void)
+{
+	if (LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_REGIONSIZE_MASK)
+		return NASID_TO_FINEREG_SHFT;
+
+	return NASID_TO_COARSEREG_SHFT;
+}
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _ASM_SGI_SN0_HUBNI_H */
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index 0ef2181db8d0..db3759e551b3 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -25,6 +25,7 @@
 #include <asm/sections.h>
 
 #include <asm/sn/arch.h>
+#include <asm/sn/agent.h>
 #include <asm/sn/klconfig.h>
 #include <asm/sn/sn_private.h>
 
@@ -36,31 +37,18 @@ struct node_data *__node_data[MAX_NUMNODES];
 
 EXPORT_SYMBOL(__node_data);
 
-static int fine_mode;
-
-static int is_fine_dirmode(void)
-{
-	return ((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_REGIONSIZE_MASK) >> NSRI_REGIONSIZE_SHFT) & REGIONSIZE_FINE;
-}
-
-static u64 get_region(nasid_t nasid)
-{
-	if (fine_mode)
-		return nasid >> NASID_TO_FINEREG_SHFT;
-	else
-		return nasid >> NASID_TO_COARSEREG_SHFT;
-}
-
-static u64 region_mask;
-
-static void gen_region_mask(u64 *region_mask)
+static u64 gen_region_mask(void)
 {
+	int region_shift;
+	u64 region_mask;
 	nasid_t nasid;
 
-	(*region_mask) = 0;
-	for_each_online_node(nasid) {
-		(*region_mask) |= 1ULL << get_region(nasid);
-	}
+	region_shift = get_region_shift();
+	region_mask = 0;
+	for_each_online_node(nasid)
+		region_mask |= BIT_ULL(nasid >> region_shift);
+
+	return region_mask;
 }
 
 #define rou_rflag	rou_flags
@@ -280,10 +268,10 @@ static unsigned long __init slot_psize_compute(nasid_t nasid, int slot)
 
 static void __init mlreset(void)
 {
+	u64 region_mask;
 	nasid_t nasid;
 
 	master_nasid = get_nasid();
-	fine_mode = is_fine_dirmode();
 
 	/*
 	 * Probe for all CPUs - this creates the cpumask and sets up the
@@ -296,7 +284,7 @@ static void __init mlreset(void)
 	init_topology_matrix();
 	dump_topology();
 
-	gen_region_mask(&region_mask);
+	region_mask = gen_region_mask();
 
 	setup_replication_mask();
 
-- 
2.24.1


  parent reply	other threads:[~2020-01-09 12:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-09 12:33 [PATCH 00/14] Cleanup SGI-IP27 and prepare for SGI-IP35 support Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 01/14] MIPS: SGI-IP27: use nodemask instead of cpumask Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 02/14] MIPS: SGI-IP27: use cpu physid already present while scanning for CPUs Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 03/14] MIPS: SGI-IP27: use asm/sn/agent.h for including HUB related stuff Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 04/14] MIPS: SGI-IP27: get rid of asm/sn/sn0/ip27.h Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 05/14] MIPS: SGI-IP27: move IP27 specific macro to IP27 specific header file Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 06/14] MIPS: SGI-IP27: Move get_nasid() to a IP27 specific file Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 07/14] MIPS: SGI-IP27: Split kldir.h into generic SN and IP27 parts Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 08/14] MIPS: SGI-IP27: Use union instead of typedef Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 09/14] MIPS: SGI-IP27: Use structs for decoding error status registers Thomas Bogendoerfer
2020-01-09 12:33 ` Thomas Bogendoerfer [this message]
2020-01-09 12:33 ` [PATCH 11/14] MIPS: SGI-IP27: Move all shared IP27 declarations to ip27-common.h Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 12/14] MIPS: SGI-IP27: Only reserve interrupts used in Linux Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 13/14] MIPS: SGI-IP27: Store cpu speed when scanning for CPUs and use it later Thomas Bogendoerfer
2020-01-09 12:33 ` [PATCH 14/14] MIPS: SGI-IP27: No need for slice_map Thomas Bogendoerfer
2020-01-10 19:25 ` [PATCH 00/14] Cleanup SGI-IP27 and prepare for SGI-IP35 support Paul Burton

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=20200109123353.5656-11-tbogendoerfer@suse.de \
    --to=tbogendoerfer@suse.de \
    --cc=jhogan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=paulburton@kernel.org \
    --cc=ralf@linux-mips.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).