The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] kernel/cpu: Disallow offlining boot CPU based on config
@ 2026-06-05 10:30 Sneh Mankad
  2026-06-05 10:43 ` Peter Zijlstra
  2026-06-05 13:07 ` Pankaj Patil
  0 siblings, 2 replies; 4+ messages in thread
From: Sneh Mankad @ 2026-06-05 10:30 UTC (permalink / raw)
  To: Thomas Gleixner, Daniel Lezcano, Peter Zijlstra,
	Rafael J. Wysocki, Pavel Machek, Len Brown
  Cc: linux-arm-msm, linux-kernel, linux-pm, Sneh Mankad

The Qualcomm SoCs like LeMans, Monaco support suspend to ram which leads
the SoC to ACPI S3 similar state where SoC is turned off and DDR is
retained.
The hardware design on these SoCs forces a constraint to suspend and
resume the system on boot CPU / CPU0.

If CPU0 is already offline before starting suspend to ram the
freeze_secondary_cpus() picks alternate CPU as primary / last CPU and
proceed further to invoke PSCI SYSTEM_SUSPEND.
This leads to a system crash.

In order to prevent such an issue introduce PM_SLEEP_SMP_CPU_ZERO_STRICT
config and when enabled prohibit the CPU0 to be offline.

Signed-off-by: Sneh Mankad <sneh.mankad@oss.qualcomm.com>
---
 kernel/cpu.c         | 4 ++++
 kernel/power/Kconfig | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index bc4f7a9ba64e62d76fbb2b362f243c918defe5bc..1c878db1d9cb6df0e31cb55343851aab4e38a3a0 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1478,6 +1478,10 @@ static int cpu_down_maps_locked(unsigned int cpu, enum cpuhp_state target)
 	 */
 	if (cpu_hotplug_offline_disabled)
 		return -EOPNOTSUPP;
+#ifdef CONFIG_PM_SLEEP_SMP_CPU_ZERO_STRICT
+	if (cpu == get_boot_cpu_id())
+		return -EPERM;
+#endif
 	if (cpu_hotplug_disabled)
 		return -EBUSY;
 	return _cpu_down(cpu, 0, target);
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 05337f437cca29da57864583166d7f9abd526507..0b342b3a4a5650a1927dc4805d1515e1d9e067c6 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -401,3 +401,11 @@ config ENERGY_MODEL
 	  The exact usage of the energy model is subsystem-dependent.
 
 	  If in doubt, say N.
+
+config PM_SLEEP_SMP_CPU_ZERO_STRICT
+	bool "Disallow boot CPU (CPU0) offline"
+	depends on HOTPLUG_CPU
+	depends on SUSPEND
+	help
+	  Disallow boot CPU (CPU0) offline when the suspend_ops->enter()
+	  has to be executed by boot CPU.

---
base-commit: ba3e43a9e601636f5edb54e259a74f96ca3b8fd8
change-id: 20260603-disable_boot_cpu_offline-eb4f55ac96f2

Best regards,
-- 
Sneh Mankad <sneh.mankad@oss.qualcomm.com>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-05 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-05 10:30 [PATCH] kernel/cpu: Disallow offlining boot CPU based on config Sneh Mankad
2026-06-05 10:43 ` Peter Zijlstra
2026-06-05 12:20   ` Thomas Gleixner
2026-06-05 13:07 ` Pankaj Patil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox