aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdelkader Boudih <freebsd@seuros.com>2026-08-17 03:12:00 +0000
committerEnji Cooper <ngie@FreeBSD.org>2026-09-04 23:07:01 +0000
commit6f16db3a09536c3bd18ca4c967bd8f048920f001 (patch)
treee6f27eb7a691f6a0a0873095d3ad305377a6b385
parent9c9a06e0c0953caa58da9486298bd6aaa99b405e (diff)
asmc: prefer MMIO backend over PIO when both are present
T2, T1, and some pre-T1 Macs advertise a legacy PIO range in the SMC ACPI _CRS alongside a live MMIO window, but the silicon behind the PIO range is bogus. Try MMIO first, validate via LDKN >= 2, fall back to PIO if that fails or no MMIO resource is present. Drop "(T2)" from the backend message since MMIO isn't T2-exclusive. MFC: 1 week Reviewed by: ngie Differential Revision: https://reviews.freebsd.org/D58839 (cherry picked from commit 37826269b41b46c72264191d35b09baf24e055b9)
-rw-r--r--sys/dev/asmc/asmc.c18
-rw-r--r--sys/dev/asmc/asmcmmio.c2
2 files changed, 11 insertions, 9 deletions
diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
index d55c585419fb..80412b9c8daf 100644
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -427,25 +427,22 @@ asmc_probe(device_t dev)
}
/*
- * Try PIO first; fall back to MMIO for T2 Macs.
+ * Try MMIO first; the legacy PIO range can be claimable but dead.
+ * Fall back to PIO if MMIO probe fails or the resource is absent.
*/
static int
asmc_try_probe(device_t dev)
{
struct asmc_softc *sc = device_get_softc(dev);
- sc->sc_ioport = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
- &sc->sc_rid_port, RF_ACTIVE);
- if (sc->sc_ioport != NULL)
- return (0);
-
sc->sc_rid_mem = 0;
sc->sc_iomem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
&sc->sc_rid_mem, RF_ACTIVE);
if (sc->sc_iomem != NULL) {
if (asmc_mmio_probe(dev) == 0) {
sc->sc_is_mmio = true;
- device_printf(dev, "using MMIO backend (T2)\n");
+ if (bootverbose)
+ device_printf(dev, "using MMIO backend\n");
return (0);
}
bus_release_resource(dev, SYS_RES_MEMORY,
@@ -453,7 +450,12 @@ asmc_try_probe(device_t dev)
sc->sc_iomem = NULL;
}
- device_printf(dev, "unable to allocate IO port\n");
+ sc->sc_ioport = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
+ &sc->sc_rid_port, RF_ACTIVE);
+ if (sc->sc_ioport != NULL)
+ return (0);
+
+ device_printf(dev, "unable to allocate IO port or MMIO\n");
return (ENOMEM);
}
diff --git a/sys/dev/asmc/asmcmmio.c b/sys/dev/asmc/asmcmmio.c
index 237e8ec4ed52..4981822c4723 100644
--- a/sys/dev/asmc/asmcmmio.c
+++ b/sys/dev/asmc/asmcmmio.c
@@ -292,7 +292,7 @@ asmc_mmio_probe(device_t dev)
return (ENXIO);
}
- device_printf(dev, "MMIO: LDKN=%d, T2 SMC detected\n", ldkn);
+ device_printf(dev, "MMIO: LDKN=%d, MMIO-capable SMC detected\n", ldkn);
sc->sc_is_t2 = 1;
return (0);