diff mbox series

[v4.4,V2,15/43] arm64: Move cpu_die_early to smp.c

Message ID dd031e0851c01a0cfe275c05dc24935580d2fd78.1562908075.git.viresh.kumar@linaro.org (mailing list archive)
State New, archived
Headers show
Series V4.4 backport of arm64 Spectre patches | expand

Commit Message

Viresh Kumar July 12, 2019, 5:28 a.m. UTC
From: Suzuki K Poulose <suzuki.poulose@arm.com>

commit fce6361fe9b0caeba0c05b7d72ceda406f8780df upstream.

This patch moves cpu_die_early to smp.c, where it fits better.
No functional changes, except for adding the necessary checks
for CONFIG_HOTPLUG_CPU.

Cc: Mark Rutland <mark.rutland@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
[ Viresh: Resolved rebase conflict ]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/arm64/include/asm/smp.h   |  1 +
 arch/arm64/kernel/cpufeature.c | 22 ----------------------
 arch/arm64/kernel/smp.c        | 25 +++++++++++++++++++++++++
 3 files changed, 26 insertions(+), 22 deletions(-)

Comments

Mark Rutland July 31, 2019, 12:35 p.m. UTC | #1
On Fri, Jul 12, 2019 at 10:58:03AM +0530, Viresh Kumar wrote:
> From: Suzuki K Poulose <suzuki.poulose@arm.com>
> 
> commit fce6361fe9b0caeba0c05b7d72ceda406f8780df upstream.
> 
> This patch moves cpu_die_early to smp.c, where it fits better.
> No functional changes, except for adding the necessary checks
> for CONFIG_HOTPLUG_CPU.
> 
> Cc: Mark Rutland <mark.rutland@arm.com>
> Acked-by: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> [ Viresh: Resolved rebase conflict ]
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

> +void cpu_die_early(void)

> +	asm(
> +	"1:	wfe\n"
> +	"	wfi\n"
> +	"	b	1b");
> +}

Rather than open-coding this loop differently from upstream and the
v4.9.y backport, please backport commit:

  c4bc34d20273db69 ("arm64: Add a helper for parking CPUs in a loop")

... as a prerequisite of this patch.

Otherwise, this looks fine to me.

Thanks,
Mark.
Viresh Kumar Aug. 1, 2019, 3:35 a.m. UTC | #2
On 31-07-19, 13:35, Mark Rutland wrote:
> On Fri, Jul 12, 2019 at 10:58:03AM +0530, Viresh Kumar wrote:
> > From: Suzuki K Poulose <suzuki.poulose@arm.com>
> > 
> > commit fce6361fe9b0caeba0c05b7d72ceda406f8780df upstream.
> > 
> > This patch moves cpu_die_early to smp.c, where it fits better.
> > No functional changes, except for adding the necessary checks
> > for CONFIG_HOTPLUG_CPU.
> > 
> > Cc: Mark Rutland <mark.rutland@arm.com>
> > Acked-by: Will Deacon <will.deacon@arm.com>
> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> > Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> > [ Viresh: Resolved rebase conflict ]
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> 
> > +void cpu_die_early(void)
> 
> > +	asm(
> > +	"1:	wfe\n"
> > +	"	wfi\n"
> > +	"	b	1b");
> > +}
> 
> Rather than open-coding this loop differently from upstream and the
> v4.9.y backport, please backport commit:
> 
>   c4bc34d20273db69 ("arm64: Add a helper for parking CPUs in a loop")
> 
> ... as a prerequisite of this patch.

Done, thanks.
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
index d9c3d6a6100a..13ce01fe6237 100644
--- a/arch/arm64/include/asm/smp.h
+++ b/arch/arm64/include/asm/smp.h
@@ -68,5 +68,6 @@  extern int __cpu_disable(void);
 
 extern void __cpu_die(unsigned int cpu);
 extern void cpu_die(void);
+extern void cpu_die_early(void);
 
 #endif /* ifndef __ASM_SMP_H */
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index b7f01bf47988..a0273cd8be51 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -852,28 +852,6 @@  static inline void set_sys_caps_initialised(void)
 	sys_caps_initialised = true;
 }
 
-/*
- * Kill the calling secondary CPU, early in bringup before it is turned
- * online.
- */
-void cpu_die_early(void)
-{
-	int cpu = smp_processor_id();
-
-	pr_crit("CPU%d: will not boot\n", cpu);
-
-	/* Mark this CPU absent */
-	set_cpu_present(cpu, 0);
-
-	/* Check if we can park ourselves */
-	if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_die)
-		cpu_ops[cpu]->cpu_die(cpu);
-	asm(
-	"1:	wfe\n"
-	"	wfi\n"
-	"	b	1b");
-}
-
 /*
  * Run through the enabled system capabilities and enable() it on this CPU.
  * The capabilities were decided based on the available CPUs at the boot time.
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 03c0946b79d2..752b53daac23 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -312,6 +312,31 @@  void cpu_die(void)
 }
 #endif
 
+/*
+ * Kill the calling secondary CPU, early in bringup before it is turned
+ * online.
+ */
+void cpu_die_early(void)
+{
+	int cpu = smp_processor_id();
+
+	pr_crit("CPU%d: will not boot\n", cpu);
+
+	/* Mark this CPU absent */
+	set_cpu_present(cpu, 0);
+
+#ifdef CONFIG_HOTPLUG_CPU
+	/* Check if we can park ourselves */
+	if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_die)
+		cpu_ops[cpu]->cpu_die(cpu);
+#endif
+
+	asm(
+	"1:	wfe\n"
+	"	wfi\n"
+	"	b	1b");
+}
+
 static void __init hyp_mode_check(void)
 {
 	if (is_hyp_mode_available())