Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6097529imu; Wed, 26 Dec 2018 15:10:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN4/pjnTfyW5+XwKsNQhVnXKZt5+p1cQ2WbxpUsJoHq08voyRqWbayo0d0pqKv/v/omgzHSW X-Received: by 2002:a63:6c48:: with SMTP id h69mr19796694pgc.139.1545865848199; Wed, 26 Dec 2018 15:10:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545865848; cv=none; d=google.com; s=arc-20160816; b=fCLHrVtVxwXK9jT24Dlrm7QNBCIvyCnNGg6p8GfgZNYt7/J7J0ReMpi6wixhrGsP4/ ippOHj1fhtE28aSvlOsjn+vqpPwwA9hUNxFqgqWEZF/SwOvsswwp0jdSfPc96OgHigMG 9QHCBeugsZngyDEQq3yg5n13QxRJfH/DV2OzDIJPWWMMuFyxEqNseADa4pqBxsYWHRlX HuBYnccGj58ynENP6xVz435nLH1RsTBIxa9MAlHnLuz4qBOL4aWNfUixUtjjvSiqxMTq YEeEjSs2EMGbE0onGntjspI0xSxmKd+EIiDf9RKvprSZxq+ZJiOVkoJNl6aLAT2m0ett 92wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tcIKnC34eAFiNpEZnWR6qx/9Bpgv6C6GC8QhmKt3ljs=; b=NkLb0QzJG7tQkBv8nQzdqkqWPRraB01KP6UjnEaE06Ie3fs0ZH+GnSJhGG/xfDZcyd dMxL2dvLhndM0LeGciYFPSZVTA/Fd2/jiAg41VuMiIZ8tI0fTwy375ULULKRwQyxRPdG mGvMA6yDzdWh+U9XI44phR7d0BQFI5GejdQ0af4jRcIJ40KP7WX69GfYhLdFRwui0DXI 7NQ1BbCJws7Bo8AsW6rGrVW+tdygsVxciU5SeymnhoAQfj1eUY6EeCTKD3dmvlbPMsjD OChV/pu7HaCyTLaW1Xt7geFbcvELgTi1DTRikwW6eliYmB/dL0nnndDS7Y/tKxhykPHn KHUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="S/NxjHhn"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17si32969608pgj.142.2018.12.26.15.10.33; Wed, 26 Dec 2018 15:10:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="S/NxjHhn"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727980AbeLZXJW (ORCPT + 99 others); Wed, 26 Dec 2018 18:09:22 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:20034 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727737AbeLZXJV (ORCPT ); Wed, 26 Dec 2018 18:09:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545865761; x=1577401761; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=8S/RrFDjuKHkFUQKssSKhJVyNonR+n8bd5mR5vPrqWA=; b=S/NxjHhncpLTxXWaDk3JNW8xHBFZ1F7O+qQX0B2yQD7QwrLan8SQwIgT ng0fm6o62GkCpAl4Y43MczNW+DrMMGwzDl3kYcEU9HiXWmK8lUcZ7IEvM k1QXT9zITTcabildKp5kLtEETPjaE6s0/Sz0tu6dMMowSaHcvgw5jJUrC NgWQup0hwfKMLNTJDg8Kqh4PLbh5Zfc7BV5VhxtukajcJcOJ536+ogjKt Y9+KH7y0UBYTJWe0K0MmLBDv3uH8JJwPVcmOmGyG2+fRm5YZOeQiFEU8I oMni4mDZYqjTAq1ALKDQebEJE+4wKq2eKVGVKvr/h4V6003TNQHlnkO1P A==; X-IronPort-AV: E=Sophos;i="5.56,401,1539619200"; d="scan'208";a="98702974" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 27 Dec 2018 07:09:07 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 26 Dec 2018 14:49:51 -0800 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Dec 2018 15:09:07 -0800 From: Atish Patra To: linux-riscv@lists.infradead.org Cc: Atish Patra , Albert Ou , Anup Patel , Daniel Lezcano , Dmitriy Cherkasov , Jason Cooper , linux-kernel@vger.kernel.org, Marc Zyngier , Michael Clark , Palmer Dabbelt , =?UTF-8?q?Patrick=20St=C3=A4hlin?= , Rob Herring , Thomas Gleixner , Damien Le Moal Subject: [PATCH 1/3] RISC-V: Do not wait indefinitely in __cpu_up Date: Wed, 26 Dec 2018 15:08:59 -0800 Message-Id: <1545865741-22795-2-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545865741-22795-1-git-send-email-atish.patra@wdc.com> References: <1545865741-22795-1-git-send-email-atish.patra@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/riscv/kernel/smpboot.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 18cda0e8..bb8cd242 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -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,15 @@ 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(); + 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 +128,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. -- 2.7.4