MIPS: Netlogic: Add NUMA support for XLP
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
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 | 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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