Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Netlogic: Add cpu to node mapping for XLP9XX

XLP9XX has 20 cores per node, opposed to 8 on earlier XLP8XX.
Update code that calculates node id from cpu id to handle this.

Signed-off-by: Jayachandran C <jchandra@broadcom.com>
Signed-off-by: John Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/6283/

authored by

Jayachandran C and committed by
Ralf Baechle
98d4884c e7aa6c66

+33 -14
+9 -2
arch/mips/include/asm/mach-netlogic/multi-node.h
··· 47 47 #endif 48 48 #endif 49 49 50 - #define NLM_CORES_PER_NODE 8 51 50 #define NLM_THREADS_PER_CORE 4 52 - #define NLM_CPUS_PER_NODE (NLM_CORES_PER_NODE * NLM_THREADS_PER_CORE) 51 + #ifdef CONFIG_CPU_XLR 52 + #define nlm_cores_per_node() 8 53 + #else 54 + extern unsigned int xlp_cores_per_node; 55 + #define nlm_cores_per_node() xlp_cores_per_node 56 + #endif 57 + 58 + #define nlm_threads_per_node() (nlm_cores_per_node() * NLM_THREADS_PER_CORE) 59 + #define nlm_cpuid_to_node(c) ((c) / nlm_threads_per_node()) 53 60 54 61 struct nlm_soc_info { 55 62 unsigned long coremask; /* cores enabled on the soc */
+6 -1
arch/mips/include/asm/netlogic/mips-extns.h
··· 146 146 147 147 static inline int nlm_nodeid(void) 148 148 { 149 - return (__read_32bit_c0_register($15, 1) >> 5) & 0x3; 149 + uint32_t prid = read_c0_prid(); 150 + 151 + if ((prid & 0xff00) == PRID_IMP_NETLOGIC_XLP9XX) 152 + return (__read_32bit_c0_register($15, 1) >> 7) & 0x7; 153 + else 154 + return (__read_32bit_c0_register($15, 1) >> 5) & 0x3; 150 155 } 151 156 152 157 static inline unsigned int nlm_core_id(void)
+3 -3
arch/mips/netlogic/common/irq.c
··· 223 223 continue; 224 224 225 225 nlm_pic_init_irt(nodep->picbase, irt, i, 226 - node * NLM_CPUS_PER_NODE, 0); 226 + node * nlm_threads_per_node(), 0); 227 227 nlm_setup_pic_irq(node, i, i, irt); 228 228 } 229 229 } ··· 232 232 { 233 233 int node, cpu; 234 234 235 - node = hwcpuid / NLM_CPUS_PER_NODE; 236 - cpu = hwcpuid % NLM_CPUS_PER_NODE; 235 + node = nlm_cpuid_to_node(hwcpuid); 236 + cpu = hwcpuid % nlm_threads_per_node(); 237 237 238 238 if (cpu == 0 && node != 0) 239 239 nlm_init_node_irqs(node);
+5 -3
arch/mips/netlogic/common/smp.c
··· 63 63 uint64_t picbase; 64 64 65 65 cpu = cpu_logical_map(logical_cpu); 66 - node = cpu / NLM_CPUS_PER_NODE; 66 + node = nlm_cpuid_to_node(cpu); 67 67 picbase = nlm_get_node(node)->picbase; 68 68 69 69 if (action & SMP_CALL_FUNCTION) ··· 152 152 int cpu, node; 153 153 154 154 cpu = cpu_logical_map(logical_cpu); 155 - node = cpu / NLM_CPUS_PER_NODE; 155 + node = nlm_cpuid_to_node(logical_cpu); 156 156 nlm_next_sp = (unsigned long)__KSTK_TOS(idle); 157 157 nlm_next_gp = (unsigned long)task_thread_info(idle); 158 158 ··· 164 164 void __init nlm_smp_setup(void) 165 165 { 166 166 unsigned int boot_cpu; 167 - int num_cpus, i, ncore; 167 + int num_cpus, i, ncore, node; 168 168 volatile u32 *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY); 169 169 char buf[64]; 170 170 ··· 187 187 __cpu_number_map[i] = num_cpus; 188 188 __cpu_logical_map[num_cpus] = i; 189 189 set_cpu_possible(num_cpus, true); 190 + node = nlm_cpuid_to_node(i); 191 + cpumask_set_cpu(num_cpus, &nlm_get_node(node)->cpumask); 190 192 ++num_cpus; 191 193 } 192 194 }
+5
arch/mips/netlogic/xlp/setup.c
··· 51 51 struct nlm_soc_info nlm_nodes[NLM_NR_NODES]; 52 52 cpumask_t nlm_cpumask = CPU_MASK_CPU0; 53 53 unsigned int nlm_threads_per_core; 54 + unsigned int xlp_cores_per_node; 54 55 55 56 static void nlm_linux_exit(void) 56 57 { ··· 155 154 void *reset_vec; 156 155 157 156 nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE); 157 + if (cpu_is_xlp9xx()) 158 + xlp_cores_per_node = 32; 159 + else 160 + xlp_cores_per_node = 8; 158 161 nlm_init_boot_cpu(); 159 162 xlp_mmu_init(); 160 163 nlm_node_init(0);
+2 -2
arch/mips/netlogic/xlp/wakeup.c
··· 165 165 nodep->coremask = 1; 166 166 167 167 pr_info("Node %d - SYS/FUSE coremask %x\n", n, syscoremask); 168 - for (core = 0; core < NLM_CORES_PER_NODE; core++) { 168 + for (core = 0; core < nlm_cores_per_node(); core++) { 169 169 /* we will be on node 0 core 0 */ 170 170 if (n == 0 && core == 0) 171 171 continue; ··· 175 175 continue; 176 176 177 177 /* see if at least the first hw thread is enabled */ 178 - cpu = (n * NLM_CORES_PER_NODE + core) 178 + cpu = (n * nlm_cores_per_node() + core) 179 179 * NLM_THREADS_PER_CORE; 180 180 if (!cpumask_test_cpu(cpu, wakeup_mask)) 181 181 continue;
+1 -1
arch/mips/netlogic/xlr/wakeup.c
··· 70 70 71 71 /* Fill up the coremask early */ 72 72 nodep->coremask = 1; 73 - for (i = 1; i < NLM_CORES_PER_NODE; i++) { 73 + for (i = 1; i < nlm_cores_per_node(); i++) { 74 74 for (j = 1000000; j > 0; j--) { 75 75 if (cpu_ready[i * NLM_THREADS_PER_CORE]) 76 76 break;
+2 -2
arch/mips/pci/msi-xlp.c
··· 280 280 irt = PIC_IRT_PCIE_LINK_INDEX(link); 281 281 nlm_setup_pic_irq(node, lirq, lirq, irt); 282 282 nlm_pic_init_irt(nlm_get_node(node)->picbase, irt, lirq, 283 - node * NLM_CPUS_PER_NODE, 1 /*en */); 283 + node * nlm_threads_per_node(), 1 /*en */); 284 284 } 285 285 286 286 /* allocate a MSI vec, and tell the bridge about it */ ··· 443 443 msixvec = link * XLP_MSIXVEC_PER_LINK + i; 444 444 irt = PIC_IRT_PCIE_MSIX_INDEX(msixvec); 445 445 nlm_pic_init_irt(nodep->picbase, irt, PIC_PCIE_MSIX_IRQ(link), 446 - node * NLM_CPUS_PER_NODE, 1 /* enable */); 446 + node * nlm_threads_per_node(), 1 /* enable */); 447 447 448 448 /* Initialize MSI-X extended irq space for the link */ 449 449 irq = nlm_irq_to_xirq(node, nlm_link_msixirq(link, i));