2019-05-27 08:55:05 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-10-28 19:20:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2005-10-28 19:20:45 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-05-09 09:15:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-12 11:37:04 -03:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2024-08-09 13:42:25 +08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-20 13:42:36 +02:00
|
|
|
|
2010-07-19 12:34:07 +05:30
|
|
|
|
2015-04-04 16:13:02 -07:00
|
|
|
|
2015-04-04 16:13:03 -07:00
|
|
|
|
2015-08-10 14:24:17 -07:00
|
|
|
|
2016-02-22 10:48:03 +01:00
|
|
|
|
2016-09-19 11:32:35 +02:00
|
|
|
|
2016-09-19 16:29:27 +02:00
|
|
|
|
2024-08-09 13:42:25 +08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-07-12 11:37:04 -03:00
|
|
|
|
2012-02-24 17:12:24 +01:00
|
|
|
|
2012-07-16 16:12:11 +03:00
|
|
|
|
2014-07-11 07:12:58 +02:00
|
|
|
|
2015-04-04 16:13:01 -07:00
|
|
|
|
2010-07-12 11:37:04 -03:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2017-03-28 17:59:35 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-04 22:27:34 -07:00
|
|
|
|
2015-10-20 21:30:45 +02:00
|
|
|
|
2015-05-28 11:25:03 +02:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-05 22:52:17 -07:00
|
|
|
|
2015-05-28 11:25:03 +02:00
|
|
|
|
2015-04-04 20:59:41 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-28 19:20:45 +02:00
|
|
|
|
2017-03-28 17:59:35 +02:00
|
|
|
|
2005-10-28 19:20:45 +02:00
|
|
|
|
|
|
|
|
|
2010-07-12 11:37:04 -03:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2012-07-16 16:12:11 +03:00
|
|
|
|
2014-04-23 09:58:26 -05:00
|
|
|
|
2012-07-16 16:12:11 +03:00
|
|
|
|
2015-04-04 22:11:43 -07:00
|
|
|
|
Bluetooth: hci_ldisc: Allow sleeping while proto locks are held.
Commit dec2c92880cc5435381d50e3045ef018a762a917 ("Bluetooth: hci_ldisc:
Use rwlocking to avoid closing proto races") introduced locks in
hci_ldisc that are held while calling the proto functions. These locks
are rwlock's, and hence do not allow sleeping while they are held.
However, the proto functions that hci_bcm registers use mutexes and
hence need to be able to sleep.
In more detail: hci_uart_tty_receive() and hci_uart_dequeue() both
acquire the rwlock, after which they call proto->recv() and
proto->dequeue(), respectively. In the case of hci_bcm these point to
bcm_recv() and bcm_dequeue(). The latter both acquire the
bcm_device_lock, which is a mutex, so doing so results in a call to
might_sleep(). But since we're holding a rwlock in hci_ldisc, that
results in the following BUG (this for the dequeue case - a similar
one for the receive case is omitted for brevity):
BUG: sleeping function called from invalid context at kernel/locking/mutex.c
in_atomic(): 1, irqs_disabled(): 0, pid: 7303, name: kworker/7:3
INFO: lockdep is turned off.
CPU: 7 PID: 7303 Comm: kworker/7:3 Tainted: G W OE 4.13.2+ #17
Hardware name: Apple Inc. MacBookPro13,3/Mac-A5C67F76ED83108C, BIOS MBP133.8
Workqueue: events hci_uart_write_work [hci_uart]
Call Trace:
dump_stack+0x8e/0xd6
___might_sleep+0x164/0x250
__might_sleep+0x4a/0x80
__mutex_lock+0x59/0xa00
? lock_acquire+0xa3/0x1f0
? lock_acquire+0xa3/0x1f0
? hci_uart_write_work+0xd3/0x160 [hci_uart]
mutex_lock_nested+0x1b/0x20
? mutex_lock_nested+0x1b/0x20
bcm_dequeue+0x21/0xc0 [hci_uart]
hci_uart_write_work+0xe6/0x160 [hci_uart]
process_one_work+0x253/0x6a0
worker_thread+0x4d/0x3b0
kthread+0x133/0x150
We can't replace the mutex in hci_bcm, because there are other calls
there that might sleep. Therefore this replaces the rwlock's in
hci_ldisc with rw_semaphore's (which allow sleeping). This is a safer
approach anyway as it reduces the restrictions on the proto callbacks.
Also, because acquiring write-lock is very rare compared to acquiring
the read-lock, the percpu variant of rw_semaphore is used.
Lastly, because hci_uart_tx_wakeup() may be called from an IRQ context,
we can't block (sleep) while trying acquire the read lock there, so we
use the trylock variant.
Signed-off-by: Ronald Tschalär <ronald@innovation.ch>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-10-25 22:14:53 -07:00
|
|
|
|
2005-10-28 19:20:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-17 17:30:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-28 17:59:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2010-07-12 11:37:04 -03:00
|
|
|
|
2021-06-29 21:59:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-12 18:59:46 +03:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2005-10-28 19:20:45 +02:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-04-04 22:11:43 -07:00
|
|
|
|
|
|
|
|
|
2024-02-24 00:37:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-08 17:37:41 +01:00
|
|
|
|
2017-03-28 17:59:35 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2019-06-14 09:23:49 +02:00
|
|
|
|
2012-07-16 16:12:11 +03:00
|
|
|
|
2018-05-27 21:04:53 +02:00
|
|
|
|
2015-05-28 11:25:03 +02:00
|
|
|
|
2019-07-30 11:33:45 +02:00
|
|
|
|
2015-06-17 17:30:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-04-05 23:44:59 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-15 13:02:19 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-02 08:43:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-23 11:47:19 -07:00
|
|
|
|
2015-04-05 23:44:59 -07:00
|
|
|
|
|
|
|
|
|
2005-10-28 19:20:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-20 13:42:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-19 12:34:07 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-16 16:12:02 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-04 16:13:02 -07:00
|
|
|
|
2015-07-01 12:20:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-05 22:52:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-08-10 14:24:17 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-22 10:48:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-09-19 16:29:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-09 13:42:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|