* [PATCH] bluetooth: hci_ldisc: fix deadlock condition
[not found] <1398265117-11793-2-git-send-email-balbi@ti.com>
@ 2014-08-22 13:45 ` Tim Niemeyer
2014-08-22 15:51 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Tim Niemeyer @ 2014-08-22 13:45 UTC (permalink / raw)
To: Felipe Balbi, Greg KH, stable
Cc: Linux Kernel Mailing List, Marcel Holtmann, Gustavo Padovan,
Johan Hedberg, jslaby, grant.likely, linux-bluetooth, andreas
This Patch was applied to 3.10 and 3.2. It's probably missed on 3.4.
---------------------
From: Felipe Balbi <balbi@ti.com>
LDISCs shouldn't call tty->ops->write() from within
->write_wakeup().
->write_wakeup() is called with port lock taken and
IRQs disabled, tty->ops->write() will try to acquire
the same port lock and we will deadlock.
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Reported-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Tested-by: Andreas Bießmann <andreas@biessmann.de>
[tim.niemeyer@corscience.de: rebased on 3.4.103]
Signed-off-by: Tim Niemeyer <tim.niemeyer@corscience.de>
---
drivers/bluetooth/hci_ldisc.c | 25 ++++++++++++++++++++-----
drivers/bluetooth/hci_uart.h | 2 ++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 98a8c05..d4550f9 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -118,10 +118,6 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
int hci_uart_tx_wakeup(struct hci_uart *hu)
{
- struct tty_struct *tty = hu->tty;
- struct hci_dev *hdev = hu->hdev;
- struct sk_buff *skb;
-
if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) {
set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
return 0;
@@ -129,6 +125,22 @@ int hci_uart_tx_wakeup(struct hci_uart *hu)
BT_DBG("");
+ schedule_work(&hu->write_work);
+
+ return 0;
+}
+
+static void hci_uart_write_work(struct work_struct *work)
+{
+ struct hci_uart *hu = container_of(work, struct hci_uart, write_work);
+ struct tty_struct *tty = hu->tty;
+ struct hci_dev *hdev = hu->hdev;
+ struct sk_buff *skb;
+
+ /* REVISIT: should we cope with bad skbs or ->write() returning
+ * and error value ?
+ */
+
restart:
clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
@@ -153,7 +165,6 @@ restart:
goto restart;
clear_bit(HCI_UART_SENDING, &hu->tx_state);
- return 0;
}
/* ------- Interface to HCI layer ------ */
@@ -264,6 +275,8 @@ static int hci_uart_tty_open(struct tty_struct *tty)
hu->tty = tty;
tty->receive_room = 65536;
+ INIT_WORK(&hu->write_work, hci_uart_write_work);
+
spin_lock_init(&hu->rx_lock);
/* Flush any pending characters in the driver and line discipline. */
@@ -298,6 +311,8 @@ static void hci_uart_tty_close(struct tty_struct *tty)
if (hdev)
hci_uart_close(hdev);
+ cancel_work_sync(&hu->write_work);
+
if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) {
if (hdev) {
hci_unregister_dev(hdev);
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 6cf6ab22..af93d83 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -66,6 +66,8 @@ struct hci_uart {
unsigned long flags;
unsigned long hdev_flags;
+ struct work_struct write_work;
+
struct hci_uart_proto *proto;
void *priv;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bluetooth: hci_ldisc: fix deadlock condition
2014-08-22 13:45 ` [PATCH] bluetooth: hci_ldisc: fix deadlock condition Tim Niemeyer
@ 2014-08-22 15:51 ` Greg KH
2014-08-23 9:50 ` Tim Niemeyer
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2014-08-22 15:51 UTC (permalink / raw)
To: Tim Niemeyer
Cc: Felipe Balbi, stable, Linux Kernel Mailing List, Marcel Holtmann,
Gustavo Padovan, Johan Hedberg, jslaby, grant.likely,
linux-bluetooth, andreas
On Fri, Aug 22, 2014 at 03:45:07PM +0200, Tim Niemeyer wrote:
> This Patch was applied to 3.10 and 3.2. It's probably missed on 3.4.
Does it apply there?
What is the git id of the commit?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bluetooth: hci_ldisc: fix deadlock condition
2014-08-22 15:51 ` Greg KH
@ 2014-08-23 9:50 ` Tim Niemeyer
0 siblings, 0 replies; 3+ messages in thread
From: Tim Niemeyer @ 2014-08-23 9:50 UTC (permalink / raw)
To: Greg KH
Cc: Tim Niemeyer, Felipe Balbi, stable, Linux Kernel Mailing List,
Marcel Holtmann, Gustavo Padovan, Johan Hedberg, jslaby,
grant.likely, linux-bluetooth, andreas
[-- Attachment #1: Type: text/plain, Size: 715 bytes --]
Hi
Am Freitag, den 22.08.2014, 10:51 -0500 schrieb Greg KH:
> On Fri, Aug 22, 2014 at 03:45:07PM +0200, Tim Niemeyer wrote:
> > This Patch was applied to 3.10 and 3.2. It's probably missed on 3.4.
>
> Does it apply there?
The original patch applies not cleanly on 3.4. The init_work is not
available there.
I backported it and it's the same result as the backport from Andreas.
He tested the patch on 3.4.87. The attached patch of my last mail
applies.
> What is the git id of the commit?
Sorry, missed it:
commit da64c27d3c93ee9f89956b9de86c4127eb244494 upstream
commit a22d29e6e5757b1daed7d0b409a815eb33f66e4e stable-3.10
commit 87520218746b8d973670e37237666f174590898c stable-3.2
Tim
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-08-23 9:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1398265117-11793-2-git-send-email-balbi@ti.com>
2014-08-22 13:45 ` [PATCH] bluetooth: hci_ldisc: fix deadlock condition Tim Niemeyer
2014-08-22 15:51 ` Greg KH
2014-08-23 9:50 ` Tim Niemeyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox