The acpi_event_wait() loop is tricky.  I'm leaving it alone for now.

Everything else here is straightforward, though.  The acpiec(4) sleep
is adjacent to a delay of 1 microsecond so I've chosen that to replace
the current duration of 1 tick.

ok?

Index: acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.374
diff -u -p -r1.374 acpi.c
--- acpi.c      7 Sep 2019 13:46:20 -0000       1.374
+++ acpi.c      23 Nov 2019 00:02:15 -0000
@@ -2866,9 +2866,7 @@ acpi_thread(void *arg)
                s = spltty();
                while (sc->sc_threadwaiting) {
                        dnprintf(10, "acpi thread going to sleep...\n");
-                       rw_exit_write(&sc->sc_lck);
-                       tsleep(sc, PWAIT, "acpi0", 0);
-                       rw_enter_write(&sc->sc_lck);
+                       rwsleep_nsec(sc, &sc->sc_lck, PWAIT, "acpi0", INFSLP);
                }
                sc->sc_threadwaiting = 1;
                splx(s);
Index: acpiec.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpiec.c,v
retrieving revision 1.60
diff -u -p -r1.60 acpiec.c
--- acpiec.c    2 Jul 2019 21:17:24 -0000       1.60
+++ acpiec.c    23 Nov 2019 00:02:16 -0000
@@ -107,8 +107,10 @@ acpiec_wait(struct acpiec_softc *sc, uin
                        sc->sc_gotsci = 1;
                if (cold || (stat & EC_STAT_BURST))
                        delay(1);
-               else
-                       tsleep(&acpiecnowait, PWAIT, "acpiec", 1);
+               else {
+                       tsleep_nsec(&acpiecnowait, PWAIT, "acpiec",
+                           USEC_TO_NSEC(1));
+               }
        }
 
        dnprintf(40, "%s: EC wait_ns, stat: %b\n", DEVNAME(sc), (int)stat,
Index: dsdt.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
retrieving revision 1.249
diff -u -p -r1.249 dsdt.c
--- dsdt.c      16 Oct 2019 01:43:50 -0000      1.249
+++ dsdt.c      23 Nov 2019 00:02:16 -0000
@@ -465,15 +465,11 @@ void
 acpi_sleep(int ms, char *reason)
 {
        static int acpinowait;
-       int to = ms * hz / 1000;
 
        if (cold)
                delay(ms * 1000);
-       else {
-               if (to <= 0)
-                       to = 1;
-               tsleep(&acpinowait, PWAIT, reason, to);
-       }
+       else
+               tsleep_nsec(&acpinowait, PWAIT, reason, MSEC_TO_NSEC(ms));
 }
 
 void
Index: tipmic.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/tipmic.c,v
retrieving revision 1.4
diff -u -p -r1.4 tipmic.c
--- tipmic.c    4 Apr 2019 06:33:10 -0000       1.4
+++ tipmic.c    23 Nov 2019 00:02:16 -0000
@@ -333,7 +333,8 @@ tipmic_thermal_opreg_handler(void *cooki
        splx(s);
 
        while (sc->sc_stat_adc == 0) {
-               if (tsleep(&sc->sc_stat_adc, PRIBIO, "tipmic", hz)) {
+               if (tsleep_nsec(&sc->sc_stat_adc, PRIBIO, "tipmic",
+                   SEC_TO_NSEC(1))) {
                        printf("%s: ADC timeout\n", sc->sc_dev.dv_xname);
                        break;
                }

Reply via email to