Skip to content

Commit

Permalink
usb: gadget: aspeed: Don't reject requests on suspended devices
Browse files Browse the repository at this point in the history
A disconnect may just suspend the hub in absence of a physical
disconnect detection. If we start rejecting requests, the mass
storage function gets into a spin trying to requeue the same
request for ever and hangs.

Signed-off-by: Benjamin Herrenschmidt <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
  • Loading branch information
ozbenh authored and Felipe Balbi committed Aug 12, 2019
1 parent 7e420ce commit ef9d346
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions drivers/usb/gadget/udc/aspeed-vhub/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,19 @@ int ast_vhub_std_dev_request(struct ast_vhub_ep *ep,
u16 wValue, wIndex;

/* No driver, we shouldn't be enabled ... */
if (!d->driver || !d->enabled || d->suspended) {
if (!d->driver || !d->enabled) {
EPDBG(ep,
"Device is wrong state driver=%p enabled=%d"
" suspended=%d\n",
d->driver, d->enabled, d->suspended);
"Device is wrong state driver=%p enabled=%d\n",
d->driver, d->enabled);
return std_req_stall;
}

/*
* Note: we used to reject/stall requests while suspended,
* we don't do that anymore as we seem to have cases of
* mass storage getting very upset.
*/

/* First packet, grab speed */
if (d->gadget.speed == USB_SPEED_UNKNOWN) {
d->gadget.speed = ep->vhub->speed;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/udc/aspeed-vhub/ep0.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static int ast_vhub_ep0_queue(struct usb_ep* u_ep, struct usb_request *u_req,
return -EINVAL;

/* Disabled device */
if (ep->dev && (!ep->dev->enabled || ep->dev->suspended))
if (ep->dev && !ep->dev->enabled)
return -ESHUTDOWN;

/* Data, no buffer and not internal ? */
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/udc/aspeed-vhub/epn.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static int ast_vhub_epn_queue(struct usb_ep* u_ep, struct usb_request *u_req,

/* Endpoint enabled ? */
if (!ep->epn.enabled || !u_ep->desc || !ep->dev || !ep->d_idx ||
!ep->dev->enabled || ep->dev->suspended) {
!ep->dev->enabled) {
EPDBG(ep, "Enqueuing request on wrong or disabled EP\n");
return -ESHUTDOWN;
}
Expand Down

0 comments on commit ef9d346

Please sign in to comment.