git: 9ca7451d86dc - stable/13 - change ipmi watchdog to awlays stop when system is halted

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Sat, 17 Feb 2024 19:22:37 UTC
The branch stable/13 has been updated by avg:

URL: https://cgit.FreeBSD.org/src/commit/?id=9ca7451d86dcf8fb072491028e3b0fb50b2299c5

commit 9ca7451d86dcf8fb072491028e3b0fb50b2299c5
Author:     Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2023-01-03 17:26:45 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2024-02-17 19:22:08 +0000

    change ipmi watchdog to awlays stop when system is halted
    
    That is, wd_shutdown_countdown value is ignored when halting.
    
    A halted system should remain halted for as long as needed until
    a power cycle, so the watchdog should not reset the system.
    
    (cherry picked from commit 8fdb26160160c4507eb2f644a982a3e05984cdf6)
---
 sys/dev/ipmi/ipmi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/dev/ipmi/ipmi.c b/sys/dev/ipmi/ipmi.c
index 7fef4d5ad103..ff2a31859485 100644
--- a/sys/dev/ipmi/ipmi.c
+++ b/sys/dev/ipmi/ipmi.c
@@ -741,6 +741,10 @@ ipmi_shutdown_event(void *arg, int howto)
 	 * Zero value in wd_shutdown_countdown will disable watchdog;
 	 * Negative value in wd_shutdown_countdown will keep existing state;
 	 *
+	 * System halt is a special case of shutdown where wd_shutdown_countdown
+	 * is ignored and watchdog is disabled to ensure that the system remains
+	 * halted as requested.
+	 *
 	 * Revert to using a power cycle to ensure that the watchdog will
 	 * do something useful here.  Having the watchdog send an NMI
 	 * instead is useless during shutdown, and might be ignored if an
@@ -748,7 +752,7 @@ ipmi_shutdown_event(void *arg, int howto)
 	 */
 
 	wd_in_shutdown = true;
-	if (wd_shutdown_countdown == 0) {
+	if (wd_shutdown_countdown == 0 || (howto & RB_HALT) != 0) {
 		/* disable watchdog */
 		ipmi_set_watchdog(sc, 0);
 		sc->ipmi_watchdog_active = 0;