[PATCH 11/38] MIPS: SGI-IP27: lay out node memory in 1GB banks on Bedrock hubs

From: Imre Kaloz

Date: Thu Oct 01 2026 - 12:58:37 EST


Hub describes a node's memory as 128MB slots, four slots to a
klconfig bank entry. Bedrock gives each bank entry a 1GB slot of its
own and sizes it in megabytes. Take the slot shift, the slot count and
the bank size from the hub generation.

Signed-off-by: Imre Kaloz <kaloz@xxxxxxxxxx>
---
arch/mips/sgi-ip27/ip27-memory.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index 4317f5ae1fd1..0204dc8bb1bb 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -31,9 +31,16 @@

#include "ip27-common.h"

-#define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT)
#define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT)

+/* A Bedrock node's memory comes in 1GB banks. */
+#define BEDROCK_SLOT_SHIFT 30
+
+static unsigned int __init slot_shift(void)
+{
+ return system_is_ip35 ? BEDROCK_SLOT_SHIFT : SLOT_SHIFT;
+}
+
struct node_data *__node_data[MAX_NUMNODES];
EXPORT_SYMBOL(__node_data);

@@ -230,7 +237,8 @@ static void __init dump_topology(void)

static unsigned long __init slot_getbasepfn(nasid_t nasid, int slot)
{
- return ((unsigned long)nasid << PFN_NASIDSHFT) | (slot << SLOT_PFNSHIFT);
+ return ((unsigned long)nasid << PFN_NASIDSHFT) |
+ ((unsigned long)slot << (slot_shift() - PAGE_SHIFT));
}

static unsigned long __init slot_psize_compute(nasid_t nasid, int slot)
@@ -249,6 +257,12 @@ static unsigned long __init slot_psize_compute(nasid_t nasid, int slot)
if (!banks)
return 0;

+ /* Bedrock bank entry N sizes the 1GB slot N, in megabytes. */
+ if (system_is_ip35) {
+ size = (unsigned long)banks->membnk_bnksz[slot];
+ return (size << 20) >> PAGE_SHIFT;
+ }
+
/* Size in _Megabytes_ */
size = (unsigned long)banks->membnk_bnksz[slot/4];

@@ -315,12 +329,13 @@ static void __init mlreset(void)
static void __init szmem(void)
{
unsigned long slot_psize, slot0sz = 0, nodebytes; /* Hack to detect problem configs */
+ int slots = system_is_ip35 ? MD_MEM_BANKS : MAX_MEM_SLOTS;
int slot;
nasid_t node;

for_each_online_node(node) {
nodebytes = 0;
- for (slot = 0; slot < MAX_MEM_SLOTS; slot++) {
+ for (slot = 0; slot < slots; slot++) {
slot_psize = slot_psize_compute(node, slot);
if (slot == 0)
slot0sz = slot_psize;
@@ -328,7 +343,7 @@ static void __init szmem(void)
* We need to refine the hack when we have replicated
* kernel text.
*/
- nodebytes += (1LL << SLOT_SHIFT);
+ nodebytes += (1LL << slot_shift());

if (!slot_psize)
continue;
@@ -337,7 +352,7 @@ static void __init szmem(void)
(slot0sz << PAGE_SHIFT)) {
pr_info("Ignoring slot %d onwards on node %d\n",
slot, node);
- slot = MAX_MEM_SLOTS;
+ slot = slots;
continue;
}
memblock_add_node(PFN_PHYS(slot_getbasepfn(node, slot)),
--
2.47.3