usb: dwc3: gadget: Synchronize IRQ between soft connect/disconnect
authorWesley Cheng <quic_wcheng@quicinc.com>
Wed, 17 Aug 2022 18:23:53 +0000 (11:23 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Aug 2022 07:07:53 +0000 (09:07 +0200)
Ensure that there are no pending events being handled in between soft
connect/disconnect transitions.  As we are keeping interrupts enabled,
and EP0 events are still being serviced, this avoids any stale events from
being serviced.

Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Link: https://lore.kernel.org/r/20220817182359.13550-4-quic_wcheng@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/gadget.c

index 004b8c4746a7603537851e21e74e48d5c0a97066..311348aea58e33d7ae07643b58b7c7eaa4c89d2d 100644 (file)
@@ -2569,6 +2569,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
                return 0;
        }
 
+       synchronize_irq(dwc->irq_gadget);
+
        if (!is_on) {
                ret = dwc3_gadget_soft_disconnect(dwc);
        } else {