From nobody Wed Apr 8 12:11:50 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 4frMPS1pbTz6Y245 for ; Wed, 08 Apr 2026 12:11:56 +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" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4frMPS0VVjz3QKP for ; Wed, 08 Apr 2026 12:11:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1775650316; 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=+IiPF8gfABaK1lYMTcrJ4090sUAckmx5gGquxKbT2Ao=; b=DCvi9Vp/gNkcJ8ElX8p+PX/pNjh9KOQxxMMiPQhdfy+3bvBlO2iZPD61bTKf6GYay0hxYI nlLxUGBDooi9I2pe3szz8qdQl5AEg/DbuW2EQlkV9n2NbcZYrfd1nYP5YK/q6EClQBryUu 0D5VBRJl3pGth5eXApkCLzjIHsL6q5RyAeME5gXGV7NjViwyEEHs/p98A7T2TNBT1MszHx zljelSkYqlbgubm9RQqML0IEcXdjKWTEo/nXtb5yiqFzfb7MO9q0MEUW8TdB3PcJRXVJt9 FXcUPPFeUVYiLLngVrvznMIK3yz5yJ/4CvwlhfRdlwumrljd1f/S8gWvcfmP0Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1775650316; a=rsa-sha256; cv=none; b=kev0Z/LrEx8gqnVLw+MZ0uiaI2jUloKUlI9nfBTsJRC73X8h4WWXrMdVJgOYh9C85Fqkei r1Gk9U9oBSBEDO0iX1CLL4WUAFuf9Js20zMOXZoGzwZDjKdm8QOplmuaS7kQnPrJa5cK89 BG70BClJRewJqiKDa4UT9Axx7BgmRLxkbfsqtCQu9vFrHaxLa06fX1A7OMY+vlG9F48LNS jxqWRfawrAUEWvXnSpHT8iF17xVqGPdlhojvYtEJ5/E7NnfSYpnQ6iSCllTiLYZY6Choro 6kpMqk7nKHUqTW2rxjYnw0waqol1vYtWusLTltU8LZef7AsWvDiKiPAKCiA50Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1775650316; 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=+IiPF8gfABaK1lYMTcrJ4090sUAckmx5gGquxKbT2Ao=; b=Dc1EAOAgUE2hFGPF7KW3yKU4DhklCC6wlSKl9hf+adKRgnDn4crGt9As1FRhIb8c9vnW0w /Dd56kDBwqc3NKa+nLP25YuaNhTkrjPqw9DYD37ngZQSMEII6Eac5+M91+vo7BdBnPj11h VLwGoUgxdi96YJZ+qzrsl+jAZQv08ybBVaei6VgpC1OgH5U+Wk1Oa+00nUVpYgNcX9a6Rl QSrbEiRJMOXqVt6POy/C5SL2YVDklSlQDgGbsMPobscw/q71st+g4xhl0hF0byrXMoaTkd XE4TI/XVtZObbbaDjUeOwwgAUVeRxpi+tvGeKPV0MmFqUz93ed2XZDWBogSrJg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4frMPS008Nz9b0 for ; Wed, 08 Apr 2026 12:11:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27533 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 08 Apr 2026 12:11:50 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Aymeric Wibo Subject: git: 19ab46cc6604 - main - acpi: Parse _S3D in s2idle instead of _S255D 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: 19ab46cc66045ea936475f1a1e08763eb2fd663e Auto-Submitted: auto-generated Date: Wed, 08 Apr 2026 12:11:50 +0000 Message-Id: <69d64606.27533.60b92c0f@gitrepo.freebsd.org> The branch main has been updated by obiwac: URL: https://cgit.FreeBSD.org/src/commit/?id=19ab46cc66045ea936475f1a1e08763eb2fd663e commit 19ab46cc66045ea936475f1a1e08763eb2fd663e Author: Aymeric Wibo AuthorDate: 2026-03-04 13:09:14 +0000 Commit: Aymeric Wibo CommitDate: 2026-04-08 12:11:23 +0000 acpi: Parse _S3D in s2idle instead of _S255D Previously, when entering s2idle, we were parsing the _S255D object to get the shallowest D-state supported by device, as acpi_stype_to_sstate() returns -1 for s2idle. Instead, we should read _S3D. Relevant document: https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/07_Power_and_Performance_Mgmt/device-power-management-objects.html#s3d-s3-device-state Reviewed by: olce Tested by: emaste, olce Approved by: olce Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55118 --- sys/dev/acpica/acpi.c | 84 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 98578b383f42..bdc197a4fb59 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -2131,44 +2131,64 @@ acpi_bus_get_prop(device_t bus, device_t child, const char *propname, } } +static int +acpi_device_pwr_for_sleep_sxd(device_t dev, ACPI_HANDLE handle, int state, + int *dstate) +{ + ACPI_STATUS status; + char sxd[8]; + + /* Note illegal _S0D is evaluated because some systems expect this. */ + snprintf(sxd, sizeof(sxd), "_S%dD", state); + status = acpi_GetInteger(handle, sxd, dstate); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + device_printf(dev, "failed to get %s on %s: %s\n", sxd, + acpi_name(handle), AcpiFormatException(status)); + return (ENXIO); + } + return (0); +} + +/* + * Get the D-state we need to set the device to for entry into the sleep type + * we are currently entering (sc->acpi_stype is set in acpi_EnterSleepState + * before the ACPI bus gets suspended, and thus before this function is called). + * + * If entering s2idle, we will try to enter whichever D-state we would've been + * transitioning to in S3. If we are entering an ACPI S-state, we evaluate the + * relevant _SxD state instead (ACPI 7.3.16 - 7.3.19). + */ int acpi_device_pwr_for_sleep(device_t bus, device_t dev, int *dstate) { - struct acpi_softc *sc; - ACPI_HANDLE handle; - ACPI_STATUS status; - char sxd[8]; - - handle = acpi_get_handle(dev); + struct acpi_softc *sc = device_get_softc(bus); + ACPI_HANDLE handle = acpi_get_handle(dev); + int state; - /* - * XXX If we find these devices, don't try to power them down. - * The serial and IRDA ports on my T23 hang the system when - * set to D3 and it appears that such legacy devices may - * need special handling in their drivers. - */ - if (dstate == NULL || handle == NULL || - acpi_MatchHid(handle, "PNP0500") || - acpi_MatchHid(handle, "PNP0501") || - acpi_MatchHid(handle, "PNP0502") || - acpi_MatchHid(handle, "PNP0510") || - acpi_MatchHid(handle, "PNP0511")) - return (ENXIO); + if (dstate == NULL) + return (EINVAL); - /* - * Override next state with the value from _SxD, if present. - * Note illegal _S0D is evaluated because some systems expect this. - */ - sc = device_get_softc(bus); - snprintf(sxd, sizeof(sxd), "_S%dD", acpi_stype_to_sstate(sc, sc->acpi_stype)); - status = acpi_GetInteger(handle, sxd, dstate); - if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { - device_printf(dev, "failed to get %s on %s: %s\n", sxd, - acpi_name(handle), AcpiFormatException(status)); - return (ENXIO); - } + /* + * XXX If we find these devices, don't try to power them down. + * The serial and IRDA ports on my T23 hang the system when + * set to D3 and it appears that such legacy devices may + * need special handling in their drivers. + */ + if (handle == NULL || + acpi_MatchHid(handle, "PNP0500") || + acpi_MatchHid(handle, "PNP0501") || + acpi_MatchHid(handle, "PNP0502") || + acpi_MatchHid(handle, "PNP0510") || + acpi_MatchHid(handle, "PNP0511")) + return (ENXIO); - return (0); + if (sc->acpi_stype == POWER_STYPE_SUSPEND_TO_IDLE) + state = ACPI_STATE_S3; + else + state = acpi_stype_to_sstate(sc, sc->acpi_stype); + if (state == ACPI_STATE_UNKNOWN) + return (ENOENT); + return (acpi_device_pwr_for_sleep_sxd(bus, handle, state, dstate)); } /* Callback arg for our implementation of walking the namespace. */