From 73462a3bf92128bdb31152904696b1007909ceb1 Mon Sep 17 00:00:00 2001 From: William Wu Date: Fri, 6 Jul 2018 19:56:09 +0800 Subject: [PATCH] phy: rockchip: rockchip-inno-usb2: fix lock warning If the usb otg work as host mode or work as peripheral mode with vbus always on, the otg_sm_work won't be initialized, so flush the otg_sm_work in rockchip_usb2phy_exit() will casuse the following lock warning: [] dump_backtrace+0x0/0x1ec [] show_stack+0x14/0x1c [] dump_stack+0xb8/0xf4 [] __lock_acquire+0x670/0x1984 [] lock_acquire+0x1a4/0x264 [] del_timer_sync+0x48/0xb8 [] flush_delayed_work+0x20/0x50 [] rockchip_usb2phy_exit+0x48/0x58 [] phy_exit+0x64/0xb4 [] dwc3_core_exit+0x44/0x98 [] dwc3_remove+0x90/0xe4 [] platform_drv_remove+0x28/0x48 [] __device_release_driver+0xac/0x114 [] device_release_driver+0x28/0x3c [] bus_remove_device+0x110/0x128 [] device_del+0x160/0x1f8 [] platform_device_del+0x20/0x88 [] platform_device_unregister+0x14/0x28 [] of_platform_device_destroy+0x54/0xa8 [] device_for_each_child+0x68/0x98 [] of_platform_depopulate+0x30/0x4c [] dwc3_rockchip_probe+0x4d4/0x574 [] platform_drv_probe+0x58/0xa4 [] driver_probe_device+0x118/0x2b0 [] __driver_attach+0x6c/0x98 [] bus_for_each_dev+0x80/0xb0 [] driver_attach+0x20/0x28 [] bus_add_driver+0xe8/0x1e4 [] driver_register+0x94/0xe0 [] __platform_driver_register+0x48/0x50 [] dwc3_rockchip_driver_init+0x18/0x20 [] do_one_initcall+0x17c/0x198 [] kernel_init_freeable+0x1f8/0x2b0 [] kernel_init+0x10/0xf8 [] ret_from_fork+0x10/0x50 This patch only allows to flush the otg_sm_work when the usb bvalid irq is valid. Fixes: f6fac8b68ad8 ("phy: rockchip: rockchip-inno-usb2: flush otg work when exit") Change-Id: I4dbe34fa9a330f22abb24ccd625da33425a9f753 Signed-off-by: William Wu --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 95942d4c3ace..022d17874b04 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -743,7 +743,8 @@ static int rockchip_usb2phy_exit(struct phy *phy) if (rport->port_id == USB2PHY_PORT_HOST) cancel_delayed_work_sync(&rport->sm_work); - else if (rport->port_id == USB2PHY_PORT_OTG) + else if (rport->port_id == USB2PHY_PORT_OTG && + rport->bvalid_irq > 0) flush_delayed_work(&rport->otg_sm_work); return 0;