usb: dwc3: ep0: Fail enqueue() when racing with vbus_sess disconnect

When the setup packet comes right before the disconnect notification
there is a possible race between clearing the run stop bit and
enqueuing the setup packet. This results in controller halt failure.
Add a vbus_active check before enqueuing the packet to fix this issue.

Change-Id: I3921a1fa92a0f5c6892f1cc3ffe9dda6366b72b1
Signed-off-by: Elson Roy Serrao <eserrao@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
Elson Roy Serrao 2019-10-15 15:05:32 -07:00 • committed by Jack Pham
commit 904ab34b54

View file

@ -197,7 +197,8 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
int ret;
spin_lock_irqsave(&dwc->lock, flags);
if (!dep->endpoint.desc || !dwc->pullups_connected) {
if (!dep->endpoint.desc || !dwc->softconnect ||
!dwc->vbus_active) {
dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
dep->name);
ret = -ESHUTDOWN;