Return-Path: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Date: Wed, 23 Apr 2014 17:27:02 +0200 From: =?UTF-8?Q?Andreas_Bie=C3=9Fmann?= To: =?UTF-8?Q?Andreas_Bie=C3=9Fmann?= , linux-kernel@vger.kernel.org, Marcel Holtmann , Gustavo Padovan , linux-bluetooth@vger.kernel.org, Felipe Balbi Subject: Re: [PATCH] =?UTF-8?Q?bluetooth=3Ahci=5Fldisc=3A=20add=20tasklet?= =?UTF-8?Q?=20for=20deferred=20TX=20handling?= In-Reply-To: <20140423151548.GA10025@t440s.P-661HNU-F1> References: <1397661950-30408-1-git-send-email-andreas@biessmann.de> <20140423151548.GA10025@t440s.P-661HNU-F1> Message-ID: List-ID: Hi Johan, Am 2014-04-23 17:15, schrieb Johan Hedberg: > On Wed, Apr 16, 2014, Andreas Bie=C3=9Fmann wrote: >> This patch fixes a recursive locking scenario when using BCSP=20 >> connection via >> 8250 driver. The 8250 driver may tty_wakeup() in interrupt context=20 >> which >> results in hci_uart_tx_wakeup(). This in turn will call uart_write()=20 >> in the >> very same context and therefore will spin_lock() the same lock within=20 >> the >> same context. >>=20 >> Here is the call stack: >>=20 >> ---8<--- >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> [ INFO: possible recursive locking detected ] >> 3.4.87-gf1a3cc3 #3 Tainted: G O >> --------------------------------------------- >> swapper/0 is trying to acquire lock: >> (&port_lock_key){-.-...}, at: [] uart_write+0x60/0xfc >>=20 >> but task is already holding lock: >> (&port_lock_key){-.-...}, at: []=20 >> serial8250_handle_irq+0x24/0x88 >>=20 >> other info that might help us debug this: >> Possible unsafe locking scenario: >>=20 >> CPU0 >> ---- >> lock(&port_lock_key); >> lock(&port_lock_key); >>=20 >> *** DEADLOCK *** >>=20 >> May be due to missing lock nesting notation >>=20 >> 2 locks held by swapper/0: >> #0: (&(&i->lock)->rlock){-.-...}, at: []=20 >> serial8250_interrupt+0x2c/0xc0 >> #1: (&port_lock_key){-.-...}, at: []=20 >> serial8250_handle_irq+0x24/0x88 >>=20 >> stack backtrace: >> [] (unwind_backtrace+0x0/0xec) from []=20 >> (dump_stack+0x20/0x24) >> [] (dump_stack+0x20/0x24) from []=20 >> (print_deadlock_bug+0xb4/0xe4) >> [] (print_deadlock_bug+0xb4/0xe4) from []=20 >> (check_deadlock.isra.20+0x160/0x18c) >> [] (check_deadlock.isra.20+0x160/0x18c) from []=20 >> (validate_chain.isra.24+0x4a4/0x4f0) >> [] (validate_chain.isra.24+0x4a4/0x4f0) from []=20 >> (__lock_acquire+0x670/0x740) >> [] (__lock_acquire+0x670/0x740) from []=20 >> (lock_acquire+0x138/0x15c) >> [] (lock_acquire+0x138/0x15c) from []=20 >> (_raw_spin_lock_irqsave+0x54/0x68) >> [] (_raw_spin_lock_irqsave+0x54/0x68) from []=20 >> (uart_write+0x60/0xfc) >> [] (uart_write+0x60/0xfc) from []=20 >> (hci_uart_tx_wakeup+0x9c/0x160 [hci_uart]) >> [] (hci_uart_tx_wakeup+0x9c/0x160 [hci_uart]) from=20 >> [] (hci_uart_tty_wakeup+0x58/0x5c [hci_uart]) >> [] (hci_uart_tty_wakeup+0x58/0x5c [hci_uart]) from=20 >> [] (tty_wakeup+0x48/0x68) >> [] (tty_wakeup+0x48/0x68) from []=20 >> (uart_write_wakeup+0x2c/0x30) >> [] (uart_write_wakeup+0x2c/0x30) from []=20 >> (serial8250_tx_chars+0xf0/0x140) >> [] (serial8250_tx_chars+0xf0/0x140) from []=20 >> (serial8250_handle_irq+0x6c/0x88) >> [] (serial8250_handle_irq+0x6c/0x88) from []=20 >> (serial8250_default_handle_irq+0x30/0x34) >> [] (serial8250_default_handle_irq+0x30/0x34) from=20 >> [] (serial8250_interrupt+0x44/0xc0) >> [] (serial8250_interrupt+0x44/0xc0) from []=20 >> (handle_irq_event_percpu+0xc4/0x2cc) >> [] (handle_irq_event_percpu+0xc4/0x2cc) from []=20 >> (handle_irq_event+0x4c/0x6c) >> [] (handle_irq_event+0x4c/0x6c) from []=20 >> (handle_edge_irq+0x114/0x14c) >> [] (handle_edge_irq+0x114/0x14c) from []=20 >> (generic_handle_irq+0x40/0x54) >> [] (generic_handle_irq+0x40/0x54) from []=20 >> (gpio_irq_handler+0x168/0x1ac) >> [] (gpio_irq_handler+0x168/0x1ac) from []=20 >> (generic_handle_irq+0x40/0x54) >> [] (generic_handle_irq+0x40/0x54) from []=20 >> (handle_IRQ+0x70/0x94) >> [] (handle_IRQ+0x70/0x94) from []=20 >> (omap3_intc_handle_irq+0x64/0x78) >> [] (omap3_intc_handle_irq+0x64/0x78) from []=20 >> (__irq_svc+0x44/0x78) >> --->8--- >>=20 >> Signed-off-by: Andreas Bie=C3=9Fmann >> Cc: Marcel Holtmann >> Cc: Gustavo Padovan >> Cc: Johan Hedberg >> Cc: linux-bluetooth@vger.kernel.org >> --- >>=20 >> It seems at least one other guy had the very same problem with another= =20 >> uart >> (mpc52xx): http://www.spinics.net/lists/linux-rt-users/msg09246.html >>=20 >> I wonder, if my approach is right. It is runtime tested with 3.4.87 on= =20 >> our >> board and work around the mentioned recursive locking. But I do not=20 >> know, if >> it should be fixed in another way. >> If it is right, I'd work some more on it to get the fix mainline. >>=20 >> drivers/bluetooth/hci_ldisc.c | 49=20 >> ++++++++++++++++++++++++++++++++++++----- >> drivers/bluetooth/hci_uart.h | 2 ++ >> 2 files changed, 45 insertions(+), 6 deletions(-) >=20 > This seems to be tackling the same problem as the following patch from > Felipe Balbi (of which a new revision was sent earlier today): >=20 > Subject: [PATCH 02/13] bluetooth: hci_ldisc: fix deadlock condition seems so, thanks for the pointer! Best regards Andreas Bie=C3=9Fmann