• Chen-Yu Tsai's avatar
    phy: sun4i-usb: Use spinlock to guard phyctl register access · 72c6187f
    Chen-Yu Tsai authored
    commit 919ab2524c52e5f801d8873f09145ce822cdd43a upstream.
    
    The musb driver calls into this phy driver to disable/enable squelch
    detection. This function was introduced in 24fe86a6 ("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: ba4bdc9e ("PHY: sunxi: Add driver for sunxi usb phy")
    Cc: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: 's avatarChen-Yu Tsai <wens@csie.org>
    Reviewed-by: 's avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: 's avatarKishon Vijay Abraham I <kishon@ti.com>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    72c6187f
Name
Last commit
Last update
..
tegra Loading commit data...
Kconfig Loading commit data...
Makefile Loading commit data...
phy-armada375-usb2.c Loading commit data...
phy-bcm-cygnus-pcie.c Loading commit data...
phy-bcm-kona-usb2.c Loading commit data...
phy-bcm-ns-usb2.c Loading commit data...
phy-bcm-ns2-pcie.c Loading commit data...
phy-berlin-sata.c Loading commit data...
phy-berlin-usb.c Loading commit data...
phy-brcm-sata.c Loading commit data...
phy-core.c Loading commit data...
phy-da8xx-usb.c Loading commit data...
phy-dm816x-usb.c Loading commit data...
phy-exynos-dp-video.c Loading commit data...
phy-exynos-mipi-video.c Loading commit data...
phy-exynos4210-usb2.c Loading commit data...
phy-exynos4x12-usb2.c Loading commit data...
phy-exynos5-usbdrd.c Loading commit data...
phy-exynos5250-sata.c Loading commit data...
phy-exynos5250-usb2.c Loading commit data...
phy-hi6220-usb.c Loading commit data...
phy-hix5hd2-sata.c Loading commit data...
phy-lpc18xx-usb-otg.c Loading commit data...
phy-miphy28lp.c Loading commit data...
phy-miphy365x.c Loading commit data...
phy-mt65xx-usb3.c Loading commit data...
phy-mvebu-sata.c Loading commit data...
phy-omap-control.c Loading commit data...
phy-omap-usb2.c Loading commit data...
phy-pistachio-usb.c Loading commit data...
phy-pxa-28nm-hsic.c Loading commit data...
phy-pxa-28nm-usb2.c Loading commit data...
phy-qcom-apq8064-sata.c Loading commit data...
phy-qcom-ipq806x-sata.c Loading commit data...
phy-qcom-ufs-i.h Loading commit data...
phy-qcom-ufs-qmp-14nm.c Loading commit data...
phy-qcom-ufs-qmp-14nm.h Loading commit data...
phy-qcom-ufs-qmp-20nm.c Loading commit data...
phy-qcom-ufs-qmp-20nm.h Loading commit data...
phy-qcom-ufs.c Loading commit data...
phy-rcar-gen2.c Loading commit data...
phy-rcar-gen3-usb2.c Loading commit data...
phy-rockchip-dp.c Loading commit data...
phy-rockchip-emmc.c Loading commit data...
phy-rockchip-usb.c Loading commit data...
phy-s5pv210-usb2.c Loading commit data...
phy-samsung-usb2.c Loading commit data...
phy-samsung-usb2.h Loading commit data...
phy-spear1310-miphy.c Loading commit data...
phy-spear1340-miphy.c Loading commit data...
phy-stih407-usb.c Loading commit data...
phy-stih41x-usb.c Loading commit data...
phy-sun4i-usb.c Loading commit data...
phy-sun9i-usb.c Loading commit data...
phy-ti-pipe3.c Loading commit data...
phy-tusb1210.c Loading commit data...
phy-twl4030-usb.c Loading commit data...
phy-xgene.c Loading commit data...
ulpi_phy.h Loading commit data...