UPSTREAM: usb: dwc3: gadget: Avoid duplicate requests to enable Run/Stop

Relocate the pullups_connected check until after it is ensured that there
are no runtime PM transitions.  If another context triggered the DWC3
core's runtime resume, it may have already enabled the Run/Stop.  Do not
re-run the entire pullup sequence again, as it may issue a core soft
reset while Run/Stop is already set.

This patch depends on
  commit 69e131d1ac4e ("usb: dwc3: gadget: Prevent repeat pullup()")

Fixes: 77adb8bdf4 ("usb: dwc3: gadget: Allow runtime suspend if UDC unbinded")
Cc: stable <stable@kernel.org>
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Link: https://lore.kernel.org/r/20220728020647.9377-1-quic_wcheng@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 245440430
Change-Id: I7785374fddef1f707b8f4757c46d642fa814d82f
(cherry picked from commit 040f2dbd2010c43f33ad27249e6dac48456f4d99)
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
This commit is contained in:
Wesley Cheng
2022-06-28 18:00:32 -07:00
committed by Todd Kjos
parent 7bdc155a70
commit 898941454f

View File

@@ -2471,10 +2471,6 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
int ret;
is_on = !!is_on;
if (dwc->pullups_connected == is_on)
return 0;
dwc->softconnect = is_on;
/*
@@ -2512,6 +2508,12 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
return 0;
}
/* Ensure that RPM resume has not already triggered run/stop set */
if (dwc->pullups_connected == is_on) {
pm_runtime_put(dwc->dev);
return 0;
}
/*
* Synchronize and disable any further event handling while controller
* is being enabled/disabled.