git: 5f68acc931a4 - main - acpi: Warn if no amdsmu(4) loaded after suspend-to-idle resume

From: Aymeric Wibo <obiwac_at_FreeBSD.org>
Date: Wed, 16 Sep 2026 16:22:44 UTC
The branch main has been updated by obiwac:

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

commit 5f68acc931a4814c4ee46124aaa5afff22402f61
Author:     Aymeric Wibo <obiwac@FreeBSD.org>
AuthorDate: 2026-09-14 18:14:54 +0000
Commit:     Aymeric Wibo <obiwac@FreeBSD.org>
CommitDate: 2026-09-16 16:21:41 +0000

    acpi: Warn if no amdsmu(4) loaded after suspend-to-idle resume
    
    If amdsmu(4) is not loaded when entering suspend-to-idle and on an AMD
    CPU, emit a warning.
    
    FreeBSD currently only supports S0ix on AMD CPUs through the SMU. When
    Intel support is completed, we should check the equivalent for Intel
    (intelpmc).
    
    Reviewed by:    olce
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D59672
---
 sys/dev/acpica/acpi.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 7f9e637c25f9..33d4572b1d2e 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -3660,6 +3660,36 @@ do_idle(struct acpi_softc *sc, enum acpi_sleep_state *slp_state,
 }
 #endif
 
+static void
+check_post_suspend_to_idle(device_t dev)
+{
+	devclass_t dc;
+#if defined(__x86_64__)
+	u_int vendor_id = cpu_vendor_id;
+#else
+	u_int vendor_id = 0;
+#endif
+
+	switch (vendor_id) {
+	case CPU_VENDOR_AMD:
+	case CPU_VENDOR_HYGON:
+		dc = devclass_find("amdsmu");
+
+		if (dc != NULL && devclass_get_count(dc) > 0)
+			break;
+		device_printf(dev,
+		    "Resumed from suspend-to-idle on AMD processor but "
+		    "amdsmu(4) is not attached; unable to verify S0i3 entry. "
+		    "It is unlikely the system entered a deep sleep state.\n");
+		break;
+	default:
+		device_printf(dev,
+		    "Resumed from suspend-to-idle on a processor FreeBSD does "
+		    "not yet support for this. It is unlikely the system "
+		    "entered a deep sleep state.\n");
+	}
+}
+
 /*
  * Enter the desired system sleep state.
  *
@@ -3836,6 +3866,9 @@ backout:
 
     EVENTHANDLER_INVOKE(power_resume, stype);
 
+    if (stype == POWER_STYPE_SUSPEND_TO_IDLE)
+	check_post_suspend_to_idle(sc->acpi_dev);
+
     /* Allow another sleep request after a while. */
     callout_schedule(&acpi_sleep_timer, hz * ACPI_MINIMUM_AWAKETIME);