diff options
author | Mitchell Horne <mhorne@FreeBSD.org> | 2023-01-07 18:09:28 +0000 |
---|---|---|
committer | Mitchell Horne <mhorne@FreeBSD.org> | 2023-01-23 19:10:24 +0000 |
commit | 5644850620aead7c257a4e3040e20201b510f499 (patch) | |
tree | bae05380fbcfe13cd5db9e9f1eeaa397ef09e2df /sys/ddb/db_command.c | |
parent | 627ca221c311b5d9c4132e03664a96f390ff5c0d (diff) | |
download | src-5644850620aead7c257a4e3040e20201b510f499.tar.gz src-5644850620aead7c257a4e3040e20201b510f499.zip |
ddb: have 'reset' command use normal reboot path
This conditionally gives all registered shutdown handlers a chance to
perform the reboot, with cpu_reset() being the fallback. The '\s'
modifier can be used with the command to get the previous behaviour.
The motivation is that some platforms may not be able do anything
meaningful via cpu_reset(), due to a lack of standardized reset
mechanism and/or firmware shortcomings. However, they may have a
separate device driver attached that normally performs the reboot. Such
is the case for some versions of the Raspberry Pi, where reset via PSCI
fails, but the BCM2835 watchdog driver has a shutdown hook.
Reported by: bz
Reviewed by: markj (slightly earlier version)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D37981
Diffstat (limited to 'sys/ddb/db_command.c')
-rw-r--r-- | sys/ddb/db_command.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 0ddbf5f49629..02f79ca949c2 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -745,7 +745,7 @@ out: static void db_reset(db_expr_t addr, bool have_addr, db_expr_t count __unused, - char *modif __unused) + char *modif) { int delay, loop; @@ -770,6 +770,18 @@ db_reset(db_expr_t addr, bool have_addr, db_expr_t count __unused, } } + /* + * Conditionally try the standard reboot path, so any registered + * shutdown/reset handlers have a chance to run first. Some platforms + * may not support the machine-dependent mechanism used by cpu_reset() + * and rely on some other non-standard mechanism to perform the reset. + * For example, the BCM2835 watchdog driver or gpio-poweroff driver. + */ + if (modif[0] != 's') { + kern_reboot(RB_NOSYNC); + /* NOTREACHED */ + } + cpu_reset(); } |