linux/drivers/usb/gadget/udc
Iago Abal 1d23d16a88 usb: gadget: pch_udc: reorder spin_[un]lock to avoid deadlock
The above commit reordered spin_lock/unlock and now `&dev->lock' is acquired
(rather than released) before calling `dev->driver->disconnect',
`dev->driver->setup', `dev->driver->suspend', `usb_gadget_giveback_request', and
`usb_gadget_udc_reset'.

But this *may* not be the right way to fix the problem pointed by d3cb25a121.

Note that the other usb/gadget/udc drivers do release the lock before calling
these functions. There are also inconsistencies within pch_udc.c, where
`dev->driver->disconnect' is called while holding `&dev->lock' in lines 613 and
1184, but not in line 2739.

Finally, commit d3cb25a121 may have introduced several potential deadlocks.

For instance, EBA (https://github.com/models-team/eba) reports:

    Double lock in drivers/usb/gadget/udc/pch_udc.c
    first at 2791: spin_lock(& dev->lock); [pch_udc_isr]
    second at 2694: spin_lock(& dev->lock); [pch_udc_svc_cfg_interrupt]
        after calling from 2793: pch_udc_dev_isr(dev, dev_intr);
        after calling from 2724: pch_udc_svc_cfg_interrupt(dev);

Similarly, other potential deadlocks are 2791 -> 2793 -> 2721 -> 2657; and
2791 -> 2793 -> 2711 -> 2573 -> 1499 -> 1480.

Fixes: d3cb25a121 ("usb: gadget: udc: fix spin_lock in pch_udc")
Signed-off-by: Iago Abal <mail@iagoabal.eu>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2016-06-21 13:18:23 +03:00
..
bdc usb: gadget: bdc: fix spelling mistake: "allocted" -> "allocated" 2016-06-21 11:05:00 +03:00
Kconfig usb: gadget: net2280: add USB2380 support 2016-06-20 12:30:03 +03:00
Makefile usb: gadget: add tracepoints to the gadget API 2016-06-21 10:38:41 +03:00
amd5536udc.c usb: gadget: fix unused-but-set-variale warnings 2016-06-21 11:04:09 +03:00
amd5536udc.h usb: gadget: amd5536udc: remove unnecessary conditions 2015-10-01 12:40:20 -05:00
at91_udc.c usb: gadget: udc: at91: use PTR_ERR_OR_ZERO() 2016-04-14 09:24:38 +03:00
at91_udc.h usb: gadget: at91_udc: move at91_udc_data in at91_udc.h 2015-09-27 10:54:31 -05:00
atmel_usba_udc.c usb: gadget: udc: atmel: Also get regmap for at91sam9x5-pmc 2016-06-21 10:52:22 +03:00
atmel_usba_udc.h usb: gadget: atmel: access the PMC using regmap 2016-02-17 17:53:03 +01:00
bcm63xx_udc.c usb: gadget: bcm63xx_udc: use list_for_each_entry_safe 2015-12-22 12:08:40 -06:00
core.c usb: gadget: add tracepoints to the gadget API 2016-06-21 10:38:41 +03:00
dummy_hcd.c usb: gadget: fix unused-but-set-variale warnings 2016-06-21 11:04:09 +03:00
fotg210-udc.c usb: gadget: fotg210-udc: add ep capabilities support 2015-08-04 12:26:41 -05:00
fotg210.h
fsl_mxc_udc.c
fsl_qe_udc.c usb: gadget: fsl_qe_udc: fix IS_ERR_VALUE usage 2016-02-17 16:32:44 +02:00
fsl_qe_udc.h
fsl_udc_core.c usb: gadget: fsl_udc_core: add ep capabilities support 2015-08-04 12:26:43 -05:00
fsl_usb2_udc.h
fusb300_udc.c usb: gadget: fusb300_udc: add ep capabilities support 2015-08-04 12:26:44 -05:00
fusb300_udc.h usb: gadget: fusb300_udc.h: Fix typo in include guard 2014-09-03 09:15:57 -05:00
goku_udc.c PCI: Add PCI_CLASS_SERIAL_USB_DEVICE definition 2016-03-15 08:52:28 -05:00
goku_udc.h
gr_udc.c usb : replace dma_pool_alloc and memset with dma_pool_zalloc 2015-12-01 14:26:33 -08:00
gr_udc.h usb: gadget: gr_udc: Add bounce buffer to handle odd sized OUT requests 2014-09-16 10:01:45 -05:00
lpc32xx_udc.c usb: udc: lpc32xx: remove USB PLL and USB OTG clock management 2016-03-04 15:14:49 +02:00
m66592-udc.c usb: gadget: m66592: fix unused-but-set-variable warnings 2016-06-21 11:04:25 +03:00
m66592-udc.h
mv_u3d.h
mv_u3d_core.c usb: gadget: mv_u3d: fix unused-but-set-variable warnings 2016-06-21 11:04:38 +03:00
mv_udc.h
mv_udc_core.c usb: gadget: fix unused-but-set-variale warnings 2016-06-21 11:04:09 +03:00
net2272.c usb: gadget: fix unused-but-set-variale warnings 2016-06-21 11:04:09 +03:00
net2272.h usb: gadget: net2272: use common is_selfpowered 2015-01-29 10:35:27 -06:00
net2280.c usb: gadget: net2280: add USB2380 support 2016-06-20 12:30:03 +03:00
net2280.h usb: gadget: net2280: add USB2380 support 2016-06-20 12:30:03 +03:00
omap_udc.c usb: gadget: omap_udc: add ep capabilities support 2015-08-04 12:26:50 -05:00
omap_udc.h
pch_udc.c usb: gadget: pch_udc: reorder spin_[un]lock to avoid deadlock 2016-06-21 13:18:23 +03:00
pxa25x_udc.c usb: gadget: pxa25x_udc: document endianess better 2016-03-04 15:14:31 +02:00
pxa25x_udc.h usb: gadget: pxa25x_udc: use readl/writel for mmio 2016-03-04 15:14:29 +02:00
pxa27x_udc.c usb: pxa27x_udc: remove unused function argument 2016-06-21 10:46:33 +03:00
pxa27x_udc.h usb: gadget: pxa27x_udc: add ep capabilities support 2015-08-04 12:26:52 -05:00
r8a66597-udc.c usb: gadget: r8a66597: fix unused-but-set-variable warnings 2016-06-21 11:04:32 +03:00
r8a66597-udc.h
renesas_usb3.c usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller 2015-12-22 21:58:15 -06:00
s3c-hsudc.c usb: gadget: s3c-hsudc: remove redundant condition 2015-12-16 10:07:27 -06:00
s3c2410_udc.c usb: gadget: s3c2410_udc: add ep capabilities support 2015-08-04 12:26:54 -05:00
s3c2410_udc.h
trace.c usb: gadget: add tracepoints to the gadget API 2016-06-21 10:38:41 +03:00
trace.h usb: gadget: add tracepoints to the gadget API 2016-06-21 10:38:41 +03:00
udc-xilinx.c usb: gadget: fix unused-but-set-variale warnings 2016-06-21 11:04:09 +03:00