From nobody Tue Nov 22 06:12:39 2022 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 4NGYnz4Jybz4j1Ck; Tue, 22 Nov 2022 06:12:39 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NGYnz35knz3GHr; Tue, 22 Nov 2022 06:12:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669097559; 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=77PD3N75vWLJoOTF8oQhrSloSBCvEp2Vzf0G8Qd/SS8=; b=OfCq/ZBj8KZmU0Sk1BTceRDjb3V7nruZ+Q8t9RPjcPjGfyu0ZE/X7nfrKIKNHQRwSDldTz yrpAby4lH9wTHt7MDpy9deKuQBls3BWu01CaJMKIrkah3KG8oCPldRcXMPHsRZrWBJ5Xql X6kBpmOIyPJy9Mf5K6fWrMtiuGwWvVqhCrApu0XPicJG13n14wMd93ag6bxA31smQx5FOA EUo8uRYE3mA0ATRIveo51RR6/EkeDpZQpfvgNG4k8dmqI6cYxRZQePjQPzBAqMndHU0IyZ /7KZ1hbSTJPCfup8MQ5JkjnSFe4F8ZXuHmlwuUWHbVLKy9RL7B+ZJ8AzNrc54w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669097559; 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=77PD3N75vWLJoOTF8oQhrSloSBCvEp2Vzf0G8Qd/SS8=; b=yEO6cqYQXOHqsFZNFl6z9/FJ+CKxmi1bK9TsJcGlZstoZcHtnhiji+6DHheUclA6GNTBwm VY5kjMIXy12WB3tPUYtvpUp+W0MB7nrM9TdAfM16qi/STy5WZRlpWoPDPIThxO8fIuhn8+ pvNAgV1ztWW6nxfw5h3nxhKP25leHCTR19O9BKIRptMxdezOnRvHXb168AJJIz4Uxm2LQx KFx+J68bwRaLLFW39yYHrIeDImeOECIT9m172nCh0ZzZj9bgqptLvYUMGkiRBDrZzavR4l YCqSvQvI+EEy1/HCaPo2X3nBrywX8+Nf1ZRr7UP5EYQCcny3IuysFfmBYpJLKg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669097559; a=rsa-sha256; cv=none; b=yK9Wtotds7AIptkpQnkTLQb091TcymRcdRZC8skCNeFKxpNNB40CGhxtd1TUzY14yBDPl5 qO+Q9OKSPglp9ryWpRTScO94xTDDufqxH41A9msesfORLSh5VZcC33j+JzO/1ZEjiob947 WyxiiJWVjfa/H8hCbkH0kbNFh1J/f9xDJ7PVlxMeS7LJy8Wpl3C2v8jd+azB5i5BoNjolS 0DTbuxChpmKkh2DSesbU2VY5DdP9ILwfZoKwwhvwREX0KKdNAx2zCPIJmQYSdEE4jecm+k EUuzbP7O3VwnyUAk4PrGOnM2Iu4FWYs74lTVwN9RdjzaGuWptDOkZ/8wmmkZUQ== 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 4NGYnz2BLhzXyT; Tue, 22 Nov 2022 06:12:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AM6Cd7m072160; Tue, 22 Nov 2022 06:12:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AM6Cdfq072159; Tue, 22 Nov 2022 06:12:39 GMT (envelope-from git) Date: Tue, 22 Nov 2022 06:12:39 GMT Message-Id: <202211220612.2AM6Cdfq072159@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: b8a0dfb17e3b - main - Add support for _CR3 critical standby (S3) threshold. 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b8a0dfb17e3b62f228bb29e1098b34b3198f8e73 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b8a0dfb17e3b62f228bb29e1098b34b3198f8e73 commit b8a0dfb17e3b62f228bb29e1098b34b3198f8e73 Author: Cyrus Rahman AuthorDate: 2022-11-18 18:30:30 +0000 Commit: John Baldwin CommitDate: 2022-11-22 06:12:04 +0000 Add support for _CR3 critical standby (S3) threshold. Along with _PSV, _HOT, and _CRT, ACPI supports the _CR3 threshold which specifies a temperature above which a system should transition to the S3 standby state. On FreeBSD, this is more useful than _HOT, which specifies the S4 transition threshold temperature (since FreeBSD does not generally support the S4 state), or, in many cases, _CRT, since after transitioning to S3 the system can cool and then be resumed. Reviewed by: jhb, bcr (manpages) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D35980 --- share/man/man4/acpi_thermal.4 | 5 ++++- sys/dev/acpica/acpi_thermal.c | 26 +++++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/share/man/man4/acpi_thermal.4 b/share/man/man4/acpi_thermal.4 index d1cf8ee60ef2..1b9395a24be3 100644 --- a/share/man/man4/acpi_thermal.4 +++ b/share/man/man4/acpi_thermal.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 17, 2007 +.Dd November 21, 2022 .Dt ACPI_THERMAL 4 .Os .Sh NAME @@ -84,6 +84,9 @@ Current temperature for this zone. .It Va hw.acpi.thermal.tz%d._PSV Temperature to start passive cooling by throttling down CPU, etc. This value can be overridden by the user. +.It Va hw.acpi.thermal.tz%d._CR3 +Temperature to start critical suspend to RAM (S3). +This value can be overridden by the user. .It Va hw.acpi.thermal.tz%d._HOT Temperature to start critical suspend to disk (S4). This value can be overridden by the user. diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c index bd9ecf455e26..2ff9de6802fb 100644 --- a/sys/dev/acpica/acpi_thermal.c +++ b/sys/dev/acpica/acpi_thermal.c @@ -60,7 +60,7 @@ ACPI_MODULE_NAME("THERMAL") #define TZ_NOTIFY_TEMPERATURE 0x80 /* Temperature changed. */ #define TZ_NOTIFY_LEVELS 0x81 /* Cooling levels changed. */ #define TZ_NOTIFY_DEVICES 0x82 /* Device lists changed. */ -#define TZ_NOTIFY_CRITICAL 0xcc /* Fake notify that _CRT/_HOT reached. */ +#define TZ_NOTIFY_CRITICAL 0xcc /* Fake notify that _CRT/_HOT/_CR3 reached. */ /* Check for temperature changes every 10 seconds by default */ #define TZ_POLLRATE 10 @@ -78,6 +78,7 @@ struct acpi_tz_zone { ACPI_BUFFER al[TZ_NUMLEVELS]; int crt; int hot; + int cr3; ACPI_BUFFER psl; int psv; int tc1; @@ -97,8 +98,9 @@ struct acpi_tz_softc { int tz_thflags; /*Current temp-related flags*/ #define TZ_THFLAG_NONE 0 #define TZ_THFLAG_PSV (1<<0) -#define TZ_THFLAG_HOT (1<<2) -#define TZ_THFLAG_CRT (1<<3) +#define TZ_THFLAG_CR3 (1<<2) +#define TZ_THFLAG_HOT (1<<3) +#define TZ_THFLAG_CRT (1<<4) int tz_flags; #define TZ_FLAG_NO_SCP (1<<0) /*No _SCP method*/ #define TZ_FLAG_GETPROFILE (1<<1) /*Get power_profile in timeout*/ @@ -281,6 +283,10 @@ acpi_tz_attach(device_t dev) OID_AUTO, "_PSV", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, offsetof(struct acpi_tz_softc, tz_zone.psv), acpi_tz_temp_sysctl, "IK", "passive cooling temp setpoint"); + SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), + OID_AUTO, "_CR3", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, + offsetof(struct acpi_tz_softc, tz_zone.cr3), acpi_tz_temp_sysctl, "IK", + "too warm temp setpoint (standby now)"); SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), OID_AUTO, "_HOT", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, offsetof(struct acpi_tz_softc, tz_zone.hot), acpi_tz_temp_sysctl, "IK", @@ -420,6 +426,7 @@ acpi_tz_establish(struct acpi_tz_softc *sc) } acpi_tz_getparam(sc, "_CRT", &sc->tz_zone.crt); acpi_tz_getparam(sc, "_HOT", &sc->tz_zone.hot); + acpi_tz_getparam(sc, "_CR3", &sc->tz_zone.cr3); sc->tz_zone.psl.Length = ACPI_ALLOCATE_BUFFER; sc->tz_zone.psl.Pointer = NULL; AcpiEvaluateObject(sc->tz_handle, "_PSL", NULL, &sc->tz_zone.psl); @@ -437,6 +444,7 @@ acpi_tz_establish(struct acpi_tz_softc *sc) */ acpi_tz_sanity(sc, &sc->tz_zone.crt, "_CRT"); acpi_tz_sanity(sc, &sc->tz_zone.hot, "_HOT"); + acpi_tz_sanity(sc, &sc->tz_zone.cr3, "_CR3"); acpi_tz_sanity(sc, &sc->tz_zone.psv, "_PSV"); for (i = 0; i < TZ_NUMLEVELS; i++) acpi_tz_sanity(sc, &sc->tz_zone.ac[i], "_ACx"); @@ -494,6 +502,7 @@ acpi_tz_get_temperature(struct acpi_tz_softc *sc) static void acpi_tz_monitor(void *Context) { + struct acpi_softc *acpi_sc; struct acpi_tz_softc *sc; struct timespec curtime; int temp; @@ -544,6 +553,8 @@ acpi_tz_monitor(void *Context) newflags = TZ_THFLAG_NONE; if (sc->tz_zone.psv != -1 && temp >= sc->tz_zone.psv) newflags |= TZ_THFLAG_PSV; + if (sc->tz_zone.cr3 != -1 && temp >= sc->tz_zone.cr3) + newflags |= TZ_THFLAG_CR3; if (sc->tz_zone.hot != -1 && temp >= sc->tz_zone.hot) newflags |= TZ_THFLAG_HOT; if (sc->tz_zone.crt != -1 && temp >= sc->tz_zone.crt) @@ -603,13 +614,18 @@ acpi_tz_monitor(void *Context) * * If we're almost at that threshold, notify the user through devd(8). */ - if ((newflags & (TZ_THFLAG_HOT | TZ_THFLAG_CRT)) != 0) { + if ((newflags & (TZ_THFLAG_CR3 | TZ_THFLAG_HOT | TZ_THFLAG_CRT)) != 0) { sc->tz_validchecks++; if (sc->tz_validchecks == TZ_VALIDCHECKS) { device_printf(sc->tz_dev, "WARNING - current temperature (%d.%dC) exceeds safe limits\n", TZ_KELVTOC(sc->tz_temperature)); - shutdown_nice(RB_POWEROFF); + if ((newflags & (TZ_THFLAG_HOT | TZ_THFLAG_CRT)) != 0) + shutdown_nice(RB_POWEROFF); + else { + acpi_sc = acpi_device_get_parent_softc(sc->tz_dev); + acpi_ReqSleepState(acpi_sc, ACPI_STATE_S3); + } } else if (sc->tz_validchecks == TZ_NOTIFYCOUNT) acpi_UserNotify("Thermal", sc->tz_handle, TZ_NOTIFY_CRITICAL); } else {