Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4530688imu; Tue, 8 Jan 2019 01:41:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN4h+QxCxLfIBrNzSCji8ZJbsXKXaEYwG2LUXg6wQpvfnmXBco/EGpVxOZ0C4qOKUjIj2NfN X-Received: by 2002:a63:6207:: with SMTP id w7mr873937pgb.90.1546940518719; Tue, 08 Jan 2019 01:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546940518; cv=none; d=google.com; s=arc-20160816; b=mGSMLH1AwQYaRbCepPtWBfJAoJ8qLOd9CXd4mg3pGNp9i2p12dvPhX0Fbw+GhgyM/y xm3xWsrr8cQhAu8zjhLXsqXm4hsLF4UmAUZtmiaz2eZhfLh+Dgeecdh+U9t9gPmiGd5l mBgTKgsOk95rCDL2Uzx7GM6caNlMMfifi2g6NtP8bduHIZ6VL8PiuR3L7XbN48ayNciP RLH9UW4hWKz+3WUZst0ZC6nryVs38DVIs4ra6wd9GCoRmYC7MPpp74Zxdq14qMJFzQmR LUMTnH632xRlvlCTjVQgYZ4zS9giPtnvhCpsCSBimLQv5Oq7nWmImLfLdVVAeeH9v5+r 1X+g== 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=ihEqkFs8abbGaoKQWSqJFY43i5ngRId4jO3k6U1scUo=; b=MhpjgR3wX4kT575AiuPXC9j+NhPrpMWGO1+m6WUYemDyaVoR12ubyMiyyNP5QbXNwd 1Wy51uIqm0x9tkWV8g0wIOnFo5fs5fWCin6C6ZD+8n0vPGbbuy3YOtCdZT4+4vywRKDz KlRvnOyOj187aMo7skis3OhspqS9VkEHWldVz6sRHWMt/MY6tKX46zDsrNWd1RYXySg5 XosqGTGct+9f6x+S1dslJFqe0Rqlb3sCo1KesunHoWTBaphJKkfq9ns0K2s1PRLfLg73 10/lS9EIs7wntNN4zpYQT67m45/2MqbBVWYidexBA/TqKcRA4hVjAdPzbEL4btaC2ZEk IUzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=P02rmWol; 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 cb2si2772238plb.298.2019.01.08.01.41.43; Tue, 08 Jan 2019 01:41:58 -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=P02rmWol; 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 S1728392AbfAHJir (ORCPT + 99 others); Tue, 8 Jan 2019 04:38:47 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:8878 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727932AbfAHJiq (ORCPT ); Tue, 8 Jan 2019 04:38:46 -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=1546940326; x=1578476326; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=yvtspfG7CoIHnopRwUo0DnfYLecRH2XoGu3rQKnIYZw=; b=P02rmWolculmF+eIPGLtZQhlEuXq7RuKWhK8bUKt4X3cWaU0VKxuFLR4 Zcrtsjfy7ASKOt2MkfdJbpuwntVASnExzDjTU3TxhY0joKL7OfDy/195/ AQHzBgSiqL9hh25WXz8wztSbDe8yfUSWzAsVR77hQvX32aotwQItBXfVO 9t97aq4lcI1AJdz5VdXxT0x31XM3rqdjJB9Sb6ljXOo+S4JMPoRqLB7NB /lmNg7X8hLqCSAEC7oR/ogknE2STEpBJHEHPj1XwVaZfesZeHklJKu0tR EqeQRj47x6tFt2AN4ouhiirPkhxAYQZFs8LhXfTX4t+7/mg6fjbbRzgLa A==; X-IronPort-AV: E=Sophos;i="5.56,453,1539619200"; d="scan'208";a="99458400" 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; 08 Jan 2019 17:38:45 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 08 Jan 2019 01:18:50 -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; 08 Jan 2019 01:38:45 -0800 From: Atish Patra To: linux-riscv@lists.infradead.org Cc: Atish Patra , Alan Kao , Albert Ou , Andreas Schwab , 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?= , Thomas Gleixner , Zong Li Subject: [PATCH v2 1/8] RISC-V: Do not wait indefinitely in __cpu_up Date: Tue, 8 Jan 2019 01:38:31 -0800 Message-Id: <1546940318-9752-2-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1546940318-9752-1-git-send-email-atish.patra@wdc.com> References: <1546940318-9752-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 Reviewed-by: Anup Patel --- 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 fc185eca..32e14572 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) { @@ -81,6 +82,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; @@ -96,10 +98,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) @@ -125,6 +132,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