From nobody Fri Sep 26 16:03:50 2025 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 4cYFkZ65wWz68Vvy; Fri, 26 Sep 2025 16:03:50 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cYFkZ3bvCz3q4d; Fri, 26 Sep 2025 16:03:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758902630; 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=us434JS9qq/siD9BAYHmmpF0N8x6+dx+mxyQdhtoMzg=; b=qwmwe92Ur0BOivpC+jyvAUDPD6Pij3WbKDpkxER/8jeN5/2B+Ie1M4eV6uSGWe9HSYWq+0 alOkMuscr7HHp8zKevSrmby/ZBWOATJcFwedX+6e+AmIIzm7QSIlzvaZvduAAqR0mT3xYf kRmlUt7zXG0dJwXnp4wCzA0PGUjmiVMXREFALhYMRhhIMyg6MXZkCW7cKcNr+sItK6cHN2 dvSv5wEU4mtJsudYp/A0X82fojJ/gxhFtnohT8yJ9f1gtQ7+dORN5guoOmYkB9nbWxgFW4 knENejpKi5Mee7K1HZLwnIrICddqBbo7U6na1MD0zSNz2jxCOrovQuHpUnWcEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758902630; 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=us434JS9qq/siD9BAYHmmpF0N8x6+dx+mxyQdhtoMzg=; b=Dz+l0co68nAWrPyxf0fnDbYemL/gJ1pZzsyL9DJlAYSoQ0QSHFsx1olxhtuUU7+/rFOu0T slpS8RToXFW8v8QmcbBHoZSPPHx2sGu3imiQpnLeBp5e8yBRs7ygwraOx5h8UGh5/M5S46 JY3FMSWVbDIdEFMQHwAHtDAJiYNLw5W/6shNx2tHrZq/KfsbX2OWNY+o5JL5tbkr4vtp9i I3lh+49YHdA3nVjyNWsgGJNGSXbfKqHWWhBOE8TKsc1yNJdKmx0p+k7X+kcfh4d8Ew0Ipu oltW5W7tGFwjzvfEdcVsqhxt49ZKUAXOFCFNwD229gSKFdqCNCI2bIIuxzgFQw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758902630; a=rsa-sha256; cv=none; b=vKUsdiiXysENrliozQRWfaRXZLD3HrkCUfa//ZB8Xjn5ELsUYmkumA/MWPeLNh/TBq3fxM G+2OQodgmDdMbbta3+d0gdnKLIoPRbWvzkBnIYC/3rWQ/VlR1wMaIHPkn2G6GomQySdFa4 vSaHFh8kvSs00XroAEP0IqbLGkmN1srgNGSrL5Qv6LPhfAKUZcX1ICQgcQKxH896XqT6cH CsMaHZYGQ6Sa0Pg4zw9HnwoaPfiNEF3/wNl36RrBpPWyyxW+kUos+1npiGZqqSjgbqtdCT 4vE0IKPLnznN4wDTZ7Ruo4FnUaY8iDBzhCaEe6NxHW25yeGUuWu7ga+/s0103Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cYFkZ378mztrc; Fri, 26 Sep 2025 16:03:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58QG3ogw069255; Fri, 26 Sep 2025 16:03:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58QG3oPf069252; Fri, 26 Sep 2025 16:03:50 GMT (envelope-from git) Date: Fri, 26 Sep 2025 16:03:50 GMT Message-Id: <202509261603.58QG3oPf069252@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Aymeric Wibo Subject: git: 9e1e29bd5ec6 - main - acpi: Add back `hw.acpi.suspend_state` sysctl List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: obiwac X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e1e29bd5ec61bba1bb3366ff4c069b0c8f75954 Auto-Submitted: auto-generated The branch main has been updated by obiwac: URL: https://cgit.FreeBSD.org/src/commit/?id=9e1e29bd5ec61bba1bb3366ff4c069b0c8f75954 commit 9e1e29bd5ec61bba1bb3366ff4c069b0c8f75954 Author: Aymeric Wibo AuthorDate: 2025-09-26 15:49:28 +0000 Commit: Aymeric Wibo CommitDate: 2025-09-26 16:03:05 +0000 acpi: Add back `hw.acpi.suspend_state` sysctl When writing an ACPI S-state to it it will set kern.power.suspend to the appropriate sleep type, and when reading from it it will return the corresponding ACPI S-state to the sleep type in kern.power.suspend. This is deprecated and kern.power.suspend should be used directly instead, but add this back because zzz(1) makes use of this and we can't easily rewrite it just now. PR: 289634 Reviewed by: cy, markj Approved by: cy, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52600 Event: EuroBSDcon 2025 Devsummit --- sys/dev/acpica/acpi.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index f9003a951d45..6994f46eba10 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -195,6 +195,7 @@ static void acpi_system_eventhandler_wakeup(void *arg, static enum power_stype acpi_sstate_to_stype(int sstate); static int acpi_sname_to_sstate(const char *sname); static const char *acpi_sstate_to_sname(int sstate); +static int acpi_suspend_state_sysctl(SYSCTL_HANDLER_ARGS); static int acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS); static int acpi_stype_sysctl(SYSCTL_HANDLER_ARGS); static int acpi_debug_objects_sysctl(SYSCTL_HANDLER_ARGS); @@ -616,6 +617,11 @@ acpi_attach(device_t dev) &sc->acpi_lid_switch_stype, 0, acpi_stype_sysctl, "A", "Lid ACPI sleep state. Set to s2idle or s2mem if you want to suspend " "your laptop when close the lid."); + SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), + OID_AUTO, "suspend_state", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, + NULL, 0, acpi_suspend_state_sysctl, "A", + "Current ACPI suspend state. This sysctl is deprecated; you probably " + "want to use kern.power.suspend instead."); SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, "standby_state", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, @@ -4352,6 +4358,32 @@ acpi_supported_sleep_state_sysctl(SYSCTL_HANDLER_ARGS) return (error); } +static int +acpi_suspend_state_sysctl(SYSCTL_HANDLER_ARGS) +{ + char name[10]; + int err; + struct acpi_softc *sc = oidp->oid_arg1; + enum power_stype new_stype; + enum power_stype old_stype = power_suspend_stype; + int old_sstate = acpi_stype_to_sstate(sc, old_stype); + int new_sstate; + + strlcpy(name, acpi_sstate_to_sname(old_sstate), sizeof(name)); + err = sysctl_handle_string(oidp, name, sizeof(name), req); + if (err != 0 || req->newptr == NULL) + return (err); + + new_sstate = acpi_sname_to_sstate(name); + if (new_sstate < 0) + return (EINVAL); + new_stype = acpi_sstate_to_stype(new_sstate); + if (acpi_supported_stypes[new_stype] == false) + return (EOPNOTSUPP); + if (new_stype != old_stype) + power_suspend_stype = new_stype; + return (err); +} static int acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS)