diff options
| author | Jayachandran C <jchandra@broadcom.com> | 2015-01-07 06:28:30 -0500 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2015-04-01 11:21:50 -0400 |
| commit | c2736525465a5d6fe1456da8cc2bc701f9128682 (patch) | |
| tree | 702e2d39bc32f37a7d953243f876e19c89ffae13 /arch/mips/netlogic | |
| parent | 65fecc2725e5c8d5ef988d971b798b28b94e1865 (diff) | |
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>
Diffstat (limited to 'arch/mips/netlogic')
| -rw-r--r-- | arch/mips/netlogic/common/irq.c | 10 | ||||
| -rw-r--r-- | arch/mips/netlogic/common/smp.c | 26 | ||||
| -rw-r--r-- | arch/mips/netlogic/xlp/setup.c | 5 | ||||
| -rw-r--r-- | arch/mips/netlogic/xlp/wakeup.c | 8 |
4 files changed, 23 insertions, 26 deletions
diff --git a/arch/mips/netlogic/common/irq.c b/arch/mips/netlogic/common/irq.c index c100b9afa0ab..5f5d18b0e94d 100644 --- a/arch/mips/netlogic/common/irq.c +++ b/arch/mips/netlogic/common/irq.c | |||
| @@ -230,16 +230,16 @@ static void nlm_init_node_irqs(int node) | |||
| 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); | 237 | cpu = hwtid % nlm_threads_per_node(); |
| 238 | cpu = hwcpuid % nlm_threads_per_node(); | 238 | node = hwtid / nlm_threads_per_node(); |
| 239 | 239 | ||
| 240 | if (cpu == 0 && node != 0) | 240 | if (cpu == 0 && node != 0) |
| 241 | nlm_init_node_irqs(node); | 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 | asmlinkage void plat_irq_dispatch(void) | 245 | asmlinkage void plat_irq_dispatch(void) |
diff --git a/arch/mips/netlogic/common/smp.c b/arch/mips/netlogic/common/smp.c index 32f15aba745a..dc3e327fbbac 100644 --- a/arch/mips/netlogic/common/smp.c +++ b/arch/mips/netlogic/common/smp.c | |||
| @@ -59,17 +59,17 @@ | |||
| 59 | 59 | ||
| 60 | void nlm_send_ipi_single(int logical_cpu, unsigned int action) | 60 | void nlm_send_ipi_single(int logical_cpu, unsigned int action) |
| 61 | { | 61 | { |
| 62 | int cpu, node; | 62 | unsigned int hwtid; |
| 63 | uint64_t picbase; | 63 | uint64_t picbase; |
| 64 | 64 | ||
| 65 | cpu = cpu_logical_map(logical_cpu); | 65 | /* node id is part of hwtid, and needed for send_ipi */ |
| 66 | node = nlm_cpuid_to_node(cpu); | 66 | hwtid = cpu_logical_map(logical_cpu); |
| 67 | picbase = nlm_get_node(node)->picbase; | 67 | picbase = nlm_get_node(nlm_hwtid_to_node(hwtid))->picbase; |
| 68 | 68 | ||
| 69 | if (action & SMP_CALL_FUNCTION) | 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 | if (action & SMP_RESCHEDULE_YOURSELF) | 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 | void nlm_send_ipi_mask(const struct cpumask *mask, unsigned int action) | 75 | void nlm_send_ipi_mask(const struct cpumask *mask, unsigned int action) |
| @@ -120,7 +120,7 @@ static void nlm_init_secondary(void) | |||
| 120 | 120 | ||
| 121 | hwtid = hard_smp_processor_id(); | 121 | hwtid = hard_smp_processor_id(); |
| 122 | current_cpu_data.core = hwtid / NLM_THREADS_PER_CORE; | 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 | nlm_percpu_init(hwtid); | 124 | nlm_percpu_init(hwtid); |
| 125 | nlm_smp_irq_init(hwtid); | 125 | nlm_smp_irq_init(hwtid); |
| 126 | } | 126 | } |
| @@ -146,16 +146,18 @@ static cpumask_t phys_cpu_present_mask; | |||
| 146 | 146 | ||
| 147 | void nlm_boot_secondary(int logical_cpu, struct task_struct *idle) | 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; | ||
| 151 | |||
| 152 | hwtid = cpu_logical_map(logical_cpu); | ||
| 153 | picbase = nlm_get_node(nlm_hwtid_to_node(hwtid))->picbase; | ||
| 150 | 154 | ||
| 151 | cpu = cpu_logical_map(logical_cpu); | ||
| 152 | node = nlm_cpuid_to_node(logical_cpu); | ||
| 153 | nlm_next_sp = (unsigned long)__KSTK_TOS(idle); | 155 | nlm_next_sp = (unsigned long)__KSTK_TOS(idle); |
| 154 | nlm_next_gp = (unsigned long)task_thread_info(idle); | 156 | nlm_next_gp = (unsigned long)task_thread_info(idle); |
| 155 | 157 | ||
| 156 | /* barrier for sp/gp store above */ | 158 | /* barrier for sp/gp store above */ |
| 157 | __sync(); | 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 | void __init nlm_smp_setup(void) | 163 | void __init nlm_smp_setup(void) |
| @@ -183,7 +185,7 @@ void __init nlm_smp_setup(void) | |||
| 183 | __cpu_number_map[i] = num_cpus; | 185 | __cpu_number_map[i] = num_cpus; |
| 184 | __cpu_logical_map[num_cpus] = i; | 186 | __cpu_logical_map[num_cpus] = i; |
| 185 | set_cpu_possible(num_cpus, true); | 187 | set_cpu_possible(num_cpus, true); |
| 186 | node = nlm_cpuid_to_node(i); | 188 | node = nlm_hwtid_to_node(i); |
| 187 | cpumask_set_cpu(num_cpus, &nlm_get_node(node)->cpumask); | 189 | cpumask_set_cpu(num_cpus, &nlm_get_node(node)->cpumask); |
| 188 | ++num_cpus; | 190 | ++num_cpus; |
| 189 | } | 191 | } |
diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c index 4fdd9fd29d1d..27113a17f18d 100644 --- a/arch/mips/netlogic/xlp/setup.c +++ b/arch/mips/netlogic/xlp/setup.c | |||
| @@ -51,7 +51,6 @@ uint64_t nlm_io_base; | |||
| 51 | struct nlm_soc_info nlm_nodes[NLM_NR_NODES]; | 51 | struct nlm_soc_info nlm_nodes[NLM_NR_NODES]; |
| 52 | cpumask_t nlm_cpumask = CPU_MASK_CPU0; | 52 | cpumask_t nlm_cpumask = CPU_MASK_CPU0; |
| 53 | unsigned int nlm_threads_per_core; | 53 | unsigned int nlm_threads_per_core; |
| 54 | unsigned int xlp_cores_per_node; | ||
| 55 | 54 | ||
| 56 | static void nlm_linux_exit(void) | 55 | static void nlm_linux_exit(void) |
| 57 | { | 56 | { |
| @@ -163,10 +162,6 @@ void __init prom_init(void) | |||
| 163 | void *reset_vec; | 162 | void *reset_vec; |
| 164 | 163 | ||
| 165 | nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE); | 164 | nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE); |
| 166 | if (cpu_is_xlp9xx()) | ||
| 167 | xlp_cores_per_node = 32; | ||
| 168 | else | ||
| 169 | xlp_cores_per_node = 8; | ||
| 170 | nlm_init_boot_cpu(); | 165 | nlm_init_boot_cpu(); |
| 171 | xlp_mmu_init(); | 166 | xlp_mmu_init(); |
| 172 | nlm_node_init(0); | 167 | nlm_node_init(0); |
diff --git a/arch/mips/netlogic/xlp/wakeup.c b/arch/mips/netlogic/xlp/wakeup.c index 26d82f79ef29..87d7846af2d0 100644 --- a/arch/mips/netlogic/xlp/wakeup.c +++ b/arch/mips/netlogic/xlp/wakeup.c | |||
| @@ -111,7 +111,7 @@ static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask) | |||
| 111 | struct nlm_soc_info *nodep; | 111 | struct nlm_soc_info *nodep; |
| 112 | uint64_t syspcibase, fusebase; | 112 | uint64_t syspcibase, fusebase; |
| 113 | uint32_t syscoremask, mask, fusemask; | 113 | uint32_t syscoremask, mask, fusemask; |
| 114 | int core, n, cpu; | 114 | int core, n, cpu, ncores; |
| 115 | 115 | ||
| 116 | for (n = 0; n < NLM_NR_NODES; n++) { | 116 | for (n = 0; n < NLM_NR_NODES; n++) { |
| 117 | if (n != 0) { | 117 | if (n != 0) { |
| @@ -168,7 +168,8 @@ static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask) | |||
| 168 | syscoremask = (1 << hweight32(~fusemask & mask)) - 1; | 168 | syscoremask = (1 << hweight32(~fusemask & mask)) - 1; |
| 169 | 169 | ||
| 170 | pr_info("Node %d - SYS/FUSE coremask %x\n", n, syscoremask); | 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 | /* we will be on node 0 core 0 */ | 173 | /* we will be on node 0 core 0 */ |
| 173 | if (n == 0 && core == 0) | 174 | if (n == 0 && core == 0) |
| 174 | continue; | 175 | continue; |
| @@ -178,8 +179,7 @@ static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask) | |||
| 178 | continue; | 179 | continue; |
| 179 | 180 | ||
| 180 | /* see if at least the first hw thread is enabled */ | 181 | /* see if at least the first hw thread is enabled */ |
| 181 | cpu = (n * nlm_cores_per_node() + core) | 182 | cpu = (n * ncores + core) * NLM_THREADS_PER_CORE; |
| 182 | * NLM_THREADS_PER_CORE; | ||
| 183 | if (!cpumask_test_cpu(cpu, wakeup_mask)) | 183 | if (!cpumask_test_cpu(cpu, wakeup_mask)) |
| 184 | continue; | 184 | continue; |
| 185 | 185 | ||
