linux-stable/drivers/usb
Thomas Gleixner a5c6234e10 completion: Use simple wait queues
completion uses a wait_queue_head_t to enqueue waiters.

wait_queue_head_t contains a spinlock_t to protect the list of waiters
which excludes it from being used in truly atomic context on a PREEMPT_RT
enabled kernel.

The spinlock in the wait queue head cannot be replaced by a raw_spinlock
because:

  - wait queues can have custom wakeup callbacks, which acquire other
    spinlock_t locks and have potentially long execution times

  - wake_up() walks an unbounded number of list entries during the wake up
    and may wake an unbounded number of waiters.

For simplicity and performance reasons complete() should be usable on
PREEMPT_RT enabled kernels.

completions do not use custom wakeup callbacks and are usually single
waiter, except for a few corner cases.

Replace the wait queue in the completion with a simple wait queue (swait),
which uses a raw_spinlock_t for protecting the waiter list and therefore is
safe to use inside truly atomic regions on PREEMPT_RT.

There is no semantical or functional change:

  - completions use the exclusive wait mode which is what swait provides

  - complete() wakes one exclusive waiter

  - complete_all() wakes all waiters while holding the lock which protects
    the wait queue against newly incoming waiters. The conversion to swait
    preserves this behaviour.

complete_all() might cause unbound latencies with a large number of waiters
being woken at once, but most complete_all() usage sites are either in
testing or initialization code or have only a really small number of
concurrent waiters which for now does not cause a latency problem. Keep it
simple for now.

The fixup of the warning check in the USB gadget driver is just a straight
forward conversion of the lockless waiter check from one waitqueue type to
the other.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Davidlohr Bueso <dbueso@suse.de>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lkml.kernel.org/r/20200321113242.317954042@linutronix.de
2020-03-21 16:00:24 +01:00
..
atm USB driver fixes for 5.5-rc2 2019-12-14 12:40:39 -08:00
c67x00
cdns3 usb: cdns3: fix spelling mistake and rework grammar in text 2020-01-24 09:41:27 +01:00
chipidea usb: chipidea: add inline for ci_hdrc_host_driver_init if host is not defined 2020-01-22 07:54:27 +01:00
class compat_ioctl: remove most of fs/compat_ioctl.c 2019-12-01 13:46:15 -08:00
common usb: common: usb-conn-gpio: Don't log an error on probe deferral 2019-12-10 11:41:20 +01:00
core USB: Fix novation SourceControl XL after suspend 2020-02-12 09:54:07 -08:00
dwc2 usb: dwc2: Fix SET/CLEAR_FEATURE and GET_STATUS flows 2020-02-11 08:45:45 +02:00
dwc3 usb: dwc3: debug: fix string position formatting mixup with ret and len 2020-02-11 08:45:45 +02:00
early remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
gadget completion: Use simple wait queues 2020-03-21 16:00:24 +01:00
host xhci: Fix memory leak when caching protocol extended capability PSI tables - take 2 2020-02-12 09:51:09 -08:00
image
isp1760 remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
misc USB: misc: iowarrior: add support for the 100 device 2020-02-17 10:44:43 +01:00
mon usb: mon: Fix a deadlock in usbmon between mmap and read 2019-12-10 11:41:20 +01:00
mtu3
musb usb: musb: fix spelling mistake: "periperal" -> "peripheral" 2020-01-21 19:58:45 +01:00
phy usb: phy: tegra: Add clarifying comments about the shared registers 2020-02-10 11:12:15 -08:00
renesas_usbhs phy: for 5.6 2020-01-17 07:52:26 +01:00
roles remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
serial USB: serial: ch341: fix receiver regression 2020-02-10 10:10:35 +01:00
storage usb: uas: fix a plug & unplug racing 2020-02-10 11:08:30 -08:00
typec USB/Thunderbolt/PHY driver updates for 5.6-rc1 2020-01-29 10:09:44 -08:00
usbip usbip: Fix error path of vhci_recv_ret_submit() 2019-12-17 16:36:33 +01:00
Kconfig
Makefile
usb-skeleton.c