power: reset: syscon-reboot: Use devm_register_sys_off_handler(RESTART)
PATCH 1/1 power: reset: syscon-reboot: Use devm_register_sys_off_handler(RESTART)
The driver registers its restart handler but never unregisters it:
there is no remove callback and the notifier block lives in the devm-allocated context. After unbind the freed notifier stays on the handler list and the next reboot oopses on it, observed on a Hi3798MV100 board (PC is at 0x0, LR is at notifier_call_chain).
Use the device-managed registration, which unregisters the handler on driver unbind; the DT-configured priority is passed through. This mirrors the conversion of the syscon-poweroff sibling.
--- drivers/power/reset/syscon-reboot.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/power/reset/syscon-reboot.c +7 -11
@@ -31,16 +31,12 @@ struct syscon_reboot_context {const struct reboot_data *rd;/* from of match data, if any */ struct reboot_mode_bits catchall;/* from DT */ - -struct notifier_block restart_handler; }; -static int syscon_restart_handle (struct notifier_block *this, -unsigned long mode,void *cmd) +static int syscon_restart_handle (struct sys_off_data *data) { -struct syscon_reboot_context *ctx = - container_of(this, struct syscon_reboot_context, - restart_handler); +struct syscon_reboot_context *ctx = data->cb_data; +unsigned int mode = data->mode;const struct reboot_mode_bits *mode_bits;if (ctx->rd) {
@@ -113,11 +109,11 @@ static int syscon_reboot_probe(struct platform_device *pdev) } } - ctx->restart_handler.notifier_call = syscon_restart_handle; - ctx->restart_handler.priority = priority; - err =register_restart_handler (&ctx->restart_handler); + err =devm_register_sys_off_handler (dev,SYS_OFF_MODE_RESTART , + priority, syscon_restart_handle, + ctx);if (err) -dev_err (dev,"can't register restart notifier (err=%d)\n" , err); +dev_err (dev,"can't register restart handler (err=%d)\n" , err);return err; }
Signature · 1 line
2.53.0
Sebastian Reichel
AppliedQuoted 11 lines · David Yang
The driver registers its restart handler but never unregisters it:
there is no remove callback and the notifier block lives in the devm-allocated context. After unbind the freed notifier stays on the handler list and the next reboot oopses on it, observed on a Hi3798MV100 board (PC is at0x0, LR is atnotifier_call_chain).Use the device-managed registration, which unregisters the handler on driver unbind; the DT-configured priority is passed through. This mirrors the conversion of the syscon-poweroff sibling.
[...]
Applied, thanks!
[1/1] power: reset: syscon-reboot: Use devm_register_sys_off_handler(RESTART)
commit: 808914f0c0141a5e0bd66e13daff7f9d2aa12155
Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>
drivers/power/reset/syscon-reboot.c static int syscon_reboot_probe(struct platform_device *pdev) · line 114
Quoted 4 lines · On Mon, 26 Oct 2026 17:20:47 +0800 David Yang <[email protected]> wrote:
drivers/power/reset/syscon-reboot.c +3
-0+ err =devm_register_sys_off_handler (dev,SYS_OFF_MODE_RESTART , + priority, syscon_restart_handle, + ctx);
In linux-next (next-20261123), booting riscv64 under QEMU, I am seeing:
syscon-reboot reboot: can't register restart handler (err=-16) syscon-reboot reboot: probe with driver syscon-reboot failed with error -16
My LLM says:
The SBI SRST restart handler (sbi_srst_reboot_nb) is already registered at priority 192, which is also the default one for this driver, and register_sys_off_handler() only allows one handler per non-default priority, unlike register_restart_handler().
The following patch moves the SBI one to SYS_OFF_PRIO_FIRMWARE, and with both patches on top of v7.4-rc4 the driver probes again:
https://lore.kernel.org/all/[email protected]/
Cc'ing Anand and Aurelien.
I hope that helps!
Cheers,
Miguel