Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6953770imu; Thu, 27 Dec 2018 09:25:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN6T04Q8A6NP6+ehhfwXAfDtUHhYQDzBOEQoSdnQIwNFrBAOBtnZ/VbLvjRglYB7VJdertdm X-Received: by 2002:a17:902:2aaa:: with SMTP id j39mr24961527plb.335.1545931518372; Thu, 27 Dec 2018 09:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545931518; cv=none; d=google.com; s=arc-20160816; b=U63HtY+K2jwc43T3rgoRuwB8rsNNEW+pEI7UEOgijYPKWccozgK3ETRG24hLhJ2YLL ekpeTR4E1QtEpdlfdUM0BEDv+agocK/DJyJ8eSLp9LatliCsbaWjmRNWuAk97dDsqFu9 mSRxFE26jtAy5i5vkik91GKhWVVQ7MdoXWP5fKpZJLuFXCuhhCJW+vuj8djWZ+cXZ6dn eEjJF/ZLp6qejjoJOZ/wVD/KyyfeIn63kzVaOC9Srxoeyb+rJFlsCI5hDSbJ+hacTk+Y T62W1arAZiM6ua6mn5616qZPk7oa8l73iiKoTYbNxtO7CeqLXmJBhtBPqTK7Sc/XYdcU EajA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=AUBNZAgxqZfBaytyfOb+0LphpB3Zk2eeZxHObCF+N0Y=; b=buuVvw4ghmQBUSccXHMR0Q9/sZKhVJnk69Do5GWrcOULFcBr/UOVkG9WxfO5t1N52L LLWawZqvBFwZZnJWKV+9cIDkwhCK3V8A4kLOJc7YU5QfrPCu5c0ZnmtMGcsayRHF96eH spAvflKeil/NiOQvjBAyTniIV8xbwkCK4HUq6tpymZmHWURjQZMB7P1HyrcDxMDciWya 6XsqzLVwrH8/KG8Dkur/zj0jcQwRUWLb3Q5W2ZpCQ02HJP/rs/OmiC5EldNmU6w/pO5k ZI9oD8HikwotWw5WO970RQNQdrdNoVH/K4l/oSBF3g/xfCfcBLcyvkPLEOaeUIRhHNgh a4vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=sKfZTrqR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t184si25065327pfb.22.2018.12.27.09.25.02; Thu, 27 Dec 2018 09:25:18 -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=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=sKfZTrqR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728642AbeL0Dgh (ORCPT + 99 others); Wed, 26 Dec 2018 22:36:37 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38594 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbeL0Dgh (ORCPT ); Wed, 26 Dec 2018 22:36:37 -0500 Received: by mail-wr1-f66.google.com with SMTP id v13so17098903wrw.5 for ; Wed, 26 Dec 2018 19:36:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AUBNZAgxqZfBaytyfOb+0LphpB3Zk2eeZxHObCF+N0Y=; b=sKfZTrqRJx4amkkQ2XUfGpJbQS++7AiWyXIt+nTg7Bn/F9FTMw3REp7NV5xiYdkSiC RFjn3+QU70CVjLLudpvNDHg4arNBH5kaaiRoQfmnQqXOkMtGxkp/z/fJMt4tk+KxcJXy phrLosh/NL8JT7yH4AgERpy4dqY9W2lMcZSZr6DIUmR+uXMYUPWnxSN1+70LA8Omg/UP 1k/OxSpHOgn5qrZVBDKIF7KRteVoLj5vHsYpXhHktCql3SIZMpp2DPtvTaPsYM/KaFCP Cs2/mlBnKXQ3ApNf0gUJPeQ68KbmNZm3g9oIVUznBM8Uo5q3ejAAkQqTyydVU+DHSq7Q vUsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AUBNZAgxqZfBaytyfOb+0LphpB3Zk2eeZxHObCF+N0Y=; b=bwATHJm4frAITUu8G9XYXi3EF5MBwEDUv2ADFr+S/M+oC4XVS7cVB3t/6OV1r1GLCh b5aHFeNRmHUiG4U52q/KRcxZwuHWu+ss84h42iMSgt0X8SzyAhEuJFwi28V0v8Nwg8Jh YvVwmSn8vdF+qAhwOWltX4yXYSqnAs9jPSr9ENX7ZdO3d7xmu90E3bn0flsJ47GDMQkQ 5RQXtLBqGnFiJKd6nVsFbKe3vNIV9C1N2pw/Ycv2McpaiOwCi0sFTsDEpMpT31Yb38mM QJBK6XCT7DfmnkIN4d9oXwcMGTHC9N9sWkr9RIGbbqRtUPQ/O4FDNw4acXrLAEXdyr78 Cppg== X-Gm-Message-State: AJcUukc8Hp3DgJabg5QvtyubwtX/07jbh5M7ZjQeLOS6qcFLVu2BJM72 nbHqimFd7PZEn6PFK63ZtdKEfsCVR1REHBvxeqNMEg== X-Received: by 2002:adf:f5d1:: with SMTP id k17mr21949955wrp.59.1545881795255; Wed, 26 Dec 2018 19:36:35 -0800 (PST) MIME-Version: 1.0 References: <1545865741-22795-1-git-send-email-atish.patra@wdc.com> <1545865741-22795-2-git-send-email-atish.patra@wdc.com> In-Reply-To: <1545865741-22795-2-git-send-email-atish.patra@wdc.com> From: Anup Patel Date: Thu, 27 Dec 2018 09:06:24 +0530 Message-ID: Subject: Re: [PATCH 1/3] RISC-V: Do not wait indefinitely in __cpu_up To: Atish Patra Cc: linux-riscv@lists.infradead.org, Albert Ou , Daniel Lezcano , Dmitriy Cherkasov , Jason Cooper , "linux-kernel@vger.kernel.org List" , Marc Zyngier , Michael Clark , Palmer Dabbelt , =?UTF-8?Q?Patrick_St=C3=A4hlin?= , Rob Herring , Thomas Gleixner , Damien Le Moal Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 27, 2018 at 4:39 AM Atish Patra wrote: > > 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 > Looks good to me. Reviewed-by: Anup Patel