Skip to content

Commit

Permalink
usb: dwc3: gadget: avoid multiple calls to free_irq
Browse files Browse the repository at this point in the history
When we use /sys/class/udc/<udc>/soft_connect to do
a logical disconnection from the USB Host on RK3399
Excavator Board, it dumps the warning log:

Trying to free already-free IRQ 231
WARNING: CPU: 2 PID: 1308 at kernel/irq/manage.c:1628 __free_irq+0xa0/0x2e0
Modules linked in:
CPU: 2 PID: 1308 Comm: adbd Not tainted 4.19.80 #49
Hardware name: Rockchip RK3399 Excavator Board edp avb (Android) (DT)
pstate: 40400085 (nZcv daIf +PAN -UAO)
pc : __free_irq+0xa0/0x2e0
lr : __free_irq+0xa0/0x2e0
...
Call trace:
__free_irq+0xa0/0x2e0
free_irq+0x38/0x90
dwc3_gadget_stop+0x58/0x80
usb_gadget_remove_driver+0x50/0x70
usb_gadget_unregister_driver+0xc0/0x110
unregister_gadget+0x20/0x50
unregister_gadget_item+0x24/0x38
ffs_data_clear+0x120/0x130
ffs_data_reset+0x14/0x50
ffs_data_closed+0x88/0xd8
ffs_epfile_release+0x20/0x30

To solve the problem, don't call free_irq() in
dwc3_gadget_stop() if dwc->gadget_driver is NULL.

Change-Id: I9d5b5b354612c3ce3677b3d15cf6af1fcbf3f399
Signed-off-by: William Wu <[email protected]>
  • Loading branch information
wuliangfeng authored and rkhuangtao committed Apr 13, 2022
1 parent bd26413 commit 277709a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -2764,12 +2764,19 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
unsigned long flags;

spin_lock_irqsave(&dwc->lock, flags);
if (!dwc->gadget_driver) {
spin_unlock_irqrestore(&dwc->lock, flags);
dev_warn(dwc->dev, "%s is already stopped\n",
dwc->gadget->name);
goto out;
}
dwc->gadget_driver = NULL;
dwc->max_cfg_eps = 0;
spin_unlock_irqrestore(&dwc->lock, flags);

free_irq(dwc->irq_gadget, dwc->ev_buf);

out:
return 0;
}

Expand Down

0 comments on commit 277709a

Please sign in to comment.