public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/13] tty_ldisc: add more limits to the @write_wakeup
@ 2014-04-23 14:58 Felipe Balbi
  2014-04-23 14:58 ` [PATCH 02/13] bluetooth: hci_ldisc: fix deadlock condition Felipe Balbi
                   ` (11 more replies)
  0 siblings, 12 replies; 33+ messages in thread
From: Felipe Balbi @ 2014-04-23 14:58 UTC (permalink / raw)
  To: Greg KH
  Cc: marcel, gustavo, johan.hedberg, jslaby, grant.likely,
	Linux Kernel Mailing List, linux-bluetooth, linux-serial,
	devicetree, Linux OMAP Mailing List, Tony Lindgren, Huang Shijie,
	Felipe Balbi

From: Huang Shijie <b32955@freescale.com>

In the uart_handle_cts_change(), uart_write_wakeup() is called after
we call @uart_port->ops->start_tx().

The Documentation/serial/driver tells us:
-----------------------------------------------
  start_tx(port)
	Start transmitting characters.

	Locking: port->lock taken.
	Interrupts: locally disabled.
-----------------------------------------------

So when the uart_write_wakeup() is called, the port->lock is taken by
the upper. See the following callstack:

	|_ uart_write_wakeup
	   |_ tty_wakeup
	      |_ ld->ops->write_wakeup

With the port->lock held, we call the @write_wakeup. Some implemetation of
the @write_wakeup does not notice that the port->lock is held, and it still
tries to send data with uart_write() which will try to grab the prot->lock.
A dead lock occurs, see the following log caught in the Bluetooth by uart:

--------------------------------------------------------------------
BUG: spinlock lockup suspected on CPU#0, swapper/0/0
 lock: 0xdc3f4410, .magic: dead4ead, .owner: swapper/0/0, .owner_cpu: 0
CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W    3.10.17-16839-ge4a1bef #1320
[<80014cbc>] (unwind_backtrace+0x0/0x138) from [<8001251c>] (show_stack+0x10/0x14)
[<8001251c>] (show_stack+0x10/0x14) from [<802816ac>] (do_raw_spin_lock+0x108/0x184)
[<802816ac>] (do_raw_spin_lock+0x108/0x184) from [<806a22b0>] (_raw_spin_lock_irqsave+0x54/0x60)
[<806a22b0>] (_raw_spin_lock_irqsave+0x54/0x60) from [<802f5754>] (uart_write+0x38/0xe0)
[<802f5754>] (uart_write+0x38/0xe0) from [<80455270>] (hci_uart_tx_wakeup+0xa4/0x168)
[<80455270>] (hci_uart_tx_wakeup+0xa4/0x168) from [<802dab18>] (tty_wakeup+0x50/0x5c)
[<802dab18>] (tty_wakeup+0x50/0x5c) from [<802f81a4>] (imx_rtsint+0x50/0x80)
[<802f81a4>] (imx_rtsint+0x50/0x80) from [<802f88f4>] (imx_int+0x158/0x17c)
[<802f88f4>] (imx_int+0x158/0x17c) from [<8007abe0>] (handle_irq_event_percpu+0x50/0x194)
[<8007abe0>] (handle_irq_event_percpu+0x50/0x194) from [<8007ad60>] (handle_irq_event+0x3c/0x5c)
--------------------------------------------------------------------

This patch adds more limits to the @write_wakeup, the one who wants to
implemet the @write_wakeup should follow the limits which avoid the deadlock.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 include/linux/tty_ldisc.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index add26da..00c9d68 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -92,7 +92,10 @@
  *	This function is called by the low-level tty driver to signal
  *	that line discpline should try to send more characters to the
  *	low-level driver for transmission.  If the line discpline does
- *	not have any more data to send, it can just return.
+ *	not have any more data to send, it can just return. If the line
+ *	discipline does have some data to send, please arise a tasklet
+ *	or workqueue to do the real data transfer. Do not send data in
+ *	this hook, it may leads to a deadlock.
  *
  * int (*hangup)(struct tty_struct *)
  *
-- 
1.9.2.459.g68773ac


^ permalink raw reply related	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2014-08-23  9:57 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-23 14:58 [PATCH 01/13] tty_ldisc: add more limits to the @write_wakeup Felipe Balbi
2014-04-23 14:58 ` [PATCH 02/13] bluetooth: hci_ldisc: fix deadlock condition Felipe Balbi
2014-04-24  9:01   ` Andreas Bießmann
2014-08-22 13:45   ` [PATCH] " Tim Niemeyer
2014-08-22 15:51     ` Greg KH
2014-08-23  9:50       ` Tim Niemeyer
2014-04-23 14:58 ` [PATCH 03/13] Revert "serial: omap: unlock the port lock" Felipe Balbi
2014-04-23 14:58 ` [PATCH 04/13] serial: fix UART_IIR_ID Felipe Balbi
2014-04-23 14:58 ` [PATCH 05/13] tty: serial: add missing braces Felipe Balbi
2014-04-23 14:58 ` [PATCH 06/13] tty: serial: omap: switch over to devm_request_gpio Felipe Balbi
2014-04-23 14:58 ` [PATCH 07/13] tty: serial: omap: cleanup variable declarations Felipe Balbi
2014-04-23 14:58 ` [PATCH 08/13] tty: serial: omap: switch over to platform_get_resource Felipe Balbi
2014-04-23 15:27   ` Fabio Estevam
2014-04-23 15:49     ` Felipe Balbi
2014-04-23 14:58 ` [PATCH 09/13] tty: serial: omap: switch over to devm_ioremap_resource Felipe Balbi
2014-04-23 14:58 ` [PATCH 10/13] tty: serial: omap: remove some dead code Felipe Balbi
2014-04-23 15:26   ` Felipe Balbi
2014-04-23 15:35   ` Nishanth Menon
2014-04-23 22:43     ` NeilBrown
2014-04-23 23:01       ` Felipe Balbi
2014-04-24  0:13         ` NeilBrown
2014-04-24  1:21           ` Felipe Balbi
2014-04-24  1:41             ` NeilBrown
2014-04-24  1:43               ` Felipe Balbi
2014-04-24  2:24                 ` NeilBrown
2014-04-24 14:19             ` One Thousand Gnomes
2014-04-25  9:34               ` NeilBrown
2014-04-25  9:53                 ` Yegor Yefremov
2014-04-25 11:40                   ` One Thousand Gnomes
2014-04-25 11:47                 ` One Thousand Gnomes
2014-04-23 14:58 ` [PATCH 11/13] tty: serial: omap: remove unneeded singlethread workqueue Felipe Balbi
2014-04-23 14:58 ` [PATCH 12/13] tty: serial: omap: fix Sparse warnings Felipe Balbi
2014-04-23 14:58 ` [PATCH 13/13] serial: 8250: add OMAP glue Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox