diff options
author | Jayachandran C <jchandra@broadcom.com> | 2012-10-31 08:01:37 -0400 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2012-11-09 05:37:19 -0500 |
commit | 2a37b1ae443f20470a789b12a45cbc249c9e50a6 (patch) | |
tree | 101eacbdbc8a34ae7bcd0da8950972165f00d253 /arch | |
parent | 7143246e9ace7f6b50aad217289dd64b7a44dd2c (diff) |
MIPS: Netlogic: Move from u32 cpumask to cpumask_t
Initial code to support more than 32 cpus. The platform CPU mask
is updated from 32-bit mask to cpumask_t. Convert places that use
cpu_/cpus_ functions to use cpumask_* functions.
Signed-off-by: Jayachandran C <jchandra@broadcom.com>
Patchwork: http://patchwork.linux-mips.org/patch/4464
Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/include/asm/netlogic/common.h | 7 | ||||
-rw-r--r-- | arch/mips/netlogic/common/smp.c | 39 | ||||
-rw-r--r-- | arch/mips/netlogic/xlp/setup.c | 6 | ||||
-rw-r--r-- | arch/mips/netlogic/xlp/wakeup.c | 77 | ||||
-rw-r--r-- | arch/mips/netlogic/xlr/setup.c | 10 | ||||
-rw-r--r-- | arch/mips/netlogic/xlr/wakeup.c | 2 |
6 files changed, 86 insertions, 55 deletions
diff --git a/arch/mips/include/asm/netlogic/common.h b/arch/mips/include/asm/netlogic/common.h index fdd2f44c7b59..fd735bcac3e6 100644 --- a/arch/mips/include/asm/netlogic/common.h +++ b/arch/mips/include/asm/netlogic/common.h | |||
@@ -45,6 +45,8 @@ | |||
45 | #define BOOT_NMI_HANDLER 8 | 45 | #define BOOT_NMI_HANDLER 8 |
46 | 46 | ||
47 | #ifndef __ASSEMBLY__ | 47 | #ifndef __ASSEMBLY__ |
48 | #include <linux/cpumask.h> | ||
49 | |||
48 | struct irq_desc; | 50 | struct irq_desc; |
49 | extern struct plat_smp_ops nlm_smp_ops; | 51 | extern struct plat_smp_ops nlm_smp_ops; |
50 | extern char nlm_reset_entry[], nlm_reset_entry_end[]; | 52 | extern char nlm_reset_entry[], nlm_reset_entry_end[]; |
@@ -52,7 +54,7 @@ void nlm_smp_function_ipi_handler(unsigned int irq, struct irq_desc *desc); | |||
52 | void nlm_smp_resched_ipi_handler(unsigned int irq, struct irq_desc *desc); | 54 | void nlm_smp_resched_ipi_handler(unsigned int irq, struct irq_desc *desc); |
53 | void nlm_smp_irq_init(void); | 55 | void nlm_smp_irq_init(void); |
54 | void nlm_boot_secondary_cpus(void); | 56 | void nlm_boot_secondary_cpus(void); |
55 | int nlm_wakeup_secondary_cpus(u32 wakeup_mask); | 57 | int nlm_wakeup_secondary_cpus(void); |
56 | void nlm_rmiboot_preboot(void); | 58 | void nlm_rmiboot_preboot(void); |
57 | 59 | ||
58 | static inline void | 60 | static inline void |
@@ -71,6 +73,7 @@ unsigned int nlm_get_cpu_frequency(void); | |||
71 | 73 | ||
72 | extern unsigned long nlm_common_ebase; | 74 | extern unsigned long nlm_common_ebase; |
73 | extern int nlm_threads_per_core; | 75 | extern int nlm_threads_per_core; |
74 | extern uint32_t nlm_cpumask, nlm_coremask; | 76 | extern uint32_t nlm_coremask; |
77 | extern cpumask_t nlm_cpumask; | ||
75 | #endif | 78 | #endif |
76 | #endif /* _NETLOGIC_COMMON_H_ */ | 79 | #endif /* _NETLOGIC_COMMON_H_ */ |
diff --git a/arch/mips/netlogic/common/smp.c b/arch/mips/netlogic/common/smp.c index cd39f5429e8a..4fe8992b291c 100644 --- a/arch/mips/netlogic/common/smp.c +++ b/arch/mips/netlogic/common/smp.c | |||
@@ -160,9 +160,9 @@ void __init nlm_smp_setup(void) | |||
160 | int num_cpus, i; | 160 | int num_cpus, i; |
161 | 161 | ||
162 | boot_cpu = hard_smp_processor_id(); | 162 | boot_cpu = hard_smp_processor_id(); |
163 | cpus_clear(phys_cpu_present_map); | 163 | cpumask_clear(&phys_cpu_present_map); |
164 | 164 | ||
165 | cpu_set(boot_cpu, phys_cpu_present_map); | 165 | cpumask_set_cpu(boot_cpu, &phys_cpu_present_map); |
166 | __cpu_number_map[boot_cpu] = 0; | 166 | __cpu_number_map[boot_cpu] = 0; |
167 | __cpu_logical_map[0] = boot_cpu; | 167 | __cpu_logical_map[0] = boot_cpu; |
168 | set_cpu_possible(0, true); | 168 | set_cpu_possible(0, true); |
@@ -174,7 +174,7 @@ void __init nlm_smp_setup(void) | |||
174 | * it is only set for ASPs (see smpboot.S) | 174 | * it is only set for ASPs (see smpboot.S) |
175 | */ | 175 | */ |
176 | if (nlm_cpu_ready[i]) { | 176 | if (nlm_cpu_ready[i]) { |
177 | cpu_set(i, phys_cpu_present_map); | 177 | cpumask_set_cpu(i, &phys_cpu_present_map); |
178 | __cpu_number_map[i] = num_cpus; | 178 | __cpu_number_map[i] = num_cpus; |
179 | __cpu_logical_map[num_cpus] = i; | 179 | __cpu_logical_map[num_cpus] = i; |
180 | set_cpu_possible(num_cpus, true); | 180 | set_cpu_possible(num_cpus, true); |
@@ -183,19 +183,22 @@ void __init nlm_smp_setup(void) | |||
183 | } | 183 | } |
184 | 184 | ||
185 | pr_info("Phys CPU present map: %lx, possible map %lx\n", | 185 | pr_info("Phys CPU present map: %lx, possible map %lx\n", |
186 | (unsigned long)phys_cpu_present_map.bits[0], | 186 | (unsigned long)cpumask_bits(&phys_cpu_present_map)[0], |
187 | (unsigned long)cpumask_bits(cpu_possible_mask)[0]); | 187 | (unsigned long)cpumask_bits(cpu_possible_mask)[0]); |
188 | 188 | ||
189 | pr_info("Detected %i Slave CPU(s)\n", num_cpus); | 189 | pr_info("Detected %i Slave CPU(s)\n", num_cpus); |
190 | nlm_set_nmi_handler(nlm_boot_secondary_cpus); | 190 | nlm_set_nmi_handler(nlm_boot_secondary_cpus); |
191 | } | 191 | } |
192 | 192 | ||
193 | static int nlm_parse_cpumask(u32 cpu_mask) | 193 | static int nlm_parse_cpumask(cpumask_t *wakeup_mask) |
194 | { | 194 | { |
195 | uint32_t core0_thr_mask, core_thr_mask; | 195 | uint32_t core0_thr_mask, core_thr_mask; |
196 | int threadmode, i; | 196 | int threadmode, i, j; |
197 | 197 | ||
198 | core0_thr_mask = cpu_mask & 0xf; | 198 | core0_thr_mask = 0; |
199 | for (i = 0; i < 4; i++) | ||
200 | if (cpumask_test_cpu(i, wakeup_mask)) | ||
201 | core0_thr_mask |= (1 << i); | ||
199 | switch (core0_thr_mask) { | 202 | switch (core0_thr_mask) { |
200 | case 1: | 203 | case 1: |
201 | nlm_threads_per_core = 1; | 204 | nlm_threads_per_core = 1; |
@@ -214,25 +217,23 @@ static int nlm_parse_cpumask(u32 cpu_mask) | |||
214 | } | 217 | } |
215 | 218 | ||
216 | /* Verify other cores CPU masks */ | 219 | /* Verify other cores CPU masks */ |
217 | nlm_coremask = 1; | 220 | for (i = 0; i < NR_CPUS; i += 4) { |
218 | nlm_cpumask = core0_thr_mask; | 221 | core_thr_mask = 0; |
219 | for (i = 1; i < 8; i++) { | 222 | for (j = 0; j < 4; j++) |
220 | core_thr_mask = (cpu_mask >> (i * 4)) & 0xf; | 223 | if (cpumask_test_cpu(i + j, wakeup_mask)) |
221 | if (core_thr_mask) { | 224 | core_thr_mask |= (1 << j); |
222 | if (core_thr_mask != core0_thr_mask) | 225 | if (core_thr_mask != 0 && core_thr_mask != core0_thr_mask) |
223 | goto unsupp; | 226 | goto unsupp; |
224 | nlm_coremask |= 1 << i; | ||
225 | nlm_cpumask |= core0_thr_mask << (4 * i); | ||
226 | } | ||
227 | } | 227 | } |
228 | return threadmode; | 228 | return threadmode; |
229 | 229 | ||
230 | unsupp: | 230 | unsupp: |
231 | panic("Unsupported CPU mask %x\n", cpu_mask); | 231 | panic("Unsupported CPU mask %lx\n", |
232 | (unsigned long)cpumask_bits(wakeup_mask)[0]); | ||
232 | return 0; | 233 | return 0; |
233 | } | 234 | } |
234 | 235 | ||
235 | int __cpuinit nlm_wakeup_secondary_cpus(u32 wakeup_mask) | 236 | int __cpuinit nlm_wakeup_secondary_cpus(void) |
236 | { | 237 | { |
237 | unsigned long reset_vec; | 238 | unsigned long reset_vec; |
238 | char *reset_data; | 239 | char *reset_data; |
@@ -244,7 +245,7 @@ int __cpuinit nlm_wakeup_secondary_cpus(u32 wakeup_mask) | |||
244 | (nlm_reset_entry_end - nlm_reset_entry)); | 245 | (nlm_reset_entry_end - nlm_reset_entry)); |
245 | 246 | ||
246 | /* verify the mask and setup core config variables */ | 247 | /* verify the mask and setup core config variables */ |
247 | threadmode = nlm_parse_cpumask(wakeup_mask); | 248 | threadmode = nlm_parse_cpumask(&nlm_cpumask); |
248 | 249 | ||
249 | /* Setup CPU init parameters */ | 250 | /* Setup CPU init parameters */ |
250 | reset_data = (char *)CKSEG1ADDR(RESET_DATA_PHYS); | 251 | reset_data = (char *)CKSEG1ADDR(RESET_DATA_PHYS); |
diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c index b886a508f85a..9f8d360a246e 100644 --- a/arch/mips/netlogic/xlp/setup.c +++ b/arch/mips/netlogic/xlp/setup.c | |||
@@ -55,7 +55,8 @@ | |||
55 | unsigned long nlm_common_ebase = 0x0; | 55 | unsigned long nlm_common_ebase = 0x0; |
56 | 56 | ||
57 | /* default to uniprocessor */ | 57 | /* default to uniprocessor */ |
58 | uint32_t nlm_coremask = 1, nlm_cpumask = 1; | 58 | uint32_t nlm_coremask = 1; |
59 | cpumask_t nlm_cpumask = CPU_MASK_CPU0; | ||
59 | int nlm_threads_per_core = 1; | 60 | int nlm_threads_per_core = 1; |
60 | extern u32 __dtb_start[]; | 61 | extern u32 __dtb_start[]; |
61 | 62 | ||
@@ -115,7 +116,8 @@ void __init prom_init(void) | |||
115 | nlm_common_ebase = read_c0_ebase() & (~((1 << 12) - 1)); | 116 | nlm_common_ebase = read_c0_ebase() & (~((1 << 12) - 1)); |
116 | 117 | ||
117 | #ifdef CONFIG_SMP | 118 | #ifdef CONFIG_SMP |
118 | nlm_wakeup_secondary_cpus(0xffffffff); | 119 | cpumask_setall(&nlm_cpumask); |
120 | nlm_wakeup_secondary_cpus(); | ||
119 | 121 | ||
120 | /* update TLB size after waking up threads */ | 122 | /* update TLB size after waking up threads */ |
121 | current_cpu_data.tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1; | 123 | current_cpu_data.tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1; |
diff --git a/arch/mips/netlogic/xlp/wakeup.c b/arch/mips/netlogic/xlp/wakeup.c index 44d923ff3846..88ce38d096f0 100644 --- a/arch/mips/netlogic/xlp/wakeup.c +++ b/arch/mips/netlogic/xlp/wakeup.c | |||
@@ -51,45 +51,66 @@ | |||
51 | #include <asm/netlogic/xlp-hal/xlp.h> | 51 | #include <asm/netlogic/xlp-hal/xlp.h> |
52 | #include <asm/netlogic/xlp-hal/sys.h> | 52 | #include <asm/netlogic/xlp-hal/sys.h> |
53 | 53 | ||
54 | static void xlp_enable_secondary_cores(void) | 54 | static int xlp_wakeup_core(uint64_t sysbase, int core) |
55 | { | 55 | { |
56 | uint32_t core, value, coremask, syscoremask; | 56 | uint32_t coremask, value; |
57 | int count; | 57 | int count; |
58 | 58 | ||
59 | /* read cores in reset from SYS block */ | 59 | coremask = (1 << core); |
60 | syscoremask = nlm_read_sys_reg(nlm_sys_base, SYS_CPU_RESET); | ||
61 | 60 | ||
62 | /* update user specified */ | 61 | /* Enable CPU clock */ |
63 | nlm_coremask = nlm_coremask & (syscoremask | 1); | 62 | value = nlm_read_sys_reg(sysbase, SYS_CORE_DFS_DIS_CTRL); |
63 | value &= ~coremask; | ||
64 | nlm_write_sys_reg(sysbase, SYS_CORE_DFS_DIS_CTRL, value); | ||
64 | 65 | ||
65 | for (core = 1; core < 8; core++) { | 66 | /* Remove CPU Reset */ |
66 | coremask = 1 << core; | 67 | value = nlm_read_sys_reg(sysbase, SYS_CPU_RESET); |
67 | if ((nlm_coremask & coremask) == 0) | 68 | value &= ~coremask; |
68 | continue; | 69 | nlm_write_sys_reg(sysbase, SYS_CPU_RESET, value); |
69 | 70 | ||
70 | /* Enable CPU clock */ | 71 | /* Poll for CPU to mark itself coherent */ |
71 | value = nlm_read_sys_reg(nlm_sys_base, SYS_CORE_DFS_DIS_CTRL); | 72 | count = 100000; |
72 | value &= ~coremask; | 73 | do { |
73 | nlm_write_sys_reg(nlm_sys_base, SYS_CORE_DFS_DIS_CTRL, value); | 74 | value = nlm_read_sys_reg(sysbase, SYS_CPU_NONCOHERENT_MODE); |
75 | } while ((value & coremask) != 0 && --count > 0); | ||
74 | 76 | ||
75 | /* Remove CPU Reset */ | 77 | return count != 0; |
76 | value = nlm_read_sys_reg(nlm_sys_base, SYS_CPU_RESET); | 78 | } |
77 | value &= ~coremask; | 79 | |
78 | nlm_write_sys_reg(nlm_sys_base, SYS_CPU_RESET, value); | 80 | static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask) |
81 | { | ||
82 | uint64_t syspcibase, sysbase; | ||
83 | uint32_t syscoremask; | ||
84 | int core, n; | ||
85 | |||
86 | for (n = 0; n < 4; n++) { | ||
87 | syspcibase = nlm_get_sys_pcibase(n); | ||
88 | if (nlm_read_reg(syspcibase, 0) == 0xffffffff) | ||
89 | break; | ||
90 | |||
91 | /* read cores in reset from SYS and account for boot cpu */ | ||
92 | sysbase = nlm_get_sys_regbase(n); | ||
93 | syscoremask = nlm_read_sys_reg(sysbase, SYS_CPU_RESET); | ||
94 | if (n == 0) | ||
95 | syscoremask |= 1; | ||
96 | |||
97 | for (core = 0; core < 8; core++) { | ||
98 | /* see if the core exists */ | ||
99 | if ((syscoremask & (1 << core)) == 0) | ||
100 | continue; | ||
79 | 101 | ||
80 | /* Poll for CPU to mark itself coherent */ | 102 | /* see if at least the first thread is enabled */ |
81 | count = 100000; | 103 | if (!cpumask_test_cpu((n * 8 + core) * 4, wakeup_mask)) |
82 | do { | 104 | continue; |
83 | value = nlm_read_sys_reg(nlm_sys_base, | ||
84 | SYS_CPU_NONCOHERENT_MODE); | ||
85 | } while ((value & coremask) != 0 && count-- > 0); | ||
86 | 105 | ||
87 | if (count == 0) | 106 | /* wake up the core */ |
88 | pr_err("Failed to enable core %d\n", core); | 107 | if (!xlp_wakeup_core(sysbase, core)) |
108 | pr_err("Failed to enable core %d\n", core); | ||
109 | } | ||
89 | } | 110 | } |
90 | } | 111 | } |
91 | 112 | ||
92 | void xlp_wakeup_secondary_cpus(void) | 113 | void xlp_wakeup_secondary_cpus() |
93 | { | 114 | { |
94 | /* | 115 | /* |
95 | * In case of u-boot, the secondaries are in reset | 116 | * In case of u-boot, the secondaries are in reset |
@@ -98,5 +119,5 @@ void xlp_wakeup_secondary_cpus(void) | |||
98 | xlp_boot_core0_siblings(); | 119 | xlp_boot_core0_siblings(); |
99 | 120 | ||
100 | /* now get other cores out of reset */ | 121 | /* now get other cores out of reset */ |
101 | xlp_enable_secondary_cores(); | 122 | xlp_enable_secondary_cores(&nlm_cpumask); |
102 | } | 123 | } |
diff --git a/arch/mips/netlogic/xlr/setup.c b/arch/mips/netlogic/xlr/setup.c index 81b1d311834f..8fca6807cab8 100644 --- a/arch/mips/netlogic/xlr/setup.c +++ b/arch/mips/netlogic/xlr/setup.c | |||
@@ -57,8 +57,9 @@ struct psb_info nlm_prom_info; | |||
57 | unsigned long nlm_common_ebase = 0x0; | 57 | unsigned long nlm_common_ebase = 0x0; |
58 | 58 | ||
59 | /* default to uniprocessor */ | 59 | /* default to uniprocessor */ |
60 | uint32_t nlm_coremask = 1, nlm_cpumask = 1; | 60 | uint32_t nlm_coremask = 1; |
61 | int nlm_threads_per_core = 1; | 61 | int nlm_threads_per_core = 1; |
62 | cpumask_t nlm_cpumask = CPU_MASK_CPU0; | ||
62 | 63 | ||
63 | static void __init nlm_early_serial_setup(void) | 64 | static void __init nlm_early_serial_setup(void) |
64 | { | 65 | { |
@@ -178,7 +179,7 @@ static void prom_add_memory(void) | |||
178 | 179 | ||
179 | void __init prom_init(void) | 180 | void __init prom_init(void) |
180 | { | 181 | { |
181 | int *argv, *envp; /* passed as 32 bit ptrs */ | 182 | int i, *argv, *envp; /* passed as 32 bit ptrs */ |
182 | struct psb_info *prom_infop; | 183 | struct psb_info *prom_infop; |
183 | 184 | ||
184 | /* truncate to 32 bit and sign extend all args */ | 185 | /* truncate to 32 bit and sign extend all args */ |
@@ -195,7 +196,10 @@ void __init prom_init(void) | |||
195 | prom_add_memory(); | 196 | prom_add_memory(); |
196 | 197 | ||
197 | #ifdef CONFIG_SMP | 198 | #ifdef CONFIG_SMP |
198 | nlm_wakeup_secondary_cpus(nlm_prom_info.online_cpu_map); | 199 | for (i = 0; i < 32; i++) |
200 | if (nlm_prom_info.online_cpu_map & (1 << i)) | ||
201 | cpumask_set_cpu(i, &nlm_cpumask); | ||
202 | nlm_wakeup_secondary_cpus(); | ||
199 | register_smp_ops(&nlm_smp_ops); | 203 | register_smp_ops(&nlm_smp_ops); |
200 | #endif | 204 | #endif |
201 | } | 205 | } |
diff --git a/arch/mips/netlogic/xlr/wakeup.c b/arch/mips/netlogic/xlr/wakeup.c index db5d987d4881..0878924da153 100644 --- a/arch/mips/netlogic/xlr/wakeup.c +++ b/arch/mips/netlogic/xlr/wakeup.c | |||
@@ -59,7 +59,7 @@ int __cpuinit xlr_wakeup_secondary_cpus(void) | |||
59 | boot_cpu = hard_smp_processor_id(); | 59 | boot_cpu = hard_smp_processor_id(); |
60 | nlm_set_nmi_handler(nlm_rmiboot_preboot); | 60 | nlm_set_nmi_handler(nlm_rmiboot_preboot); |
61 | for (i = 0; i < NR_CPUS; i++) { | 61 | for (i = 0; i < NR_CPUS; i++) { |
62 | if (i == boot_cpu || (nlm_cpumask & (1u << i)) == 0) | 62 | if (i == boot_cpu || !cpumask_test_cpu(i, &nlm_cpumask)) |
63 | continue; | 63 | continue; |
64 | nlm_pic_send_ipi(nlm_pic_base, i, 1, 1); /* send NMI */ | 64 | nlm_pic_send_ipi(nlm_pic_base, i, 1, 1); /* send NMI */ |
65 | } | 65 | } |