Skip to content

Commit

Permalink
usb: dwc3: gadget: don't rely on jiffies while holding spinlock
Browse files Browse the repository at this point in the history
__dwc3_gadget_wakeup() is called while holding a spinlock, then depends on
jiffies in order to timeout while polling the USB core for a link state
update. In the case the wakeup failed, the timeout will never happen and
will also cause the cpu to stall until rcu_preempt kicks in.

This switches to a "decrement variable and wait" timeout scheme.

Signed-off-by: Nicolas Saenz Julienne <nicolassaenzj@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  • Loading branch information
Nicolas Saenz Julienne authored and Felipe Balbi committed Aug 22, 2016
1 parent f4693b0 commit d6011f6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ static int dwc3_gadget_get_frame(struct usb_gadget *g)

static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
{
unsigned long timeout;
int retries;

int ret;
u32 reg;
Expand Down Expand Up @@ -1484,9 +1484,9 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
}

/* poll until Link State changes to ON */
timeout = jiffies + msecs_to_jiffies(100);
retries = 20000;

while (!time_after(jiffies, timeout)) {
while (retries--) {
reg = dwc3_readl(dwc->regs, DWC3_DSTS);

/* in HS, means ON */
Expand Down

0 comments on commit d6011f6

Please sign in to comment.