git: 37826269b41b - main - asmc: prefer MMIO backend over PIO when both are present
Enji Cooper <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.cvs.src,gmane.os.freebsd.current.scm |
|---|---|
| Message-ID | <[email protected]> |
The branch main has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=37826269b41b46c72264191d35b09baf24e055b9 commit 37826269b41b46c72264191d35b09baf24e055b9 Author: Abdelkader Boudih <[email protected]> AuthorDate: 2026-08-17 03:12:00 +0000 Commit: Enji Cooper <[email protected]> CommitDate: 2026-08-17 03:12:42 +0000 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 --- sys/dev/asmc/asmc.c | 18 ++++++++++-------- sys/dev/asmc/asmcmmio.c | 2 +- 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);