From nobody Wed Apr 8 12:11:50 2026 X-Original-To: dev-commits-src-main@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 4frMPM10lDz6Y2CJ for ; Wed, 08 Apr 2026 12:11:51 +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 4frMPM0N79z3QJf for ; Wed, 08 Apr 2026 12:11:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1775650311; 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=InbOXc4tvCMsBFxs9lWYfwxEtDLSc+W1YsGw51djZIvSFDiCVxMASQa0B2r0eboDDAZgZA ZR2mdqLQap6qGU3IVO2x97+/b2ZEa1NqolNOchVGUNo2IqL1haOTyG6Gk6YcU3Eon/fZLx 9jdF1K5BoSUM3rEoY4k+Sb1NKFlUBzHGanFSLo2Qr/t88CGFreRnGY706vmkyu69DFSxka ZStZDktz0FATW/GwhfKhLuwB15fyOo1+sdvr9o3rvrEqBAwAeEAFLfdIKySCrf9amRa9B+ TBRjTrh52Vj5WBhTDx6BEREoV7W822rPQ0mJT/I6iVpmPlMliwNR7Muv0eLcxA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1775650311; a=rsa-sha256; cv=none; b=EE6+N6iA7x3mYguN/KmP79wV9TEBtqx6i5Z30f4n7TKNSBu1mTNRc4SgGuUwxHoULrusY8 i1vr9bG+rTFjYsfPuctPV9zVmVWGm00BdtQgYMtVzpmii+ISnlPoOwMsdlEhSTh23eiu6F rNIcRCoqlsjuM1/qJ3z2E/ODilxbjtdQnGUOjjCKwmUSGpwz/3vm8+2tnOiP6Ejj3y/G4W KaD6l1Oq7h/6tzTyJ2hlaBiKeLtWOhgFF0xEmv6imE6bfacjpTmDgGpzbdpHA+hVYFITVx 5ae1V2w9kYLVwwYy6a3ktQno1d5qdo+cTo7RSoGcvtMQoWKpc9otpD3EsQr2YQ== 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=1775650311; 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=cVWgSvx2aFUfpAE01S+42Vayy172yNGKeJzAjY9e/mrpGmxoLoN+TQpghU3oyUZzeLSxTg dMOJAbnp9aVgKBWXfwnFHf406H3QtfMSReEhQdl+37NKArLiSxOEEln8BpirWMno3VLwO/ jYKDSx7vPU+NmOEoYoooc+t6nN8pgQmEzshPflvXhyC+hzXv2eAetib9VxicnPEAPtc62L kJQqXutuiKNugd9jpCAAjmSCAWq0lODlfGeCQk72CCHiYoXRlUCCfjKAvA/rh+yB+veGKg LPYsqsDghiuqLum4DE5rJYo1yRonD4wpKX+4tnLVaMJm00vR9hPmFcr70KWQaw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4frMPL72NHz9gk for ; Wed, 08 Apr 2026 12:11:50 +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 the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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. */