Re: Virtual hub, resets etc...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2019-07-04 at 21:37 -0400, Alan Stern wrote:
> > 
> > Talking of which... do we need this ?
> > 
> > --- a/drivers/usb/gadget/composite.c
> > +++ b/drivers/usb/gadget/composite.c
> > @@ -1976,6 +1976,7 @@ void composite_disconnect(struct usb_gadget *gadget)
> >         * disconnect callbacks?
> >         */
> >        spin_lock_irqsave(&cdev->lock, flags);
> > +     cdev->suspended = 0;
> >        if (cdev->config)
> >                reset_config(cdev);
> >        if (cdev->driver->disconnect)
> > 
> > Otherwise with my vhub or with dummy_hcd, a suspend followed by a reset
> > will keep that stale suspended flag to 1 (which has no effect at the moment
> > but still...)
> > 
> > If yes, I'll submit a patch accordingly...
> 
> According to the USB spec, a host is not supposed to reset a suspended 
> port (it's supposed to resume the port and then do the reset).  But of 
> course this can happen anyway, so we should handle it properly.

Right. I do see the resume coming in, but I don't forward it to the
gadget because here's what happens in that order:

 1- Host gets shutdown (or cable disconnected)

 2- Upstream bus suspend: I call ->suspend on the gadgets on all
enabled ports that don't have USB_PORT_STAT_SUSPEND already set. I
don't change the port status, I don't set USB_PORT_STAT_SUSPEND

 3- Machine gets turned back on (or cable reconnected)
 
 4- Upstream bus resume: I call ->resume on the gadgets on all
enabled ports that don't have USB_PORT_STAT_SUSPEND set.

 5- Upstream bus reset: I call ->suspend on all enabled ports after
clearing their status (I preserve only USB_PORT_STAT_SUSPEND and
USB_PORT_STAT_POWER which is always set for me). Note: I currently do
this even if the port had USB_PORT_STAT_SUSPEND set, so such as port
will get a double suspend ... maybe I shouldn't.

 6- Hosts sets port reset: I reset the gadget since it's already
bound/enabled. It's still "suspended".

So we do have a legitimate case of "reset while suspended".

I'll tidy up the patch and submit it.

Cheers,
Ben.





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux