git: 9a4bb77040f0 - main - amdsmu: Use devclass name instead of module name

From: Aymeric Wibo <obiwac_at_FreeBSD.org>
Date: Mon, 26 Oct 2026 16:42:57 UTC
The branch main has been updated by obiwac:

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

commit 9a4bb77040f074f6e842a54f8aedf7a24c0eab42
Author:     Aymeric Wibo <obiwac@FreeBSD.org>
AuthorDate: 2026-10-24 00:02:52 +0000
Commit:     Aymeric Wibo <obiwac@FreeBSD.org>
CommitDate: 2026-10-26 16:35:18 +0000

    amdsmu: Use devclass name instead of module name
    
    The diagnostics array contained expected modules to be loaded but the
    checking logic checked for if a devclass of that name existed instead.
    
    Have the diagnostics array contain the devclass instead as well as the
    module to load for the hint string.
    
    Furthermore, check tha the number of devices is greater than 0 so that
    leftover devclasses from unloaded modules don't skip the hint.
    
    Reported by:    emaste
    Reviewed by:    emaste
    Fixes:  758578370f6b ("amdsmu: Hints on what to do if IP block blocking S0i3")
    Sponsored by:   The FreeBSD Foundation
    Pull Request:   https://ron-dev.freebsd.org/FreeBSD/src/pulls/70
---
 sys/dev/amdsmu/amdsmu.c | 13 ++++++++-----
 sys/dev/amdsmu/amdsmu.h | 20 +++++++++++---------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/sys/dev/amdsmu/amdsmu.c b/sys/dev/amdsmu/amdsmu.c
index c37a06e18454..cee7dbec95d7 100644
--- a/sys/dev/amdsmu/amdsmu.c
+++ b/sys/dev/amdsmu/amdsmu.c
@@ -320,6 +320,7 @@ amdsmu_resume_check(device_t dev, enum power_stype stype)
 	struct amdsmu_metrics *m = &sc->metrics;
 	bool any_blocking = false;
 	const struct amdsmu_diagnostics *d;
+	devclass_t dc;
 
 	if (stype != POWER_STYPE_SUSPEND_TO_IDLE)
 		return;
@@ -380,11 +381,13 @@ amdsmu_resume_check(device_t dev, enum power_stype stype)
 
 		if (d == NULL)
 			continue;
-		if (d->expected_module != NULL &&
-		    devclass_find(d->expected_module) == NULL)
-			device_printf(dev,
-			    "    hint: load %s to allow this block to "
-			    "suspend\n", d->expected_module);
+		if (d->expected_devclass != NULL) {
+			dc = devclass_find(d->expected_devclass);
+			if (dc == NULL || devclass_get_count(dc) == 0)
+				device_printf(dev,
+				    "    hint: load %s to allow this block to "
+				    "suspend\n", d->mod_to_load);
+		}
 		if (d->extra != NULL)
 			device_printf(dev, "    hint: %s\n", d->extra);
 	}
diff --git a/sys/dev/amdsmu/amdsmu.h b/sys/dev/amdsmu/amdsmu.h
index 263adfb1d977..5cfa8d19ccdb 100644
--- a/sys/dev/amdsmu/amdsmu.h
+++ b/sys/dev/amdsmu/amdsmu.h
@@ -123,26 +123,28 @@ static const struct amdsmu_product {
 static const struct amdsmu_diagnostics {
 	const char	*blocking_ip_block;
 	bool		ignore;
-	const char	*expected_module;
+	const char	*expected_devclass;
+	/* mod_to_load must not be NULL if expected_devclass is not NULL. */
+	const char	*mod_to_load;
 	const char	*extra;
 } amdsmu_diagnostics[] = {
-	{ "CPU", false, NULL, "this can happen due to other IP blocks or "
+	{ "CPU", false, NULL, NULL, "this can happen due to other IP blocks or "
 	    "because the system was on AC power" },
-	{ "MPM", false, NULL, "this can happen due to other IP blocks or "
-	    "because the system was on AC power" },
-	{ "GFX", false, "amdgpu", NULL },
-	{ "DISPLAY", false, "amdgpu", NULL },
+	{ "MPM", false, NULL, NULL, "this can happen due to other IP blocks or "
+	    "because the CPU didn't properly idle" },
+	{ "GFX", false, "drmn", "amdgpu", NULL },
+	{ "DISPLAY", false, "drmn", "amdgpu", NULL },
 	/*
 	 * On Phoenix and Krackan Point, these seem to report USB4, not USB3 as
 	 * their names would suggest.
 	 */
-	{ "USB3_0", false, "tb", "see thunderbolt(4)" },
-	{ "USB3_1", false, "tb", "see thunderbolt(4)" },
+	{ "USB3_0", false, "nhi", "tb", "see thunderbolt(4)" },
+	{ "USB3_1", false, "nhi", "tb", "see thunderbolt(4)" },
 	/*
 	 * On Phoenix and Krackan Point, the SMU seems to report garbage for
 	 * this IP block.
 	 */
-	{ "USB4_0", true, NULL, NULL },
+	{ "USB4_0", true, NULL, NULL, NULL },
 };
 
 struct amdsmu_softc {