Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Feb 2024 15:28:01 GMT
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b46dedfa48ef - stable/14 - run acpi_shutdown_final later to give other handlers a chance
Message-ID:  <202402171528.41HFS1rx098041@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by avg:

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

commit b46dedfa48efd5b448c33b5ea920df05241c04aa
Author:     Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2021-12-20 11:01:56 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2024-02-17 15:14:17 +0000

    run acpi_shutdown_final later to give other handlers a chance
    
    For example, shutdown_panic wants to produce some output and maybe take
    some input before a system is actually reset.
    
    The change should only make difference for the case of system reset
    (reboot), poweroff and halt should not be affected.
    
    The change makes difference only if hw.acpi.handle_reboot is set.  It
    used to default to zero until r213755 / ac731af5670c7.
    
    Also, run shutdown_halt even later, after acpi_shutdown_final.  The
    reason for that is that poweroff is requested by RB_POWEROFF | RB_HALT
    combination of flags.  In my opinion, that command is a bit bipolar, but
    since we've been doing that forever, then so be it.  Because of that
    flag combination, the order of shutdown_final handlers that check for
    either flag does matter.
    
    Some additional complexity comes from platform-specific shutdown_final
    handlers that aim to handle multiple reboot options at once.  E.g.,
    acpi_shutdown_final handles both poweroff and reboot / reset.  As
    explained in 9cdf326b4f, such a handler must run after shutdown_panic to
    give it a chance.  But as the change revealed, the handler must also run
    before shutdown_halt, so that the system can actually power off before
    entering the halt limbo.
    
    Previously, shutdown_panic and shutdown_halt had the same priority which
    appears to be incompatible with handlers that can do both poweroff and
    reset.
    
    The above also applies to power cycle handlers.
    
    (cherry picked from commit 9cdf326b4faef97f0d3314b5dd693308ac494d48)
    (cherry picked from commit e4ab361e53945a6c3e9d68c5e5ffc11de40a35f2)
---
 sys/dev/acpica/acpi.c    | 2 +-
 sys/kern/kern_shutdown.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 9196c446ae80..7d1fc10afb9e 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -675,7 +675,7 @@ acpi_attach(device_t dev)
 
     /* Register our shutdown handler. */
     EVENTHANDLER_REGISTER(shutdown_final, acpi_shutdown_final, sc,
-	SHUTDOWN_PRI_LAST);
+	SHUTDOWN_PRI_LAST + 150);
 
     /*
      * Register our acpi event handlers.
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index ea86a7e24d06..149a9456173f 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -264,10 +264,10 @@ shutdown_conf(void *unused)
 
 	EVENTHANDLER_REGISTER(shutdown_final, poweroff_wait, NULL,
 	    SHUTDOWN_PRI_FIRST);
-	EVENTHANDLER_REGISTER(shutdown_final, shutdown_halt, NULL,
-	    SHUTDOWN_PRI_LAST + 100);
 	EVENTHANDLER_REGISTER(shutdown_final, shutdown_panic, NULL,
 	    SHUTDOWN_PRI_LAST + 100);
+	EVENTHANDLER_REGISTER(shutdown_final, shutdown_halt, NULL,
+	    SHUTDOWN_PRI_LAST + 200);
 }
 
 SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202402171528.41HFS1rx098041>