From 88aa779c60f99f47f42ca4f6e85b2776e87b494c Mon Sep 17 00:00:00 2001 From: "haowei.cheng" Date: Sun, 3 Nov 2024 10:51:22 -0800 Subject: [PATCH] usb: mtu3: fix panic in mtu3_gadget_wakeup When the mtu3_gadget_wakeup function is used in an interrupt or a non-schedulable context,it may trigger a system scheduling exception due to the usleep_range_state function. We have replaced it with the non-schedulable delay function udelay, which can fix this issue. BUG: scheduling while atomic: swapper/3/0/0x00000500 Call trace: dump_backtrace+0x0/0x174 show_stack+0x18/0x24 dump_stack_lvl+0x64/0x80 dump_stack+0x18/0x34 __schedule_bug+0x50/0x6c __schedule+0x94/0x468 schedule+0xa0/0xe8 schedule_hrtimeout_range_clock+0xa8/0xe0 schedule_hrtimeout_range+0x14/0x20 usleep_range_state+0x5c/0x90 mtu3_gadget_wakeup+0x90/0xd4 usb_gadget_wakeup+0x1c/0x30 Signed-off-by: haowei.cheng --- drivers/usb/mtu3/mtu3_gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index 9977600616d7..2ab732701551 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -9,6 +9,7 @@ #include "mtu3.h" #include "mtu3_trace.h" +#include void mtu3_req_complete(struct mtu3_ep *mep, struct usb_request *req, int status) @@ -450,7 +451,7 @@ static int mtu3_gadget_wakeup(struct usb_gadget *gadget) } else { mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); spin_unlock_irqrestore(&mtu->lock, flags); - usleep_range(10000, 11000); + udelay(10000); spin_lock_irqsave(&mtu->lock, flags); mtu3_clrbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); } -- 2.17.1