Skip to contentSkip to conversation

MIPS: Netlogic: Add NUMA support for XLP

RFC PATCH New Jayachandran C 1 participant 1 message May 9, 2014 MIPS

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 MIPS: Netlogic: Add NUMA support for XLP

Support NUMA on XLP8XX/XLP9XX multi-chip configuration.

* Create mach-netlogic/mmzone.h to do memory to node mapping.
* Update mach-netlogic/topology.h for cpu to node mapping.
* Add memory initialization code xlp_numa_bootmem_init() and call it from mips bootmem_init()
* Use DRAM configuration of each node to separate the memory given to linux to node specific regions
* Add platform_notify hook to setup node id correctly for PCI devices

---
 arch/mips/Kconfig                              |    3 +-
 arch/mips/include/asm/mach-netlogic/mmzone.h   |   19 +++
 arch/mips/include/asm/mach-netlogic/topology.h |   10 ++
 arch/mips/include/asm/netlogic/xlp-hal/xlp.h   |    5 +
 arch/mips/kernel/setup.c                       |    8 +
 arch/mips/netlogic/common/smp.c                |    8 +-
 arch/mips/netlogic/xlp/Makefile                |    1 +
 arch/mips/netlogic/xlp/numa.c                  |  191 ++++++++++++++++++++++++
 arch/mips/netlogic/xlp/setup.c                 |    1 +
 arch/mips/pci/pci-xlp.c                        |   28 ++++
 10 files changed, 272 insertions(+), 2 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-netlogic/mmzone.h
 create mode 100644 arch/mips/netlogic/xlp/numa.c
arch/mips/Kconfig +2 -1
index e149850..2c8d243 100644
@@ -782,6 +782,7 @@ config NLM_XLP_BOARD
 	select ZONE_DMA32 if 64BIT
 	select SYNC_R4K
 	select SYS_HAS_EARLY_PRINTK
+	select SYS_SUPPORTS_NUMA
 	select USE_OF
 	select SYS_SUPPORTS_ZBOOT
 	select SYS_SUPPORTS_ZBOOT_UART16550
@@ -2215,7 +2216,7 @@ config ARCH_FLATMEM_ENABLE
 
 config ARCH_DISCONTIGMEM_ENABLE
 	bool
-	default y if SGI_IP27
+	default y if SGI_IP27 || NUMA
 	help
 	  Say Y to support efficient handling of discontiguous physical memory,
 	  for architectures which are either NUMA (Non-Uniform Memory Access)
arch/mips/include/asm/mach-netlogic/mmzone.h new file +19 -0
new file mode 100644
index 0000000..7f4afe9
@@ -0,0 +1,19 @@
+#ifndef _NETLOGIC_MMZONE_H_
+#define _NETLOGIC_MMZONE_H_
+
+#include <asm/mach-netlogic/multi-node.h>
+
+struct node_data {
+	struct pglist_data pglist;
+	struct nlm_soc_info *node;
+};
+
+#ifdef CONFIG_NUMA
+extern struct node_data *__node_data[];
+extern int xlp_pa_to_nid(phys_addr_t addr);
+
+#define pa_to_nid(addr)         xlp_pa_to_nid(addr)
+#define NODE_DATA(n)            (&__node_data[(n)]->pglist)
+#endif
+
+#endif /* _NETLOGIC_MMZONE_H_ */
arch/mips/include/asm/mach-netlogic/topology.h +10 -0
index ceeb1f5..dfd7c37 100644
@@ -11,6 +11,16 @@
 #include <asm/mach-netlogic/multi-node.h>
 
 #ifdef CONFIG_SMP
+#ifdef CONFIG_NUMA
+#define cpu_to_node(cpu)	nlm_cpuid_to_node(cpu_logical_map(cpu))
+#define cpumask_of_node(node)	(&nlm_get_node(node)->cpumask)
+#define parent_node(node)	(node)
+#endif
+
+struct pci_bus;
+extern int pcibus_to_node(struct pci_bus *);
+#define cpumask_of_pcibus(bus)  (cpu_online_mask)
+
 #define topology_physical_package_id(cpu)	cpu_to_node(cpu)
 #define topology_core_id(cpu)	(cpu_logical_map(cpu) / NLM_THREADS_PER_CORE)
 #define topology_thread_cpumask(cpu)		(&cpu_sibling_map[cpu])
arch/mips/include/asm/netlogic/xlp-hal/xlp.h +5 -0
index c0b2a80..67842b7 100644
@@ -93,6 +93,11 @@ int nlm_get_dram_map(int node, uint64_t *dram_map, int nentries);
 
 struct pci_dev;
 int xlp_socdev_to_node(const struct pci_dev *dev);
+#ifdef CONFIG_NUMA
+void xlp_numa_init(void);
+#else
+static inline void xlp_numa_init(void) {}
+#endif
 
 /* Device tree related */
 void xlp_early_init_devtree(void);
arch/mips/kernel/setup.c +8 -0
index 74c5f6d..666480c 100644
@@ -290,6 +290,14 @@ static void __init bootmem_init(void)
 	finalize_initrd();
 }
 
+#elif defined(CONFIG_CPU_XLP) && defined(CONFIG_NUMA)
+extern void xlp_numa_bootmem_init(void);
+static void __init bootmem_init(void)
+{
+	init_initrd();
+	xlp_numa_bootmem_init();
+	finalize_initrd();
+}
 #else  /* !CONFIG_SGI_IP27 */
 
 static void __init bootmem_init(void)
arch/mips/netlogic/common/smp.c +7 -1
index b93c5d4..89dc1fe 100644
@@ -175,6 +175,7 @@ void __init nlm_smp_setup(void)
 	__cpu_number_map[boot_cpu] = 0;
 	__cpu_logical_map[0] = boot_cpu;
 	set_cpu_possible(0, true);
+	cpumask_set_cpu(0, &nlm_get_node(0)->cpumask);
 
 	num_cpus = 1;
 	for (i = 0; i < NR_CPUS; i++) {
@@ -199,8 +200,12 @@ void __init nlm_smp_setup(void)
 	pr_info("Possible CPU mask: %s\n", buf);
 
 	/* check with the cores we have woken up */
-	for (ncore = 0, i = 0; i < NLM_NR_NODES; i++)
+	for (ncore = 0, i = 0; i < NLM_NR_NODES; i++) {
 		ncore += hweight32(nlm_get_node(i)->coremask);
+		cpumask_scnprintf(buf, ARRAY_SIZE(buf),
+						&nlm_get_node(i)->cpumask);
+		pr_info("\tnode %d: %s\n", i, buf);
+	}
 
 	pr_info("Detected (%dc%dt) %d Slave CPU(s)\n", ncore,
 		nlm_threads_per_core, num_cpus);
@@ -215,6 +220,7 @@ static int nlm_parse_cpumask(cpumask_t *wakeup_mask)
 	int threadmode, i, j;
 	char buf[64];
 
+	/* Get Core 0 thread mask and value for thread mode register */
 	core0_thr_mask = 0;
 	for (i = 0; i < NLM_THREADS_PER_CORE; i++)
 		if (cpumask_test_cpu(i, wakeup_mask))
arch/mips/netlogic/xlp/Makefile +1 -0
index be358a8..b7b8fe9 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_USB)		+= usb-init.o
 obj-$(CONFIG_USB)		+= usb-init-xlp2.o
 obj-$(CONFIG_SATA_AHCI)		+= ahci-init.o
 obj-$(CONFIG_SATA_AHCI)		+= ahci-init-xlp2.o
+obj-$(CONFIG_NUMA)		+= numa.o
arch/mips/netlogic/xlp/numa.c new file +191 -0

191 lines not on this page · raw message

arch/mips/netlogic/xlp/setup.c +1 -0
index bf4f6d3..5516a7d 100644
@@ -103,6 +103,7 @@ void __init plat_mem_setup(void)
 		pr_info("Using DRAM BARs for memory map.\n");
 		xlp_init_mem_from_bars();
 	}
+	xlp_numa_init();
 }
 
 const char *get_system_type(void)
arch/mips/pci/pci-xlp.c +28 -0
index 7babf01..9ea47ee 100644
@@ -286,6 +286,31 @@ static void xlp_config_pci_bswap(int node, int link)
 static inline void xlp_config_pci_bswap(int node, int link) {}
 #endif /* __BIG_ENDIAN */
 
+#ifdef CONFIG_NUMA
+int pcibus_to_node(struct pci_bus *bus)
+{
+	return dev_to_node(&bus->dev);
+}
+
+int xlp_fixup_numa_node(struct device *dev)
+{
+	if (dev_is_pci(dev)) {
+		struct pci_dev *pdev = to_pci_dev(dev);
+		int node;
+
+		/* fix the node numbers in top level devices */
+		if (pdev->bus->number == 0) {
+			if (cpu_is_xlp9xx())
+				node = PCI_FUNC(pdev->devfn);
+			else
+				node = PCI_SLOT(pdev->devfn) / 8;
+			set_dev_node(dev, node);
+		}
+	}
+	return 0;
+}
+#endif
+
 static int __init pcibios_init(void)
 {
 	uint64_t pciebase;
@@ -327,6 +352,9 @@ static int __init pcibios_init(void)
 	pr_info("XLP PCIe Controller %pR%pR.\n", &nlm_pci_io_resource,
 		&nlm_pci_mem_resource);
 
+#ifdef CONFIG_NUMA
+	platform_notify = xlp_fixup_numa_node;
+#endif
 	return 0;
 }
 arch_initcall(pcibios_init);
Signature · 1 line
1.7.9.5