Skip to content

Commit 7441b27

Browse files
Thinh Nguyengregkh
authored andcommitted
usb: dwc3: gadget: Fix event pending check
The DWC3_EVENT_PENDING flag is used to protect against invalid call to top-half interrupt handler, which can occur when there's a delay in software detection of the interrupt line deassertion. However, the clearing of this flag was done prior to unmasking the interrupt line, creating opportunity where the top-half handler can come. This breaks the serialization and creates a race between the top-half and bottom-half handler, resulting in losing synchronization between the controller and the driver when processing events. To fix this, make sure the clearing of the DWC3_EVENT_PENDING is done at the end of the bottom-half handler. Fixes: d325a1d ("usb: dwc3: gadget: Prevent losing events in event cache") Cc: [email protected] Signed-off-by: Thinh Nguyen <[email protected]> Link: https://lore.kernel.org/r/8670aaf1cf52e7d1e6df2a827af2d77263b93b75.1656380429.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 03c765b commit 7441b27

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4249,7 +4249,6 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3_event_buffer *evt)
42494249
}
42504250

42514251
evt->count = 0;
4252-
evt->flags &= ~DWC3_EVENT_PENDING;
42534252
ret = IRQ_HANDLED;
42544253

42554254
/* Unmask interrupt */
@@ -4261,6 +4260,9 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3_event_buffer *evt)
42614260
dwc3_writel(dwc->regs, DWC3_DEV_IMOD(0), dwc->imod_interval);
42624261
}
42634262

4263+
/* Keep the clearing of DWC3_EVENT_PENDING at the end */
4264+
evt->flags &= ~DWC3_EVENT_PENDING;
4265+
42644266
return ret;
42654267
}
42664268

0 commit comments

Comments
 (0)