Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2750301ybc; Mon, 25 Nov 2019 03:37:11 -0800 (PST) X-Google-Smtp-Source: APXvYqy7JM+h2FVIST/EA2Lc/vN/7Gg45RzZscqOQ6fUEUV9D08jaBFs5fX4NIlBB9OgfaKq5TY5 X-Received: by 2002:a17:906:bc9:: with SMTP id y9mr36321647ejg.64.1574681831209; Mon, 25 Nov 2019 03:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574681831; cv=none; d=google.com; s=arc-20160816; b=mtEJU0KoG3j6C1yPn32qAdMXmvyYsmWqf19s5LRG6kej4CbhRnBprgYw5inVSxceXR PsdAMWfupmprZAxu+YD1bBntpcOAMBSXuKSG1OPJPnRnG5cyVPaEqlbGRVrpr3H+RBBc WyV6wa3e8QANCOu57iCPVysn+pQMjuMATFbt04vxpGsl7Q7/2dn2VOvPw6VXS3oatEJJ pKw1J2SogFZKHy9/RCGEHUDOu/tm4x9BLDjtxy2BYy2zamvrf9lGE9WEnEUaUwnMaipI culuwWb8TjYqmfvArvsXvnsAi3kqdNSMbCGPPU2Xi8GwcgmbKRhY2qm1M7YL1VbjlAer SdDQ== 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; bh=LJYJjWjfBPGP2UzrcZJ3w4bzA7l7RkZPbv6PDGEcsKg=; b=rEApb13DsBi+Vq7kdans5ZRh9n3RKPc1nj3AmUyFTnjZX5T0HFAIgapbGHwLVwcLaU ffU8A/Qa/KG3s/atGiLkEEmVqEFy8hEPkJusFKELuTSlXTvoiNXybkwDQ8KGf0Y6caJW nWHicDHTQNAuoQGc4xXsFMoj71QfkbH1a+O392pErhr3GBI7xYCGS1v5BfWuOMRPvX/3 Pl2jd49d49PGqRx39V1n5rfEw0a2NkwwxC2biNT31YbcvTsr4hVZPgX4lSb6raEVUu0K DISAMn+4VGN2/ljzwwhU3LZQeedFpGtR9ORiiZShT6mjFKn5sorgZbnFCjZolQN1ISeo CSOw== ARC-Authentication-Results: i=1; mx.google.com; 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 t18si4757524eds.247.2019.11.25.03.36.46; Mon, 25 Nov 2019 03:37:11 -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; 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 S1727684AbfKYL2H (ORCPT + 99 others); Mon, 25 Nov 2019 06:28:07 -0500 Received: from foss.arm.com ([217.140.110.172]:48894 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725851AbfKYL2H (ORCPT ); Mon, 25 Nov 2019 06:28:07 -0500 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 Cc: Qais Yousef , Josh Poimboeuf , "Peter Zijlstra (Intel)" , Jiri Kosina , Nicholas Piggin , Daniel Lezcano , Ingo Molnar , Eiichi Tsukata , Zhenzhong Duan , Nadav Amit , "Rafael J. Wysocki" , Tony Luck , Fenghua Yu , Russell King , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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*/ -- 2.17.1