]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
RISC-V: Do not wait indefinitely in __cpu_up
authorAtish Patra <atish.patra@wdc.com>
Fri, 22 Feb 2019 19:41:35 +0000 (11:41 -0800)
committerPalmer Dabbelt <palmer@sifive.com>
Mon, 4 Mar 2019 18:40:36 +0000 (10:40 -0800)
In SMP path, __cpu_up waits for other CPU to come online indefinitely.
This is wrong as other CPU might be disabled in machine mode and
possible CPU is set to the cpus present in DT.

Introduce a completion variable and waits only for a second.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
arch/riscv/kernel/smpboot.c

index 6e2813257e0375304079f28e26936ff4e275107b..d369b669fe043dd39b579021f751bd2c9d55ed0d 100644 (file)
@@ -39,6 +39,7 @@
 
 void *__cpu_up_stack_pointer[NR_CPUS];
 void *__cpu_up_task_pointer[NR_CPUS];
+static DECLARE_COMPLETION(cpu_running);
 
 void __init smp_prepare_boot_cpu(void)
 {
@@ -77,6 +78,7 @@ void __init setup_smp(void)
 
 int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
+       int ret = 0;
        int hartid = cpuid_to_hartid_map(cpu);
        tidle->thread_info.cpu = cpu;
 
@@ -92,10 +94,16 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
                  task_stack_page(tidle) + THREAD_SIZE);
        WRITE_ONCE(__cpu_up_task_pointer[hartid], tidle);
 
-       while (!cpu_online(cpu))
-               cpu_relax();
+       lockdep_assert_held(&cpu_running);
+       wait_for_completion_timeout(&cpu_running,
+                                           msecs_to_jiffies(1000));
 
-       return 0;
+       if (!cpu_online(cpu)) {
+               pr_crit("CPU%u: failed to come online\n", cpu);
+               ret = -EIO;
+       }
+
+       return ret;
 }
 
 void __init smp_cpus_done(unsigned int max_cpus)
@@ -121,6 +129,7 @@ asmlinkage void __init smp_callin(void)
         * a local TLB flush right now just in case.
         */
        local_flush_tlb_all();
+       complete(&cpu_running);
        /*
         * Disable preemption before enabling interrupts, so we don't try to
         * schedule a CPU that hasn't actually started yet.