Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Feb 2024 09:41:51 GMT
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e4ab361e5394 - main - fix poweroff regression from 9cdf326b4f by delaying shutdown_halt
Message-ID:  <202402060941.4169fpXE092972@gitrepo.freebsd.org>

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

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

commit e4ab361e53945a6c3e9d68c5e5ffc11de40a35f2
Author:     Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2024-02-06 08:55:13 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2024-02-06 08:55:13 +0000

    fix poweroff regression from 9cdf326b4f by delaying shutdown_halt
    
    The regression affected ACPI-based systems without EFI poweroff support
    (including VMs).
    
    The key reason for the regression is that I overlooked 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.
    
    PR:             276784
    Reported by:    many
    Tested by:      Katsuyuki Miyoshi <katsubsd@gmail.com>,
                    Masachika ISHIZUKA <ish@amail.plala.or.jp>
    Fixes:          9cdf326b4fae run acpi_shutdown_final later to give other handlers a chance
    MFC after:      1 week
---
 sys/kern/kern_shutdown.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index ee666281418f..f49e315a503d 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -262,10 +262,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?202402060941.4169fpXE092972>