From 388805c56bd95f925a9fbd750e9f196fc5a6bcb3 Mon Sep 17 00:00:00 2001 From: William Wu Date: Tue, 8 Feb 2022 16:08:50 +0800 Subject: [PATCH] phy: rockchip: inno-usb2: correctly handle otg sm work RK3588 has two OTG controllers, OTG0 is configured as OTG mode, and OTG1 is configured as host mode. The OTG1 doesn't init the otg sm work, so it can only handle the otg sm work if the func of the work is initialized. This patch can fix the warning if the logic is power off during deep sleep on RK3588 EVB2. WARNING: CPU: 0 PID: 145 at kernel/workqueue.c:3057 __flush_work+0x26c/0x28c Modules linked in: CPU: 0 PID: 145 Comm: irq/106-rockchi Not tainted 5.10.66 #720 Hardware name: Rockchip RK3588 EVB2 LP4 V10 Board (DT) pstate: 60c00009 (nZCv daif +PAN +UAO -TCO BTYPE=--) pc : __flush_work+0x26c/0x28c lr : __cancel_work_timer+0x11c/0x1c0 ...... Call trace: __flush_work+0x26c/0x28c __cancel_work_timer+0x11c/0x1c0 cancel_delayed_work_sync+0x18/0x2c rockchip_usb2phy_bvalid_irq+0xf4/0x144 rockchip_usb2phy_irq+0x368/0x384 irq_thread_fn+0x34/0x88 irq_thread+0x1a4/0x248 kthread+0x13c/0x344 ret_from_fork+0x10/0x30 Signed-off-by: William Wu Change-Id: I42b5f6d22df3f7f94d54f05083694fb49e382620 --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 7a1868542d71..374c51b2c110 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -871,7 +871,7 @@ 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 && - rport->bvalid_irq > 0) + rport->otg_sm_work.work.func) flush_delayed_work(&rport->otg_sm_work); return 0; @@ -1617,8 +1617,10 @@ static irqreturn_t rockchip_usb2phy_bvalid_irq(int irq, void *data) if (rport->bypass_uart_en) rockchip_usb_bypass_uart(rport, false); - cancel_delayed_work_sync(&rport->otg_sm_work); - rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work); + if (rport->otg_sm_work.work.func) { + cancel_delayed_work_sync(&rport->otg_sm_work); + rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work); + } return IRQ_HANDLED; }