linux/drivers/phy
Chen-Yu Tsai 17fe3f2631 phy: sun4i-usb: Use spinlock to guard phyctl register access
commit 919ab2524c upstream.

The musb driver calls into this phy driver to disable/enable squelch
detection. This function was introduced in 24fe86a617 ("phy: sun4i-usb:
Add a sunxi specific function for setting squelch-detect"). This
function in turn calls sun4i_usb_phy_write, which uses a mutex to
guard the common access register. Unfortunately musb does this
in atomic context, which results in the following warning with lock
debugging enabled:

BUG: sleeping function called from invalid context at kernel/locking/mutex.c:97
in_atomic(): 1, irqs_disabled(): 128, pid: 96, name: kworker/0:2
CPU: 0 PID: 96 Comm: kworker/0:2 Not tainted 4.8.0-rc4-00181-gd502f8ad1c3e #13
Hardware name: Allwinner sun8i Family
Workqueue: events musb_deassert_reset
[<c010bc01>] (unwind_backtrace) from [<c0109237>] (show_stack+0xb/0xc)
[<c0109237>] (show_stack) from [<c02a669b>] (dump_stack+0x67/0x74)
[<c02a669b>] (dump_stack) from [<c05d68c9>] (mutex_lock+0x15/0x2c)
[<c05d68c9>] (mutex_lock) from [<c02c3589>] (sun4i_usb_phy_write+0x39/0xec)
[<c02c3589>] (sun4i_usb_phy_write) from [<c03e6327>] (musb_port_reset+0xfb/0x184)
[<c03e6327>] (musb_port_reset) from [<c03e4917>] (musb_deassert_reset+0x1f/0x2c)
[<c03e4917>] (musb_deassert_reset) from [<c012ecb5>] (process_one_work+0x129/0x2b8)
[<c012ecb5>] (process_one_work) from [<c012f5e3>] (worker_thread+0xf3/0x424)
[<c012f5e3>] (worker_thread) from [<c0132dbd>] (kthread+0xa1/0xb8)
[<c0132dbd>] (kthread) from [<c0105f31>] (ret_from_fork+0x11/0x20)

Since the register access is mmio, we can use a spinlock to guard this
specific access, rather than the mutex that guards the entire phy.

Fixes: ba4bdc9e1d ("PHY: sunxi: Add driver for sunxi usb phy")
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2017-02-23 03:53:59 +00:00
..
Kconfig USB fixes for 3.16-rc5 2014-07-12 14:13:10 -07:00
Makefile phy: Add new Exynos5 USB 3.0 PHY driver 2014-05-13 18:07:08 +05:30
phy-bcm-kona-usb2.c usb: phy: bcm-kona-usb2: Use PTR_ERR_OR_ZERO 2014-03-02 00:26:26 +05:30
phy-core.c phy: Find the right match in devm_phy_destroy() 2015-03-30 11:11:30 +01:00
phy-exynos-dp-video.c phy: let phy_provider_register be the last step in registering PHY 2014-02-18 12:13:16 -08:00
phy-exynos-mipi-video.c phy: exynos-mipi-video: fix check on array index 2014-05-12 19:02:02 +05:30
phy-exynos4x12-usb2.c phy: Add new Exynos USB 2.0 PHY driver 2014-03-08 12:39:44 +05:30
phy-exynos5-usbdrd.c phy: exynos5-usbdrd: Add facility for VBUS supply 2014-05-13 18:07:08 +05:30
phy-exynos4210-usb2.c phy: Add new Exynos USB 2.0 PHY driver 2014-03-08 12:39:44 +05:30
phy-exynos5250-sata.c PHY: Exynos: fix SATA phy license typo 2014-05-08 19:24:35 +05:30
phy-exynos5250-usb2.c phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver 2014-03-08 12:39:44 +05:30
phy-mvebu-sata.c phy: let phy_provider_register be the last step in registering PHY 2014-02-18 12:13:16 -08:00
phy-omap-control.c phy: omap-control: update dra7 and am437 usb2 bindings 2014-03-09 12:45:09 +05:30
phy-omap-usb2.c phy: omap-usb2: Enable runtime PM of omap-usb2 phy properly 2014-11-14 15:19:59 +00:00
phy-samsung-usb2.c drivers: phy: phy-samsung-usb2.c: Add missing MODULE_DEVICE_TABLE 2014-07-11 18:23:49 -07:00
phy-samsung-usb2.h phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver 2014-03-08 12:39:44 +05:30
phy-sun4i-usb.c phy: sun4i-usb: Use spinlock to guard phyctl register access 2017-02-23 03:53:59 +00:00
phy-ti-pipe3.c phy: ti-pipe3: Fix suspend/resume and module reload 2014-03-09 12:45:11 +05:30
phy-twl4030-usb.c phy: twl4030-usb: Relase usb phy on unload 2016-02-25 10:34:54 +00:00
phy-xgene.c PHY: add APM X-Gene SoC 15Gbps Multi-purpose PHY driver 2014-03-09 12:45:13 +05:30