Re: [PATCH v3] firmware: stratix10-svc: add PSCI secondary CPU offline on warm reboot for agilex and stratix10

From: NG, ADRIAN HO YIN

Date: Mon Sep 07 2026 - 03:34:30 EST



On 9/5/2026 12:55 AM, Dinh Nguyen wrote:


On 9/4/26 00:52, Adrian Ng Ho Yin wrote:
On Agilex7 and Stratix10 SoCs, secondary CPUs must be offlined before
a warm reboot to ensure a clean PSCI state. Agilex5 warm reset is a
SDM-owned HPS reset that holds secondaries in the new reset-release until
ATF releases them, so the secondary cores dont have to be put offline
first. Register a reboot notifier that calls remove_cpu() on each
secondary CPU when SYS_RESTART is triggered in REBOOT_WARM mode.

A snapshot of cpu_online_mask is taken before the loop since remove_cpu()
modifies the mask as CPUs go down. CPU 0 is excluded as it is typically
not hotpluggable. Failures are logged and the loop continues so the
reboot is not blocked by a single CPU that refuses to offline.
The of_device_id table carries a per-compatible pdata flag to enable the
notifier only on platforms that need it; Agilex5 leaves the flag unset.

The notifier is unregistered at the start of remove(), before async
channel teardown, to prevent a reboot notification from racing with
driver shutdown.

Signed-off-by: Adrian Ng Ho Yin <adrian.ho.yin.ng@xxxxxxxxxx>
---
changelog:
v2 -> v3:
- Use ctrl in psci_offline_secondary_cpus() via dev_err(ctrl->dev, ...)
   instead of pr_err(). The controller pointer was unused; this both
   consumes it and attributes the failure to the svc device.
- Keep of_device_id.data / stratix10_svc_pdata rather than dropping it
   because both intel,stratix10-svc and intel,agilex-svc happen to share
   the same notifier path. A separate patch adds intel,agilex5-svc without
   .data so Agilex5 does not run this sequence. Agilex5 warm reset is an
   SDM-owned HPS reset (REBOOT_HPS) that holds secondaries in the
   reset-release / P-channel block until ATF CPURSTRELEASE; Linux must
   not PSCI-offline them first.

v1 -> v2:
- Drop workqueue fan-out: remove_cpu() serialises on device_hotplug_lock
   internally so concurrent workers provided no parallelism. Replace with
   a single sequential loop over a cpumask snapshot.
- Fix CPU identity bug: get_cpu()/put_cpu() did not prevent task migration
   and the notifier can run on any CPU before migrate_to_reboot_cpu().
   Exclude CPU 0 (typically not hotpluggable) and offline everything else.
- Fix pre-count race: the two-loop atomic pre-count had a window where a
   concurrent hotplug event could cause dec_and_test() to fire prematurely.
   Eliminated entirely along with the completion and timeout.
- Replace of_device_is_compatible() checks with a stratix10_svc_pdata
   struct carried in of_device_id.data, retrieved via of_device_get_match_data().
- Move psci_cpu_off_teardown() to the top of stratix10_svc_drv_remove(),
   before async channel teardown, to close the race where a warm-reboot
   notification could fire while the driver is being dismantled.

---
  drivers/firmware/stratix10-svc.c | 88 ++++++++++++++++++++++++++++++--
  1 file changed, 85 insertions(+), 3 deletions(-)

I had some erros apply this patch, but was able to finally do it. Please double-check the applied patch on my branch: socfpga_firmware_for_v7.4

Hi Dinh,

The patch looks good on socfpga_firmware_for_v7.4.

Thank You
Adrian