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

MIPS: SMP: Allow boot_secondary SMP op to return errors

Allow the boot_secondary SMP op to return an error to __cpu_up(), which
will in turn return it to its caller.

This will allow SMP implementations to return errors quickly in cases
they they know have failed, rather than relying upon __cpu_up()
eventually timing out waiting for the cpu_running completion.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/17014/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Paul Burton and committed by
Ralf Baechle
d595d423 68923cdc

+37 -15
+6 -2
arch/mips/cavium-octeon/smp.c
··· 205 205 * Firmware CPU startup hook 206 206 * 207 207 */ 208 - static void octeon_boot_secondary(int cpu, struct task_struct *idle) 208 + static int octeon_boot_secondary(int cpu, struct task_struct *idle) 209 209 { 210 210 int count; 211 211 ··· 223 223 udelay(1); 224 224 count--; 225 225 } 226 - if (count == 0) 226 + if (count == 0) { 227 227 pr_err("Secondary boot timeout\n"); 228 + return -ETIMEDOUT; 229 + } 230 + 231 + return 0; 228 232 } 229 233 230 234 /**
+1 -1
arch/mips/include/asm/smp-ops.h
··· 26 26 void (*send_ipi_mask)(const struct cpumask *mask, unsigned int action); 27 27 void (*init_secondary)(void); 28 28 void (*smp_finish)(void); 29 - void (*boot_secondary)(int cpu, struct task_struct *idle); 29 + int (*boot_secondary)(int cpu, struct task_struct *idle); 30 30 void (*smp_setup)(void); 31 31 void (*prepare_cpus)(unsigned int max_cpus); 32 32 #ifdef CONFIG_HOTPLUG_CPU
+3 -1
arch/mips/kernel/smp-bmips.c
··· 179 179 /* 180 180 * Tell the hardware to boot CPUx - runs on CPU0 181 181 */ 182 - static void bmips_boot_secondary(int cpu, struct task_struct *idle) 182 + static int bmips_boot_secondary(int cpu, struct task_struct *idle) 183 183 { 184 184 bmips_smp_boot_sp = __KSTK_TOS(idle); 185 185 bmips_smp_boot_gp = (unsigned long)task_thread_info(idle); ··· 231 231 } 232 232 cpumask_set_cpu(cpu, &bmips_booted_mask); 233 233 } 234 + 235 + return 0; 234 236 } 235 237 236 238 /*
+2 -1
arch/mips/kernel/smp-cmp.c
··· 78 78 * __KSTK_TOS(idle) is apparently the stack pointer 79 79 * (unsigned long)idle->thread_info the gp 80 80 */ 81 - static void cmp_boot_secondary(int cpu, struct task_struct *idle) 81 + static int cmp_boot_secondary(int cpu, struct task_struct *idle) 82 82 { 83 83 struct thread_info *gp = task_thread_info(idle); 84 84 unsigned long sp = __KSTK_TOS(idle); ··· 95 95 #endif 96 96 97 97 amon_cpu_start(cpu, pc, sp, (unsigned long)gp, a0); 98 + return 0; 98 99 } 99 100 100 101 /*
+2 -1
arch/mips/kernel/smp-cps.c
··· 288 288 mips_cps_boot_vpes(core_cfg, cpu_vpe_id(&current_cpu_data)); 289 289 } 290 290 291 - static void cps_boot_secondary(int cpu, struct task_struct *idle) 291 + static int cps_boot_secondary(int cpu, struct task_struct *idle) 292 292 { 293 293 unsigned core = cpu_core(&cpu_data[cpu]); 294 294 unsigned vpe_id = cpu_vpe_id(&cpu_data[cpu]); ··· 346 346 mips_cps_boot_vpes(core_cfg, vpe_id); 347 347 out: 348 348 preempt_enable(); 349 + return 0; 349 350 } 350 351 351 352 static void cps_init_secondary(void)
+3 -1
arch/mips/kernel/smp-mt.c
··· 152 152 * (unsigned long)idle->thread_info the gp 153 153 * assumes a 1:1 mapping of TC => VPE 154 154 */ 155 - static void vsmp_boot_secondary(int cpu, struct task_struct *idle) 155 + static int vsmp_boot_secondary(int cpu, struct task_struct *idle) 156 156 { 157 157 struct thread_info *gp = task_thread_info(idle); 158 158 dvpe(); ··· 184 184 clear_c0_mvpcontrol(MVPCONTROL_VPC); 185 185 186 186 evpe(EVPE_ENABLE); 187 + 188 + return 0; 187 189 } 188 190 189 191 /*
+2 -1
arch/mips/kernel/smp-up.c
··· 39 39 /* 40 40 * Firmware CPU startup hook 41 41 */ 42 - static void up_boot_secondary(int cpu, struct task_struct *idle) 42 + static int up_boot_secondary(int cpu, struct task_struct *idle) 43 43 { 44 + return 0; 44 45 } 45 46 46 47 static void __init up_smp_setup(void)
+5 -1
arch/mips/kernel/smp.c
··· 439 439 440 440 int __cpu_up(unsigned int cpu, struct task_struct *tidle) 441 441 { 442 - mp_ops->boot_secondary(cpu, tidle); 442 + int err; 443 + 444 + err = mp_ops->boot_secondary(cpu, tidle); 445 + if (err) 446 + return err; 443 447 444 448 /* 445 449 * We must check for timeout here, as the CPU will not be marked
+2 -1
arch/mips/loongson64/loongson-3/smp.c
··· 400 400 /* 401 401 * Setup the PC, SP, and GP of a secondary processor and start it runing! 402 402 */ 403 - static void loongson3_boot_secondary(int cpu, struct task_struct *idle) 403 + static int loongson3_boot_secondary(int cpu, struct task_struct *idle) 404 404 { 405 405 unsigned long startargs[4]; 406 406 ··· 423 423 (void *)(ipi_mailbox_buf[cpu_logical_map(cpu)]+0x8)); 424 424 loongson3_ipi_write64(startargs[0], 425 425 (void *)(ipi_mailbox_buf[cpu_logical_map(cpu)]+0x0)); 426 + return 0; 426 427 } 427 428 428 429 #ifdef CONFIG_HOTPLUG_CPU
+3 -1
arch/mips/netlogic/common/smp.c
··· 147 147 unsigned long nlm_next_sp; 148 148 static cpumask_t phys_cpu_present_mask; 149 149 150 - void nlm_boot_secondary(int logical_cpu, struct task_struct *idle) 150 + int nlm_boot_secondary(int logical_cpu, struct task_struct *idle) 151 151 { 152 152 uint64_t picbase; 153 153 int hwtid; ··· 161 161 /* barrier for sp/gp store above */ 162 162 __sync(); 163 163 nlm_pic_send_ipi(picbase, hwtid, 1, 1); /* NMI */ 164 + 165 + return 0; 164 166 } 165 167 166 168 void __init nlm_smp_setup(void)
+2 -1
arch/mips/paravirt/paravirt-smp.c
··· 100 100 local_irq_enable(); 101 101 } 102 102 103 - static void paravirt_boot_secondary(int cpu, struct task_struct *idle) 103 + static int paravirt_boot_secondary(int cpu, struct task_struct *idle) 104 104 { 105 105 paravirt_smp_gp[cpu] = (unsigned long)task_thread_info(idle); 106 106 smp_wmb(); 107 107 paravirt_smp_sp[cpu] = __KSTK_TOS(idle); 108 + return 0; 108 109 } 109 110 110 111 static irqreturn_t paravirt_reched_interrupt(int irq, void *dev_id)
+2 -1
arch/mips/sgi-ip27/ip27-smp.c
··· 195 195 * set sp to the kernel stack of the newly created idle process, gp to the proc 196 196 * struct so that current_thread_info() will work. 197 197 */ 198 - static void ip27_boot_secondary(int cpu, struct task_struct *idle) 198 + static int ip27_boot_secondary(int cpu, struct task_struct *idle) 199 199 { 200 200 unsigned long gp = (unsigned long)task_thread_info(idle); 201 201 unsigned long sp = __KSTK_TOS(idle); ··· 203 203 LAUNCH_SLAVE(cputonasid(cpu), cputoslice(cpu), 204 204 (launch_proc_t)MAPPED_KERN_RW_TO_K0(smp_bootstrap), 205 205 0, (void *) sp, (void *) gp); 206 + return 0; 206 207 } 207 208 208 209 static void __init ip27_smp_setup(void)
+2 -1
arch/mips/sibyte/bcm1480/smp.c
··· 117 117 * Setup the PC, SP, and GP of a secondary processor and start it 118 118 * running! 119 119 */ 120 - static void bcm1480_boot_secondary(int cpu, struct task_struct *idle) 120 + static int bcm1480_boot_secondary(int cpu, struct task_struct *idle) 121 121 { 122 122 int retval; 123 123 ··· 126 126 (unsigned long)task_thread_info(idle), 0); 127 127 if (retval != 0) 128 128 printk("cfe_start_cpu(%i) returned %i\n" , cpu, retval); 129 + return retval; 129 130 } 130 131 131 132 /*
+2 -1
arch/mips/sibyte/sb1250/smp.c
··· 106 106 * Setup the PC, SP, and GP of a secondary processor and start it 107 107 * running! 108 108 */ 109 - static void sb1250_boot_secondary(int cpu, struct task_struct *idle) 109 + static int sb1250_boot_secondary(int cpu, struct task_struct *idle) 110 110 { 111 111 int retval; 112 112 ··· 115 115 (unsigned long)task_thread_info(idle), 0); 116 116 if (retval != 0) 117 117 printk("cfe_start_cpu(%i) returned %i\n" , cpu, retval); 118 + return retval; 118 119 } 119 120 120 121 /*