From 0b937c189f0218bcbee4ceeec090d43237e93b13 Mon Sep 17 00:00:00 2001 From: Jack Pham Date: Thu, 13 Feb 2014 18:33:50 -0800 Subject: [PATCH] usb: dwc3: gadget: Ensure core is not suspended when handling interrupt Since dwc3_thread_interrupt is part of interrupt handling that can be scheduled to run in thread context, it leaves open a window in which the controller might be placed into low power mode. In this state, clocks would be disabled, and by the time dwc3_thread_interrupt runs, would result in an unclocked I/O access when it tries to write to the GEVNTCOUNT register. Prevent this by calling pm_runtime_get() in dwc3_interrupt() in order to force the device to remain in active state, which increments the parent device's child count so that it too is prevented from entering suspend. Call pm_runtime_put() at the end of dwc3_thread_interrupt() after finishing processing the event buffers. CRs-fixed: 609233 CRs-fixed: 622850 Change-Id: Ia21c9ac74d74833a889081f41c93acec2a7ae011 Signed-off-by: Jack Pham --- drivers/usb/dwc3/gadget.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 688cf1c60e72..95d9de5c2832 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2755,6 +2755,7 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc) spin_unlock_irqrestore(&dwc->lock, flags); + pm_runtime_put(dwc->dev); return ret; } @@ -2796,6 +2797,9 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc) ret = status; } + if (ret == IRQ_WAKE_THREAD) + pm_runtime_get(dwc->dev); + return ret; }