devicetree.vger.kernel.org archive mirror
 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; 30+ messages in thread
From: Felipe Balbi @ 2014-04-23 14:58 UTC (permalink / raw)
  To: Greg KH
  Cc: marcel-kz+m5ild9QBg9hUCZPvPmw, gustavo-THi1TnShQwVAfugRpC6u6w,
	johan.hedberg-Re5JQEeQqe8AvxtiuMwx3w, jslaby-AlSwsSmVLrQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A, Linux Kernel Mailing List,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Linux OMAP Mailing List,
	Tony Lindgren, Huang Shijie, Felipe Balbi

From: Huang Shijie <b32955-KZfg59tc24xl57MIdRCFDg@public.gmane.org>

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-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Signed-off-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-04-25 11:47 UTC | newest]

Thread overview: 30+ 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-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
     [not found]   ` <1398265117-11793-8-git-send-email-balbi-l0cyMroinI0@public.gmane.org>
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
     [not found]   ` <1398265117-11793-10-git-send-email-balbi-l0cyMroinI0@public.gmane.org>
2014-04-23 15:26     ` Felipe Balbi
2014-04-23 15:35     ` Nishanth Menon
     [not found]       ` <5357DDA8.4040206-l0cyMroinI0@public.gmane.org>
2014-04-23 22:43         ` NeilBrown
     [not found]           ` <20140424084305.20c7f301-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2014-04-23 23:01             ` Felipe Balbi
2014-04-24  0:13               ` NeilBrown
     [not found]                 ` <20140424101329.02e6a62f-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2014-04-24  1:21                   ` Felipe Balbi
     [not found]                     ` <20140424012100.GB13374-HgARHv6XitL9zxVx7UNMDg@public.gmane.org>
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
     [not found]                           ` <20140425193412.7d32e429-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
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
     [not found] ` <1398265117-11793-1-git-send-email-balbi-l0cyMroinI0@public.gmane.org>
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;
as well as URLs for NNTP newsgroup(s).