git: ff3f704d922a - main - acpi_cpu: Bring back setting BM_RLD on resume

From: Aymeric Wibo <obiwac_at_FreeBSD.org>
Date: Wed, 11 Nov 2026 11:31:19 UTC
The branch main has been updated by obiwac:

URL: https://cgit.FreeBSD.org/src/commit/?id=ff3f704d922a7e0c8c32525fa0ebfc5a6e397160

commit ff3f704d922a7e0c8c32525fa0ebfc5a6e397160
Author:     Aymeric Wibo <obiwac@FreeBSD.org>
AuthorDate: 2026-11-11 11:09:28 +0000
Commit:     Aymeric Wibo <obiwac@FreeBSD.org>
CommitDate: 2026-11-11 11:30:54 +0000

    acpi_cpu: Bring back setting BM_RLD on resume
    
    enable_idle(), which was called on resume before 427747fc16c9
    ("acpi_cpu: No longer disable idle during suspend"), also set BM_RLD.
    
    This commit brings back just setting BM_RLD on resume because some
    firmware might not be doing this itself on some machines.
    
    Reviewed by:    olce
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D61431
---
 sys/dev/acpica/acpi_cpu.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index 9a523611a7f9..267c0d1cf7f5 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -169,6 +169,7 @@ static device_t	acpi_cpu_add_child(device_t dev, u_int order, const char *name,
 static int	acpi_cpu_read_ivar(device_t dev, device_t child, int index,
 		    uintptr_t *result);
 static int	acpi_cpu_shutdown(device_t dev);
+static int	acpi_cpu_resume(device_t dev);
 static void	acpi_cpu_cx_probe(struct acpi_cpu_softc *sc);
 static void	acpi_cpu_generic_cx_probe(struct acpi_cpu_softc *sc);
 static int	acpi_cpu_cx_cst(struct acpi_cpu_softc *sc);
@@ -198,7 +199,7 @@ static device_method_t acpi_cpu_methods[] = {
     DEVMETHOD(device_detach,	bus_generic_detach),
     DEVMETHOD(device_shutdown,	acpi_cpu_shutdown),
     DEVMETHOD(device_suspend,	bus_generic_suspend),
-    DEVMETHOD(device_resume,	bus_generic_resume),
+    DEVMETHOD(device_resume,	acpi_cpu_resume),
 
     /* Bus interface */
     DEVMETHOD(bus_add_child,	acpi_cpu_add_child),
@@ -511,13 +512,18 @@ disable_idle(struct acpi_cpu_softc *sc)
 }
 
 static void
-enable_idle(struct acpi_cpu_softc *sc)
+set_bm_rld(struct acpi_cpu_softc *sc)
 {
+	if (sc->cpu_cx_count > sc->cpu_non_c3 + 1 &&
+	    (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0)
+		AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1);
+}
 
-    if (sc->cpu_cx_count > sc->cpu_non_c3 + 1 &&
-	(cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0)
-	    AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1);
-    sc->cpu_disable_idle = FALSE;
+static void
+enable_idle(struct acpi_cpu_softc *sc)
+{
+	set_bm_rld(sc);
+	sc->cpu_disable_idle = FALSE;
 }
 
 #if defined(__i386__) || defined(__amd64__)
@@ -529,6 +535,18 @@ is_idle_disabled(struct acpi_cpu_softc *sc)
 }
 #endif
 
+static int
+acpi_cpu_resume(device_t dev)
+{
+	/*
+	 * XXX It probably makes more sense to do this once in the S3/S4 resume
+	 * path, as BM_RLD is a global PM1_CNT bit only lost there, rather than
+	 * for each acpi_cpu.
+	 */
+	set_bm_rld(device_get_softc(dev));
+	return (bus_generic_resume(dev));
+}
+
 /*
  * Find the processor associated with a given ACPI ID.
  */