Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/bluetooth bt_lock is now used as the audio interrupt...



details:   https://anonhg.NetBSD.org/src/rev/49f888918a92
branches:  trunk
changeset: 824213:49f888918a92
user:      nat <nat%NetBSD.org@localhost>
date:      Sun May 28 04:12:13 2017 +0000

description:
bt_lock is now used as the audio interrupt lock.  This is more appropriate
as the interrupt lock deals with the hardware.

btsco audio works again with the new audio changes.

diffstat:

 sys/dev/bluetooth/btsco.c |  28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)

diffs (140 lines):

diff -r 48267b20ab97 -r 49f888918a92 sys/dev/bluetooth/btsco.c
--- a/sys/dev/bluetooth/btsco.c Sun May 28 00:40:20 2017 +0000
+++ b/sys/dev/bluetooth/btsco.c Sun May 28 04:12:13 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: btsco.c,v 1.34 2015/07/10 22:03:12 nat Exp $   */
+/*     $NetBSD: btsco.c,v 1.35 2017/05/28 04:12:13 nat Exp $   */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.34 2015/07/10 22:03:12 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.35 2017/05/28 04:12:13 nat Exp $");
 
 #include <sys/param.h>
 #include <sys/audioio.h>
@@ -97,7 +97,7 @@
        device_t                 sc_audio;      /* MI audio device */
        void                    *sc_intr;       /* interrupt cookie */
        kcondvar_t               sc_connect;    /* connect wait */
-       kmutex_t                 sc_intr_lock;  /* for audio */
+       kmutex_t                 sc_lock;       /* for audio */
 
        /* Bluetooth */
        bdaddr_t                 sc_laddr;      /* local address */
@@ -295,7 +295,7 @@
        sc->sc_state = BTSCO_CLOSED;
        sc->sc_name = device_xname(self);
        cv_init(&sc->sc_connect, "connect");
-       mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_NONE);
+       mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
 
        /*
         * copy in our configuration info
@@ -382,10 +382,12 @@
                sc->sc_intr = NULL;
        }
 
+       mutex_enter(bt_lock);
        if (sc->sc_rx_mbuf != NULL) {
                m_freem(sc->sc_rx_mbuf);
                sc->sc_rx_mbuf = NULL;
        }
+       mutex_exit(bt_lock);
 
        if (sc->sc_tx_refcnt > 0) {
                aprint_error_dev(self, "tx_refcnt=%d!\n", sc->sc_tx_refcnt);
@@ -395,7 +397,7 @@
        }
 
        cv_destroy(&sc->sc_connect);
-       mutex_destroy(&sc->sc_intr_lock);
+       mutex_destroy(&sc->sc_lock);
 
        return 0;
 }
@@ -462,7 +464,7 @@
                 * has completed so that when it tries to send more, we
                 * can indicate an error.
                 */
-               mutex_enter(&sc->sc_intr_lock);
+               mutex_enter(bt_lock);
                if (sc->sc_tx_pending > 0) {
                        sc->sc_tx_pending = 0;
                        (*sc->sc_tx_intr)(sc->sc_tx_intrarg);
@@ -471,7 +473,7 @@
                        sc->sc_rx_want = 0;
                        (*sc->sc_rx_intr)(sc->sc_rx_intrarg);
                }
-               mutex_exit(&sc->sc_intr_lock);
+               mutex_exit(bt_lock);
                break;
 
        default:
@@ -505,13 +507,11 @@
 
        DPRINTFN(10, "%s count %d\n", sc->sc_name, count);
 
-       mutex_enter(&sc->sc_intr_lock);
        if (sc->sc_tx_pending > 0) {
                sc->sc_tx_pending -= count;
                if (sc->sc_tx_pending == 0)
                        (*sc->sc_tx_intr)(sc->sc_tx_intrarg);
        }
-       mutex_exit(&sc->sc_intr_lock);
 }
 
 static void
@@ -530,7 +530,6 @@
 
        DPRINTFN(10, "%s len=%d\n", sc->sc_name, m->m_pkthdr.len);
 
-       mutex_enter(&sc->sc_intr_lock);
        if (sc->sc_rx_want == 0) {
                m_freem(m);
        } else {
@@ -556,7 +555,6 @@
                if (sc->sc_rx_want == 0)
                        (*sc->sc_rx_intr)(sc->sc_rx_intrarg);
        }
-       mutex_exit(&sc->sc_intr_lock);
 }
 
 
@@ -777,7 +775,7 @@
 /*
  * Start Output
  *
- * We dont want to be calling the network stack with sc_intr_lock held
+ * We dont want to be calling the network stack with bt_lock held
  * so make a note of what is to be sent, and schedule an interrupt to
  * bundle it up and queue it.
  */
@@ -1079,8 +1077,8 @@
 {
        struct btsco_softc *sc = hdl;
 
-       *intr = &sc->sc_intr_lock;
-       *thread = bt_lock;
+       *thread = &sc->sc_lock;
+       *intr = bt_lock;
 }
 
 /*
@@ -1141,12 +1139,12 @@
        if (sc->sc_sco == NULL)
                return;         /* connection is lost */
 
+       mutex_enter(bt_lock);
        block = sc->sc_tx_block;
        size = sc->sc_tx_size;
        sc->sc_tx_block = NULL;
        sc->sc_tx_size = 0;
 
-       mutex_enter(bt_lock);
        while (size > 0) {
                MGETHDR(m, M_DONTWAIT, MT_DATA);
                if (m == NULL)



Home | Main Index | Thread Index | Old Index