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

MIPS: Netlogic: Move cores per node out of multi-node.h

Use the current_cpu_data package field to get the node of the current CPU.

This allows us to remove xlp_cores_per_node and move nlm_threads_per_node()
and nlm_cores_per_node() to netlogic/common.h, which simplifies code.

Signed-off-by: Jayachandran C <jchandra@broadcom.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/8889/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Jayachandran C and committed by
Ralf Baechle
c2736525 65fecc27

+43 -36
-9
arch/mips/include/asm/mach-netlogic/multi-node.h
··· 48 48 #endif 49 49 50 50 #define NLM_THREADS_PER_CORE 4 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()) 60 51 61 52 struct nlm_soc_info { 62 53 unsigned long coremask; /* cores enabled on the soc */
+20 -1
arch/mips/include/asm/netlogic/common.h
··· 111 111 return node * NR_IRQS / NLM_NR_NODES + irq; 112 112 } 113 113 114 - extern int nlm_cpu_ready[]; 114 + #ifdef CONFIG_CPU_XLR 115 + #define nlm_cores_per_node() 8 116 + #else 117 + static inline int nlm_cores_per_node(void) 118 + { 119 + return ((read_c0_prid() & PRID_IMP_MASK) 120 + == PRID_IMP_NETLOGIC_XLP9XX) ? 32 : 8; 121 + } 115 122 #endif 123 + static inline int nlm_threads_per_node(void) 124 + { 125 + return nlm_cores_per_node() * NLM_THREADS_PER_CORE; 126 + } 127 + 128 + static inline int nlm_hwtid_to_node(int hwtid) 129 + { 130 + return hwtid / nlm_threads_per_node(); 131 + } 132 + 133 + extern int nlm_cpu_ready[]; 134 + #endif /* __ASSEMBLY__ */ 116 135 #endif /* _NETLOGIC_COMMON_H_ */
+5 -5
arch/mips/netlogic/common/irq.c
··· 230 230 } 231 231 } 232 232 233 - void nlm_smp_irq_init(int hwcpuid) 233 + void nlm_smp_irq_init(int hwtid) 234 234 { 235 - int node, cpu; 235 + int cpu, node; 236 236 237 - node = nlm_cpuid_to_node(hwcpuid); 238 - cpu = hwcpuid % nlm_threads_per_node(); 237 + cpu = hwtid % nlm_threads_per_node(); 238 + node = hwtid / nlm_threads_per_node(); 239 239 240 240 if (cpu == 0 && node != 0) 241 241 nlm_init_node_irqs(node); 242 - write_c0_eimr(nlm_current_node()->irqmask); 242 + write_c0_eimr(nlm_get_node(node)->irqmask); 243 243 } 244 244 245 245 asmlinkage void plat_irq_dispatch(void)
+14 -12
arch/mips/netlogic/common/smp.c
··· 59 59 60 60 void nlm_send_ipi_single(int logical_cpu, unsigned int action) 61 61 { 62 - int cpu, node; 62 + unsigned int hwtid; 63 63 uint64_t picbase; 64 64 65 - cpu = cpu_logical_map(logical_cpu); 66 - node = nlm_cpuid_to_node(cpu); 67 - picbase = nlm_get_node(node)->picbase; 65 + /* node id is part of hwtid, and needed for send_ipi */ 66 + hwtid = cpu_logical_map(logical_cpu); 67 + picbase = nlm_get_node(nlm_hwtid_to_node(hwtid))->picbase; 68 68 69 69 if (action & SMP_CALL_FUNCTION) 70 - nlm_pic_send_ipi(picbase, cpu, IRQ_IPI_SMP_FUNCTION, 0); 70 + nlm_pic_send_ipi(picbase, hwtid, IRQ_IPI_SMP_FUNCTION, 0); 71 71 if (action & SMP_RESCHEDULE_YOURSELF) 72 - nlm_pic_send_ipi(picbase, cpu, IRQ_IPI_SMP_RESCHEDULE, 0); 72 + nlm_pic_send_ipi(picbase, hwtid, IRQ_IPI_SMP_RESCHEDULE, 0); 73 73 } 74 74 75 75 void nlm_send_ipi_mask(const struct cpumask *mask, unsigned int action) ··· 120 120 121 121 hwtid = hard_smp_processor_id(); 122 122 current_cpu_data.core = hwtid / NLM_THREADS_PER_CORE; 123 - current_cpu_data.package = nlm_cpuid_to_node(hwtid); 123 + current_cpu_data.package = nlm_nodeid(); 124 124 nlm_percpu_init(hwtid); 125 125 nlm_smp_irq_init(hwtid); 126 126 } ··· 146 146 147 147 void nlm_boot_secondary(int logical_cpu, struct task_struct *idle) 148 148 { 149 - int cpu, node; 149 + uint64_t picbase; 150 + int hwtid; 150 151 151 - cpu = cpu_logical_map(logical_cpu); 152 - node = nlm_cpuid_to_node(logical_cpu); 152 + hwtid = cpu_logical_map(logical_cpu); 153 + picbase = nlm_get_node(nlm_hwtid_to_node(hwtid))->picbase; 154 + 153 155 nlm_next_sp = (unsigned long)__KSTK_TOS(idle); 154 156 nlm_next_gp = (unsigned long)task_thread_info(idle); 155 157 156 158 /* barrier for sp/gp store above */ 157 159 __sync(); 158 - nlm_pic_send_ipi(nlm_get_node(node)->picbase, cpu, 1, 1); /* NMI */ 160 + nlm_pic_send_ipi(picbase, hwtid, 1, 1); /* NMI */ 159 161 } 160 162 161 163 void __init nlm_smp_setup(void) ··· 185 183 __cpu_number_map[i] = num_cpus; 186 184 __cpu_logical_map[num_cpus] = i; 187 185 set_cpu_possible(num_cpus, true); 188 - node = nlm_cpuid_to_node(i); 186 + node = nlm_hwtid_to_node(i); 189 187 cpumask_set_cpu(num_cpus, &nlm_get_node(node)->cpumask); 190 188 ++num_cpus; 191 189 }
-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; 55 54 56 55 static void nlm_linux_exit(void) 57 56 { ··· 162 163 void *reset_vec; 163 164 164 165 nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE); 165 - if (cpu_is_xlp9xx()) 166 - xlp_cores_per_node = 32; 167 - else 168 - xlp_cores_per_node = 8; 169 166 nlm_init_boot_cpu(); 170 167 xlp_mmu_init(); 171 168 nlm_node_init(0);
+4 -4
arch/mips/netlogic/xlp/wakeup.c
··· 111 111 struct nlm_soc_info *nodep; 112 112 uint64_t syspcibase, fusebase; 113 113 uint32_t syscoremask, mask, fusemask; 114 - int core, n, cpu; 114 + int core, n, cpu, ncores; 115 115 116 116 for (n = 0; n < NLM_NR_NODES; n++) { 117 117 if (n != 0) { ··· 168 168 syscoremask = (1 << hweight32(~fusemask & mask)) - 1; 169 169 170 170 pr_info("Node %d - SYS/FUSE coremask %x\n", n, syscoremask); 171 - for (core = 0; core < nlm_cores_per_node(); core++) { 171 + ncores = nlm_cores_per_node(); 172 + for (core = 0; core < ncores; core++) { 172 173 /* we will be on node 0 core 0 */ 173 174 if (n == 0 && core == 0) 174 175 continue; ··· 179 178 continue; 180 179 181 180 /* see if at least the first hw thread is enabled */ 182 - cpu = (n * nlm_cores_per_node() + core) 183 - * NLM_THREADS_PER_CORE; 181 + cpu = (n * ncores + core) * NLM_THREADS_PER_CORE; 184 182 if (!cpumask_test_cpu(cpu, wakeup_mask)) 185 183 continue; 186 184