summaryrefslogtreecommitdiff
path: root/sys/dev/bluetooth
diff options
context:
space:
mode:
authornat <nat@NetBSD.org>2017-05-28 04:12:13 +0000
committernat <nat@NetBSD.org>2017-05-28 04:12:13 +0000
commita3c5b5d20d651cc441543483c4ff9a86e98eaffe (patch)
tree49e183d3f8a2a20197712432d6f92202972b7ba2 /sys/dev/bluetooth
parent5a6e220c28ed95c4235a73c87e698b478a91ca04 (diff)
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 (limited to 'sys/dev/bluetooth')
-rw-r--r--sys/dev/bluetooth/btsco.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/sys/dev/bluetooth/btsco.c b/sys/dev/bluetooth/btsco.c
index 6137818580e..b9a91fd229f 100644
--- a/sys/dev/bluetooth/btsco.c
+++ b/sys/dev/bluetooth/btsco.c
@@ -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 @@ struct btsco_softc {
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 @@ btsco_attach(device_t parent, device_t self, void *aux)
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 @@ btsco_detach(device_t self, int flags)
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 @@ btsco_detach(device_t self, int flags)
}
cv_destroy(&sc->sc_connect);
- mutex_destroy(&sc->sc_intr_lock);
+ mutex_destroy(&sc->sc_lock);
return 0;
}
@@ -462,7 +464,7 @@ btsco_sco_disconnected(void *arg, int err)
* 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 @@ btsco_sco_disconnected(void *arg, int err)
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 @@ btsco_sco_complete(void *arg, int count)
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 @@ btsco_sco_input(void *arg, struct mbuf *m)
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 @@ btsco_sco_input(void *arg, struct mbuf *m)
if (sc->sc_rx_want == 0)
(*sc->sc_rx_intr)(sc->sc_rx_intrarg);
}
- mutex_exit(&sc->sc_intr_lock);
}
@@ -777,7 +775,7 @@ btsco_round_blocksize(void *hdl, int bs, int mode,
/*
* 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 @@ btsco_get_locks(void *hdl, kmutex_t **intr, kmutex_t **thread)
{
struct btsco_softc *sc = hdl;
- *intr = &sc->sc_intr_lock;
- *thread = bt_lock;
+ *thread = &sc->sc_lock;
+ *intr = bt_lock;
}
/*
@@ -1141,12 +1139,12 @@ btsco_intr(void *arg)
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)