linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 0001-usb-mtu3-fix-panic-in-mtu3_gadget_wakeup.patch
@ 2024-11-04 17:54 Haowei Cheng(Harvey)
  2024-11-05  8:41 ` 0001-usb-mtu3-fix-panic-in-mtu3_gadget_wakeup.patch Greg Kroah-Hartman
  0 siblings, 1 reply; 7+ messages in thread
From: Haowei Cheng(Harvey) @ 2024-11-04 17:54 UTC (permalink / raw)
  To: chunfeng.yun@mediatek.com
  Cc: Greg Kroah-Hartman, linux-usb@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org


[-- Attachment #1.1: Type: text/plain, Size: 2 bytes --]



[-- Attachment #1.2: Type: text/html, Size: 397 bytes --]

[-- Attachment #2: 0001-usb-mtu3-fix-panic-in-mtu3_gadget_wakeup.patch --]
[-- Type: application/octet-stream, Size: 1769 bytes --]

From 88aa779c60f99f47f42ca4f6e85b2776e87b494c Mon Sep 17 00:00:00 2001
From: "haowei.cheng" <harvey.cheng@fibocom.com>
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 <harvey.cheng@fibocom.com>
---
 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 <linux/delay.h>
 
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-11-07  8:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-04 17:54 0001-usb-mtu3-fix-panic-in-mtu3_gadget_wakeup.patch Haowei Cheng(Harvey)
2024-11-05  8:41 ` 0001-usb-mtu3-fix-panic-in-mtu3_gadget_wakeup.patch Greg Kroah-Hartman
2024-11-06 19:39   ` 回复: 0001-usb-mtu3-fix-panic-in-mtu3_gadget_wakeup.patch Haowei Cheng(Harvey)
2024-11-07  5:13     ` Greg Kroah-Hartman
2024-11-07  5:14     ` Greg Kroah-Hartman
2024-11-07  7:47       ` 回复: " Haowei Cheng(Harvey)
2024-11-07  8:14         ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).