Ticks to milliseconds.

Pretty sure all we need to do to convert the drain timeouts is
substitute 1000 for hz in each expression.

While we're here, I noticed that at halt time for input/output we
msleep to allow a drain and then immediately relinquish the mutex
after coming out of the sleep.  We could just opt not to reenter the
mutex with PNORELOCK, though that might make the code harder to read.
Maybe you have a preference?

Otherwise, ok?

Index: pci/esovar.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/esovar.h,v
retrieving revision 1.6
diff -u -p -r1.6 esovar.h
--- pci/esovar.h        21 Sep 2010 20:11:44 -0000      1.6
+++ pci/esovar.h        17 Jan 2020 04:29:28 -0000
@@ -129,7 +129,7 @@ struct eso_softc {
        void                    (*sc_rintr)(void *);
        void *                  sc_rarg;
 
-       /* Auto-initialize DMA transfer block drain timeouts, in ticks */
+       /* Auto-initialize DMA transfer block drain timeouts, in milliseconds */
        int                     sc_pdrain;
        int                     sc_rdrain;
 
Index: pci/eso.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/eso.c,v
retrieving revision 1.45
diff -u -p -r1.45 eso.c
--- pci/eso.c   14 Dec 2019 12:49:50 -0000      1.45
+++ pci/eso.c   17 Jan 2020 04:29:28 -0000
@@ -760,8 +760,8 @@ eso_halt_output(void *hdl)
            ESO_IO_A2DMAM_DMAENB);
 
        sc->sc_pintr = NULL;
-       error = msleep(&sc->sc_pintr, &audio_lock, PWAIT, "esoho", 
sc->sc_pdrain);
-       mtx_leave(&audio_lock);
+       error = msleep_nsec(&sc->sc_pintr, &audio_lock, PWAIT | PNORELOCK,
+           "esoho", MSEC_TO_NSEC(sc->sc_pdrain));
        
        /* Shut down DMA completely. */
        eso_write_mixreg(sc, ESO_MIXREG_A2C1, 0);
@@ -787,8 +787,8 @@ eso_halt_input(void *hdl)
            DMA37MD_WRITE | DMA37MD_DEMAND);
 
        sc->sc_rintr = NULL;
-       error = msleep(&sc->sc_rintr, &audio_lock, PWAIT, "esohi", 
sc->sc_rdrain);
-       mtx_leave(&audio_lock);
+       error = msleep_nsec(&sc->sc_rintr, &audio_lock, PWAIT | PNORELOCK,
+           "esohi", MSEC_TO_NSEC(sc->sc_rdrain));
 
        /* Shut down DMA completely. */
        eso_write_ctlreg(sc, ESO_CTLREG_A1C2,
@@ -1605,8 +1605,8 @@ eso_trigger_output(void *hdl, void *star
        sc->sc_pintr = intr;
        sc->sc_parg = arg;
 
-       /* Compute drain timeout. */
-       sc->sc_pdrain = hz * (blksize * 3 / 2) / 
+       /* Compute drain timeout in milliseconds. */
+       sc->sc_pdrain = 1000 * (blksize * 3 / 2) / 
            (param->sample_rate * param->channels * param->bps);
 
        /* DMA transfer count (in `words'!) reload using 2's complement. */
@@ -1688,8 +1688,8 @@ eso_trigger_input(void *hdl, void *start
        sc->sc_rintr = intr;
        sc->sc_rarg = arg;
 
-       /* Compute drain timeout. */
-       sc->sc_rdrain = hz * (blksize * 3 / 2) / 
+       /* Compute drain timeout in milliseconds. */
+       sc->sc_rdrain = 1000 * (blksize * 3 / 2) / 
            (param->sample_rate * param->channels * param->bps);
 
        /* Set up ADC DMA converter parameters. */

Reply via email to