First, the tsleep(9) calls.  These are easy.  If cold != 0 we
delay(9), so just do the equivalent thing with tsleep_nsec(9).

Next, the msleep(9).  If I understand correctly, in hvn_alloc_cmd()
we're waiting to pull something off a freelist.  The freelist,
sc->sc_cntl_fq, is protexted by the mutex sc->sc_cntl_fqlck.  The
mutex ensures we can't miss the wakeup(9) from hvn_free_cmd(), so
I think we can just INFSLP and await the wakeup(9).

ok?

Index: pv/if_hvn.c
===================================================================
RCS file: /cvs/src/sys/dev/pv/if_hvn.c,v
retrieving revision 1.40
diff -u -p -r1.40 if_hvn.c
--- pv/if_hvn.c 17 May 2018 12:32:33 -0000      1.40
+++ pv/if_hvn.c 15 Jan 2020 06:15:33 -0000
@@ -1049,7 +1049,8 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
                        if (cold)
                                delay(1000);
                        else
-                               tsleep(cmd, PRIBIO, "nvsout", 1);
+                               tsleep_nsec(cmd, PRIBIO, "nvsout",
+                                   USEC_TO_NSEC(1000));
                } else if (rv) {
                        DPRINTF("%s: NVSP operation %u send error %d\n",
                            sc->sc_dev.dv_xname, hdr->nvs_type, rv);
@@ -1070,7 +1071,8 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
                if (cold)
                        delay(1000);
                else
-                       tsleep(sc, PRIBIO | PCATCH, "nvscmd", 1);
+                       tsleep_nsec(sc, PRIBIO | PCATCH, "nvscmd",
+                           USEC_TO_NSEC(1000));
                s = splnet();
                hvn_nvs_intr(sc);
                splx(s);
@@ -1123,8 +1125,8 @@ hvn_alloc_cmd(struct hvn_softc *sc)
 
        mtx_enter(&sc->sc_cntl_fqlck);
        while ((rc = TAILQ_FIRST(&sc->sc_cntl_fq)) == NULL)
-               msleep(&sc->sc_cntl_fq, &sc->sc_cntl_fqlck,
-                   PRIBIO, "nvsalloc", 1);
+               msleep_nsec(&sc->sc_cntl_fq, &sc->sc_cntl_fqlck,
+                   PRIBIO, "nvsalloc", INFSLP);
        TAILQ_REMOVE(&sc->sc_cntl_fq, rc, rc_entry);
        mtx_leave(&sc->sc_cntl_fqlck);
        return (rc);
@@ -1367,7 +1369,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
                        if (cold)
                                delay(100);
                        else
-                               tsleep(rc, PRIBIO, "rndisout", 1);
+                               tsleep_nsec(rc, PRIBIO, "rndisout",
+                                   USEC_TO_NSEC(100));
                } else if (rv) {
                        DPRINTF("%s: RNDIS operation %u send error %d\n",
                            sc->sc_dev.dv_xname, hdr->rm_type, rv);
@@ -1389,7 +1392,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
                if (cold)
                        delay(1000);
                else
-                       tsleep(rc, PRIBIO | PCATCH, "rndiscmd", 1);
+                       tsleep_nsec(rc, PRIBIO | PCATCH, "rndiscmd",
+                           USEC_TO_NSEC(1000));
                s = splnet();
                hvn_nvs_intr(sc);
                splx(s);

Reply via email to