Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/isaki-audio2]: src/sys/dev/pci Don't release sc_lock on eso_halt_{input, ...



details:   https://anonhg.NetBSD.org/src/rev/e62b671d1e91
branches:  isaki-audio2
changeset: 450888:e62b671d1e91
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sun Apr 28 05:07:00 2019 +0000

description:
Don't release sc_lock on eso_halt_{input,output}.
halt_* is called with sc_lock && sc_intr_lock held.  This lock order
is first sc_lock and then sc_intr_lock.  So unlocking sc_lock with
sc_intr_lock held is wrong operation.  And cv_wait(sc_intr_lock) will
work even with sc_lock held.

diffstat:

 sys/dev/pci/eso.c |  16 ++--------------
 1 files changed, 2 insertions(+), 14 deletions(-)

diffs (46 lines):

diff -r 695d5113de2a -r e62b671d1e91 sys/dev/pci/eso.c
--- a/sys/dev/pci/eso.c Sun Apr 28 04:45:34 2019 +0000
+++ b/sys/dev/pci/eso.c Sun Apr 28 05:07:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eso.c,v 1.69.2.2 2019/04/28 04:45:34 isaki Exp $       */
+/*     $NetBSD: eso.c,v 1.69.2.3 2019/04/28 05:07:00 isaki Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: eso.c,v 1.69.2.2 2019/04/28 04:45:34 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: eso.c,v 1.69.2.3 2019/04/28 05:07:00 isaki Exp $");
 
 #include "mpu.h"
 
@@ -784,13 +784,7 @@
            ESO_IO_A2DMAM_DMAENB);
 
        sc->sc_pintr = NULL;
-       mutex_exit(&sc->sc_lock);
        error = cv_timedwait_sig(&sc->sc_pcv, &sc->sc_intr_lock, sc->sc_pdrain);
-       if (!mutex_tryenter(&sc->sc_lock)) {
-               mutex_spin_exit(&sc->sc_intr_lock);
-               mutex_enter(&sc->sc_lock);
-               mutex_spin_enter(&sc->sc_intr_lock);
-       }
 
        /* Shut down DMA completely. */
        eso_write_mixreg(sc, ESO_MIXREG_A2C1, 0);
@@ -816,13 +810,7 @@
            DMA37MD_WRITE | DMA37MD_DEMAND);
 
        sc->sc_rintr = NULL;
-       mutex_exit(&sc->sc_lock);
        error = cv_timedwait_sig(&sc->sc_rcv, &sc->sc_intr_lock, sc->sc_rdrain);
-       if (!mutex_tryenter(&sc->sc_lock)) {
-               mutex_spin_exit(&sc->sc_intr_lock);
-               mutex_enter(&sc->sc_lock);
-               mutex_spin_enter(&sc->sc_intr_lock);
-       }
 
        /* Shut down DMA completely. */
        eso_write_ctlreg(sc, ESO_CTLREG_A1C2,



Home | Main Index | Thread Index | Old Index