From patchwork Mon Nov 25 11:27:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 11260243 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76FD11390 for ; Mon, 25 Nov 2019 11:28:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 21E5D2085B for ; Mon, 25 Nov 2019 11:28:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Gjy4uWZH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21E5D2085B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Oxc+fAP7ugJ1LKBVWKKmIbSZMNnL/523toD2GZ9qVmU=; b=Gjy4uWZHXXz32z8qU/RV8TVbUK +MQfDK2B6UaOLEU7d5VQuuvGMD71fdLFzvH9pHlXm2XbFG6vRBO9t5rlxWFN5jk8Tu0Y8w+bBHTFw 0QGS8WUJhkpiReVzv9OhatjcyWjbMS+bAk3eE53ffTxBi8uT4UOChZGPfVcGOx3qa4m5K3WzwxqQn 9XWvtwwRog8Kl5vGp6Dzajmy3mo0hVUBbFxzNomkCKZhpCabjhJJzynSHds8gRd0Vzc9RRNBaJpRJ eBLXZ9OIqOBtDJpXN4/frmsxgK3IblTM8y7MDkkrlAjyxgDcy/0lTOHezdE1pvjwx9myxKgu++u9B t3NNAGZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iZCXK-0003rh-IA; Mon, 25 Nov 2019 11:28:10 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iZCXH-0003r5-4y for linux-arm-kernel@lists.infradead.org; Mon, 25 Nov 2019 11:28:08 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A28971045; Mon, 25 Nov 2019 03:28:06 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1F7293F52E; Mon, 25 Nov 2019 03:28:04 -0800 (PST) From: Qais Yousef To: Thomas Gleixner , Greg Kroah-Hartman Subject: [PATCH v2 01/14] smp: Create a new function to shutdown nonboot cpus Date: Mon, 25 Nov 2019 11:27:41 +0000 Message-Id: <20191125112754.25223-2-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191125112754.25223-1-qais.yousef@arm.com> References: <20191125112754.25223-1-qais.yousef@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191125_032807_274726_8543739B X-CRM114-Status: GOOD ( 12.12 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fenghua Yu , linux-ia64@vger.kernel.org, "Rafael J. Wysocki" , Catalin Marinas , Tony Luck , "Peter Zijlstra \(Intel\)" , Jiri Kosina , Daniel Lezcano , linux-kernel@vger.kernel.org, Zhenzhong Duan , Nicholas Piggin , Ingo Molnar , Eiichi Tsukata , Nadav Amit , Josh Poimboeuf , Russell King , Will Deacon , Qais Yousef , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This function will be used later in machine_shutdown() for some archs. Signed-off-by: Qais Yousef CC: Thomas Gleixner CC: Josh Poimboeuf CC: "Peter Zijlstra (Intel)" CC: Jiri Kosina CC: Nicholas Piggin CC: Daniel Lezcano CC: Ingo Molnar CC: Eiichi Tsukata CC: Zhenzhong Duan CC: Nadav Amit CC: Greg Kroah-Hartman CC: "Rafael J. Wysocki" CC: Tony Luck CC: Fenghua Yu CC: Russell King CC: Catalin Marinas CC: Will Deacon CC: linux-arm-kernel@lists.infradead.org CC: linux-ia64@vger.kernel.org CC: linux-kernel@vger.kernel.org --- include/linux/cpu.h | 2 ++ kernel/cpu.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index bc6c879bd110..8229932fb053 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -118,6 +118,7 @@ extern void cpu_hotplug_disable(void); extern void cpu_hotplug_enable(void); void clear_tasks_mm_cpumask(int cpu); int cpu_down(unsigned int cpu); +extern void smp_shutdown_nonboot_cpus(unsigned int primary_cpu); #else /* CONFIG_HOTPLUG_CPU */ @@ -129,6 +130,7 @@ static inline int cpus_read_trylock(void) { return true; } static inline void lockdep_assert_cpus_held(void) { } static inline void cpu_hotplug_disable(void) { } static inline void cpu_hotplug_enable(void) { } +static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { } #endif /* !CONFIG_HOTPLUG_CPU */ /* Wrappers which go away once all code is converted */ diff --git a/kernel/cpu.c b/kernel/cpu.c index e2cad3ee2ead..94055a0d989e 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1058,6 +1058,23 @@ int cpu_down(unsigned int cpu) } EXPORT_SYMBOL(cpu_down); +void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) +{ + unsigned int cpu; + + if (!cpu_online(primary_cpu)) { + pr_info("Attempting to shutdodwn nonboot cpus while boot cpu is offline!\n"); + cpu_online(primary_cpu); + } + + for_each_present_cpu(cpu) { + if (cpu == primary_cpu) + continue; + if (cpu_online(cpu)) + cpu_down(cpu); + } +} + #else #define takedown_cpu NULL #endif /*CONFIG_HOTPLUG_CPU*/