Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151336119
D48721.id170352.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D48721.id170352.diff
View Options
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -3442,8 +3442,9 @@
ACPI_SS_GPE_SET = 1 << 0,
ACPI_SS_DEV_SUSPEND = 1 << 1,
ACPI_SS_SPMC_SUSPEND = 1 << 2,
- ACPI_SS_SLP_PREP = 1 << 3,
- ACPI_SS_SLEPT = 1 << 4,
+ ACPI_SS_AMDSMU_SUSPEND = 1 << 3,
+ ACPI_SS_SLP_PREP = 1 << 4,
+ ACPI_SS_SLEPT = 1 << 5,
};
static void
@@ -3566,8 +3567,8 @@
ACPI_STATUS status;
enum acpi_sleep_state slp_state;
int acpi_sstate;
- devclass_t spmc_dc;
- device_t spmc = NULL;
+ devclass_t spmc_dc, amdsmu_dc;
+ device_t spmc = NULL, amdsmu = NULL;
ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, stype);
@@ -3653,6 +3654,16 @@
slp_state |= ACPI_SS_SPMC_SUSPEND;
}
+ amdsmu_dc = devclass_find("amdsmu");
+ if (amdsmu_dc != NULL)
+ amdsmu = devclass_get_device(amdsmu_dc, 0);
+ if (amdsmu != NULL) {
+ if (ACPI_PMC_SUSPEND(amdsmu) != 0)
+ device_printf(sc->acpi_dev, "failed to run AMD SMU suspend\n");
+ else
+ slp_state |= ACPI_SS_AMDSMU_SUSPEND;
+ }
+
if (stype != POWER_STYPE_SUSPEND_TO_IDLE) {
status = AcpiEnterSleepStatePrep(acpi_sstate);
if (ACPI_FAILURE(status)) {
@@ -3699,6 +3710,12 @@
sc->acpi_stype = POWER_STYPE_AWAKE;
slp_state &= ~ACPI_SS_GPE_SET;
}
+ if ((slp_state & ACPI_SS_AMDSMU_SUSPEND) != 0) {
+ MPASS(amdsmu != NULL);
+ if (ACPI_PMC_RESUME(amdsmu) != 0)
+ device_printf(sc->acpi_dev, "failed to run AMD SMU resume\n");
+ slp_state &= ~ACPI_SS_AMDSMU_SUSPEND;
+ }
if ((slp_state & ACPI_SS_SPMC_SUSPEND) != 0) {
MPASS(spmc != NULL);
if (ACPI_PMC_RESUME(spmc) != 0)
diff --git a/sys/dev/amdsmu/amdsmu.c b/sys/dev/amdsmu/amdsmu.c
--- a/sys/dev/amdsmu/amdsmu.c
+++ b/sys/dev/amdsmu/amdsmu.c
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2025 The FreeBSD Foundation
+ * Copyright (c) 2025-2026 The FreeBSD Foundation
*
* This software was developed by Aymeric Wibo <obiwac@freebsd.org>
* under sponsorship from the FreeBSD Foundation.
@@ -14,6 +14,12 @@
#include <sys/rman.h>
#include <sys/sysctl.h>
+#include "opt_acpi.h"
+
+#if defined(DEV_ACPI)
+#include "acpi_pmc_if.h"
+#endif
+
#include <dev/pci/pcivar.h>
#include <dev/amdsmu/amdsmu.h>
@@ -289,6 +295,32 @@
sc->idlemask = amdsmu_read4(sc, SMU_REG_IDLEMASK);
}
+static int
+amdsmu_suspend(device_t dev)
+{
+ int err;
+
+ err = amdsmu_cmd(dev, SMU_MSG_SLEEP_HINT, true, NULL);
+ if (err != 0) {
+ device_printf(dev, "failed to hint to SMU to enter sleep");
+ return (err);
+ }
+ return (0);
+}
+
+static int
+amdsmu_resume(device_t dev)
+{
+ int err;
+
+ err = amdsmu_cmd(dev, SMU_MSG_SLEEP_HINT, false, NULL);
+ if (err != 0) {
+ device_printf(dev, "failed to hint to SMU to exit sleep");
+ return (err);
+ }
+ return (amdsmu_dump_metrics(dev));
+}
+
static int
amdsmu_attach(device_t dev)
{
@@ -450,6 +482,11 @@
DEVMETHOD(device_probe, amdsmu_probe),
DEVMETHOD(device_attach, amdsmu_attach),
DEVMETHOD(device_detach, amdsmu_detach),
+
+#if defined(DEV_ACPI)
+ DEVMETHOD(acpi_pmc_suspend, amdsmu_suspend),
+ DEVMETHOD(acpi_pmc_resume, amdsmu_resume),
+#endif
DEVMETHOD_END
};
diff --git a/sys/dev/amdsmu/amdsmu_reg.h b/sys/dev/amdsmu/amdsmu_reg.h
--- a/sys/dev/amdsmu/amdsmu_reg.h
+++ b/sys/dev/amdsmu/amdsmu_reg.h
@@ -45,6 +45,7 @@
enum amdsmu_msg {
SMU_MSG_GETSMUVERSION = 0x02,
+ SMU_MSG_SLEEP_HINT = 0x03,
SMU_MSG_LOG_GETDRAM_ADDR_HI = 0x04,
SMU_MSG_LOG_GETDRAM_ADDR_LO = 0x05,
SMU_MSG_LOG_START = 0x06,
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m
--- a/sys/kern/bus_if.m
+++ b/sys/kern/bus_if.m
@@ -31,7 +31,7 @@
/**
* @defgroup BUS bus - KObj methods for drivers of devices with children
- * @brief A set of methods required device drivers that support
+ * @brief A set of methods required for device drivers that support
* child devices.
* @{
*/
diff --git a/sys/modules/amdsmu/Makefile b/sys/modules/amdsmu/Makefile
--- a/sys/modules/amdsmu/Makefile
+++ b/sys/modules/amdsmu/Makefile
@@ -9,6 +9,6 @@
KMOD= amdsmu
SRCS= amdsmu.c
-SRCS+= bus_if.h device_if.h pci_if.h
+SRCS+= bus_if.h device_if.h pci_if.h opt_acpi.h acpi_pmc_if.h
.include <bsd.kmod.mk>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 8, 4:50 PM (54 m, 40 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31108446
Default Alt Text
D48721.id170352.diff (4 KB)
Attached To
Mode
D48721: amdsmu: Sleep entry/exit hints for PMFW
Attached
Detach File
Event Timeline
Log In to Comment