From: joshua stein Subject: acpiec: try a short busy-wait first To: tech@openbsd.org Date: Mon, 10 Nov 2025 21:12:47 -0600 A single execution of acpisbs_read() does 1027 EC reads, 299 writes, and takes about 5980 milliseconds. It has to do this on the ACPI task queue thread which means anything else behind it has to wait up to nearly 6 seconds to run. If we busy-wait for a wee bit before falling back on tsleep, the same acpisbs function with the same number of EC reads/writes finishes in 125 milliseconds. diff --git sys/dev/acpi/acpiec.c sys/dev/acpi/acpiec.c index e6add9e7ef0..fc490ecbd33 100644 --- sys/dev/acpi/acpiec.c +++ sys/dev/acpi/acpiec.c @@ -91,7 +91,8 @@ void acpiec_wait(struct acpiec_softc *sc, uint8_t mask, uint8_t val) { static int acpiecnowait; - uint8_t stat; + int tries = 0; + uint8_t stat; dnprintf(40, "%s: EC wait_ns for: %b == %02x\n", DEVNAME(sc), (int)mask, @@ -100,7 +101,7 @@ acpiec_wait(struct acpiec_softc *sc, uint8_t mask, uint8_t val) while (((stat = acpiec_status(sc)) & mask) != val) { if (stat & EC_STAT_SCI_EVT) sc->sc_gotsci = 1; - if (cold || (stat & EC_STAT_BURST)) + if (cold || (stat & EC_STAT_BURST) || tries++ < 300) delay(1); else tsleep(&acpiecnowait, PWAIT, "acpiec", 1);