From nobody Sat Nov 07 09:14:39 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jM9Nj2phTz6yglF for ; Sat, 07 Nov 2026 09:14:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jM9Nj0Tpfz4Y8s for ; Sat, 07 Nov 2026 09:14:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794042885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M2IIBQEXhEjV5NyhO8J/m0QV3dymxhYTwSrafyRP0zU=; b=nVqm8RdGeWWbfT/Oe7e1K0goe79/ZzxgXSpU+MymKVgeUAF65s5g6QvrEt2mZN6L3nEFln vVw08ek8ag4HAXZ+PvL/51JAneViTtrNVSJzKcGwAN1BcNMpvuGYVfhIA33uDO9K3hkhsq bDk0bSvFXhAU6QapkkyXh6jrOWoGt2369mU7LjGNQUsGoYITLLjsC/3laEgHOXO8gWETvP lSf5FwHbwFuc3LyTE+ceYOAvQlnRe6N4qv0wdTSqZgZORh/dRHOUXj2dqcTljAKY4B7xPq Bs+wmR0ep8812hREhDbcY5r66O7nDeZNbhdTveAMhZ02yQztcGCtx1TI1YAyzA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794042885; b=VbhLp4LaRtI0ITcIR3IV+qAxAohybKq81xrROd2ZMOpbAGAPcVZOXIldnmSI8wjux+uL71 cqD9X1VmW1/5/zwabjr9OQInpeSikoh8xWuo3Lm08BTD095lp1vJwyA373t35MHtgHzJK8 Yro2XAdYpZ+9c4XeDE6IIdgapsrwDeme3m7zSNLx5LID1MVWXvUU87aehTqIjGiE74v0Va UnT6z7pdRdiaUbxZcD4s4yHp4BnHIE+de6jmaHbSxz+zGC49NZpGyQPPPBdWFB2yAvg6ER N4m7O4vf/XaCKhUygl+yolQgb+KAog3yE+f1Pvqi7nwKLI4KJCMMIVjd6EPJfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794042885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M2IIBQEXhEjV5NyhO8J/m0QV3dymxhYTwSrafyRP0zU=; b=Ctk4UvBTMv/UOTc+0uiw6Z8D2Pvw2xHf2VLrGqKPDiHtu7oVfMMo6jobh4LyLK4HgLKOG/ 2we9JTO0cLz52wCXsG9Y1pfsoqO11z3dmrl+kUgQ7/SMQ1+PsKji521w8Rlb5jisGQ7xJA HXEFVEQlaSlZ3hif0dy3+xZ3tosVT/IdXv10ZG5fJFRaRF5ix2CFYKmmR095bTWov/7haY K5qjQi4M0Kk1688WWIok3dtJPEmDK/NPA/wN8tclMn+Gt2gdN3vWE9bKXlHZAs+ilrdXJ5 fxPvAQV4EyeUo3jhLFF43NSPT+rlgBtmDETnok3B0Tg8+T6i5bP2NWPOGZ7/dA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jM9Nj07w8zGlD for ; Sat, 07 Nov 2026 09:14:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 33e1a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 07 Nov 2026 09:14:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Abdelkader Boudih Subject: git: 4ce90d56a853 - main - asmc: notify the SMC of shutdown and restart List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: seuros X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4ce90d56a853431668aac4493eac9cc13ab79f26 Auto-Submitted: auto-generated Date: Sat, 07 Nov 2026 09:14:39 +0000 Message-Id: <6aeeebff.33e1a.51c1cedc@gitrepo.freebsd.org> The branch main has been updated by seuros: URL: https://cgit.FreeBSD.org/src/commit/?id=4ce90d56a853431668aac4493eac9cc13ab79f26 commit 4ce90d56a853431668aac4493eac9cc13ab79f26 Author: Abdelkader Boudih AuthorDate: 2026-11-07 09:14:28 +0000 Commit: Abdelkader Boudih CommitDate: 2026-11-07 09:14:28 +0000 asmc: notify the SMC of shutdown and restart Nothing tells the SMC that a power off or restart was user requested, so the T2 keeps rebooting the machine thinking the system is wedged. Approved-by: ngie (co-mentor) Reviewed by: ngie, adrian Differential Revision: https://reviews.freebsd.org/D61260 --- sys/dev/asmc/asmc.c | 23 +++++++++++++++++++++++ sys/dev/asmc/asmcvar.h | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c index 4eaa3bf06252..182f6d585080 100644 --- a/sys/dev/asmc/asmc.c +++ b/sys/dev/asmc/asmc.c @@ -40,11 +40,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -70,6 +72,7 @@ static int asmc_probe(device_t dev); static int asmc_attach(device_t dev); static int asmc_detach(device_t dev); static int asmc_resume(device_t dev); +static void asmc_shutdown(void *arg, int howto); /* * Backlight interface. @@ -736,6 +739,10 @@ asmc_attach(device_t dev) "Apple security chip generation (RGEN; 3=T2)"); } + if (asmc_key_getinfo(dev, ASMC_KEY_MBSS, NULL, NULL) == 0) + sc->sc_shutdown_tag = EVENTHANDLER_REGISTER(shutdown_pre_sync, + asmc_shutdown, dev, SHUTDOWN_PRI_FIRST); + if (!sc->sc_has_sms) goto nosms; @@ -821,6 +828,11 @@ asmc_detach(device_t dev) { struct asmc_softc *sc = device_get_softc(dev); + if (sc->sc_shutdown_tag != NULL) { + EVENTHANDLER_DEREGISTER(shutdown_pre_sync, sc->sc_shutdown_tag); + sc->sc_shutdown_tag = NULL; + } + if (sc->sc_kbd_bkl != NULL) backlight_destroy(sc->sc_kbd_bkl); @@ -877,6 +889,17 @@ asmc_resume(device_t dev) return (0); } +static void +asmc_shutdown(void *arg, int howto) +{ + device_t dev = (device_t)arg; + uint8_t buf[2]; + + be16enc(buf, (howto & (RB_POWEROFF | RB_HALT)) != 0 ? + ASMC_MBSS_POWEROFF : ASMC_MBSS_RESTART); + asmc_key_write(dev, ASMC_KEY_MBSS, buf, sizeof(buf)); +} + #ifdef ASMC_DEBUG void asmc_dumpall(device_t dev) diff --git a/sys/dev/asmc/asmcvar.h b/sys/dev/asmc/asmcvar.h index 76c17f4ba2dd..32449a72cc48 100644 --- a/sys/dev/asmc/asmcvar.h +++ b/sys/dev/asmc/asmcvar.h @@ -90,6 +90,7 @@ struct asmc_softc { int sc_light_len; /* ASMC_LIGHT_{SHORT,LONG}LEN */ int sc_has_safespeed; int sc_has_alsl; /* ALSL interrupt source */ + eventhandler_tag sc_shutdown_tag; }; /* @@ -197,6 +198,12 @@ struct asmc_softc { */ #define ASMC_KEY_AUPO "AUPO" /* RW; 1 byte */ +/* Mac Boot State Status. */ +#define ASMC_KEY_MBSS "MBSS" /* RW; 2 bytes */ + +#define ASMC_MBSS_POWEROFF 0x0001 +#define ASMC_MBSS_RESTART 0x0003 + /* * Interrupt keys. */