MIPS: Netlogic: Add NUMA support
PATCH 1/1 MIPS: Netlogic: Add NUMA support
Support NUMA on XLP8XX and XLP9XX multi SoC setup.
Signed-off-by Jayachandran C <[email protected]>
--- arch/mips/Kconfig | 3 +- arch/mips/include/asm/mach-netlogic/mmzone.h | 19 +++ arch/mips/include/asm/mach-netlogic/topology.h | 23 +++ 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 | 190 +++++++++++++++++++++++++ arch/mips/netlogic/xlp/setup.c | 1 + arch/mips/pci/pci-xlp.c | 28 ++++ 10 files changed, 284 insertions(+), 2 deletions(-) create mode 100644 arch/mips/include/asm/mach-netlogic/mmzone.h create mode 100644 arch/mips/include/asm/mach-netlogic/topology.h create mode 100644 arch/mips/netlogic/xlp/numa.c
arch/mips/Kconfig +2 -1
@@ -851,6 +851,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
@@ -2260,7 +2261,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
@@ -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 new file +23 -0
@@ -0,0 +1,23 @@ +/* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive +* for more details. +* +* Copyright (C) 2013 Broadcom Corporation +*/ +#ifndef _ASM_MACH_NETLOGIC_TOPOLOGY_H +#define _ASM_MACH_NETLOGIC_TOPOLOGY_H + +#include <asm/mach-netlogic/multi-node.h> + +#define cpu_to_node (cpu) (cpu_data[cpu].package) +#define cpumask_of_node (node) (&nlm_get_node(node)->cpumask) +#define parent_node (node) (node) + +struct pci_bus ; +extern int pcibus_to_node (struct pci_bus *); +#define cpumask_of_pcibus (bus) (cpu_online_mask) + +#include <asm-generic/topology.h> + +#endif /* _ASM_MACH_NETLOGIC_TOPOLOGY_H */
arch/mips/include/asm/netlogic/xlp-hal/xlp.h +5 -0
@@ -94,6 +94,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
@@ -292,6 +292,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
@@ -174,6 +174,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++) {
@@ -198,8 +199,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);
@@ -214,6 +219,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
@@ -1,5 +1,6 @@ obj-y += setup.o nlm_hal.o cop2-ex.o dt.o obj-$(CONFIG_SMP) += wakeup.o +obj-$(CONFIG_NUMA) += numa.o ifdef CONFIG_USB obj-y += usb-init.o obj-y += usb-init-xlp2.o
arch/mips/netlogic/xlp/numa.c new file +190 -0
190 lines not on this page · raw message
arch/mips/netlogic/xlp/setup.c +1 -0
@@ -102,6 +102,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
@@ -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.9.1