[PATCH v3 1/3] firmware: arm_scmi: Avoid deadlocks between reboot notifier and forceful work

From: Cristian Marussi

Date: Mon Nov 30 2026 - 09:49:59 EST


When an ongoing reboot is detected scmi_reboot_notifier() cancels the
scheduled pending delayed work by calling cancel_delayed_work_sync():
this is done while holding sc->state_mtx which is also taken by the
worker is trying to synchronously cancel.

Such locking, though, guarantees mutual exclusion between the conflicting
activities carried on by the two threads, but it is in turn leading to an
ABBA deadlock with the internal reboot notifier locking.

Stop synchronously waiting for the cancellation so as to avoid deadlock
and temporarily drop state_mtx while unregistering the reboot notfier.

Fixes: 2c4b97fee94a ("firmware: arm_scmi: Add SCMI System Power Control driver")
Reported-by: Chengyu Liu <lui2012qwq@xxxxxxxxx>
Signed-off-by: Cristian Marussi <cristian.marussi@xxxxxxx>
---
v2 --> v3
- drop mutex before unregistering reboot notifier
- use dev_warn() to log forceful transititon
---
.../firmware/arm/scmi/scmi_power_control.c | 22 ++++++++++++++-----
1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/arm/scmi/scmi_power_control.c b/drivers/firmware/arm/scmi/scmi_power_control.c
index e791a206768c..0be9ca01e3fe 100644
--- a/drivers/firmware/arm/scmi/scmi_power_control.c
+++ b/drivers/firmware/arm/scmi/scmi_power_control.c
@@ -140,7 +140,7 @@ static int scmi_reboot_notifier(struct notifier_block *nb,

if (sc->state == SCMI_SYSPOWER_REBOOTING) {
dev_dbg(sc->dev, "Reboot in progress...cancel delayed work.\n");
- cancel_delayed_work_sync(&sc->forceful_work);
+ cancel_delayed_work(&sc->forceful_work);
}
mutex_unlock(&sc->state_mtx);

@@ -188,12 +188,22 @@ static void scmi_forceful_work_func(struct work_struct *work)
dwork = to_delayed_work(work);
sc = dwork_to_sconf(dwork);

- dev_dbg(sc->dev, "Graceful request timed out...forcing !\n");
mutex_lock(&sc->state_mtx);
- /* avoid deadlock by unregistering reboot notifier first */
- unregister_reboot_notifier(&sc->reboot_nb);
- if (sc->state == SCMI_SYSPOWER_IN_PROGRESS)
- scmi_request_forceful_transition(sc);
+ if (sc->state == SCMI_SYSPOWER_IN_PROGRESS) {
+ mutex_unlock(&sc->state_mtx);
+ /*
+ * Avoid deadlock by unregistering reboot notifier first
+ * while NOT holding state_mtx.
+ */
+ unregister_reboot_notifier(&sc->reboot_nb);
+ mutex_lock(&sc->state_mtx);
+ /* Re-evaluate current state after mutex re-acquired */
+ if (sc->state == SCMI_SYSPOWER_IN_PROGRESS) {
+ dev_warn(sc->dev,
+ "Graceful request timed out...forcing !\n");
+ scmi_request_forceful_transition(sc);
+ }
+ }
mutex_unlock(&sc->state_mtx);
}

--
2.54.0