Skip to content

Commit 7368760

Browse files
Peter Chengregkh
authored andcommitted
usb: chipidea: udc: fix sleeping function called from invalid context
The code calls pm_runtime_get_sync with irq disabled, it causes below warning: BUG: sleeping function called from invalid context at wer/runtime.c:1075 in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: er/u8:1 CPU: 1 PID: 37 Comm: kworker/u8:1 Not tainted 20200304-00181-gbebfd2a5be98 #1588 Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) Workqueue: ci_otg ci_otg_work [<c010e8bd>] (unwind_backtrace) from [<c010a315>] 1/0x14) [<c010a315>] (show_stack) from [<c0987d29>] 5/0x94) [<c0987d29>] (dump_stack) from [<c013e77f>] +0xeb/0x118) [<c013e77f>] (___might_sleep) from [<c052fa1d>] esume+0x75/0x78) [<c052fa1d>] (__pm_runtime_resume) from [<c0627a33>] 0x23/0x74) [<c0627a33>] (ci_udc_pullup) from [<c062fb93>] nect+0x2b/0xcc) [<c062fb93>] (usb_gadget_connect) from [<c062769d>] _connect+0x59/0x104) [<c062769d>] (ci_hdrc_gadget_connect) from [<c062778b>] ssion+0x43/0x48) [<c062778b>] (ci_udc_vbus_session) from [<c062f997>] s_connect+0x17/0x9c) [<c062f997>] (usb_gadget_vbus_connect) from [<c062634d>] bd/0x128) [<c062634d>] (ci_otg_work) from [<c0134719>] rk+0x149/0x404) [<c0134719>] (process_one_work) from [<c0134acb>] 0xf7/0x3bc) [<c0134acb>] (worker_thread) from [<c0139433>] x118) [<c0139433>] (kthread) from [<c01010bd>] (ret_from_fork+0x11/0x34) Tested-by: Dmitry Osipenko <[email protected]> Cc: <[email protected]> #v5.5 Fixes: 72dc8df ("usb: chipidea: udc: protect usb interrupt enable") Reported-by: Dmitry Osipenko <[email protected]> Signed-off-by: Peter Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b433e34 commit 7368760

File tree

1 file changed

+4
-3
lines changed
  • drivers/usb/chipidea

1 file changed

+4
-3
lines changed

drivers/usb/chipidea/udc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,18 +1530,19 @@ static const struct usb_ep_ops usb_ep_ops = {
15301530
static void ci_hdrc_gadget_connect(struct usb_gadget *_gadget, int is_active)
15311531
{
15321532
struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
1533-
unsigned long flags;
15341533

15351534
if (is_active) {
15361535
pm_runtime_get_sync(&_gadget->dev);
15371536
hw_device_reset(ci);
1538-
spin_lock_irqsave(&ci->lock, flags);
1537+
spin_lock_irq(&ci->lock);
15391538
if (ci->driver) {
15401539
hw_device_state(ci, ci->ep0out->qh.dma);
15411540
usb_gadget_set_state(_gadget, USB_STATE_POWERED);
1541+
spin_unlock_irq(&ci->lock);
15421542
usb_udc_vbus_handler(_gadget, true);
1543+
} else {
1544+
spin_unlock_irq(&ci->lock);
15431545
}
1544-
spin_unlock_irqrestore(&ci->lock, flags);
15451546
} else {
15461547
usb_udc_vbus_handler(_gadget, false);
15471548
if (ci->driver)

0 commit comments

Comments
 (0)