Re: [PATCH v2] usb: core: reduce power-on-good delay time of root hub

Alan Stern
2021-11-01T14:06:17Z

On Sat, Oct 30, 2021 at 12:49:37PM +0800, Walt Jr. Brake wrote:
> This patch make USB 3.1 device cannot be detected, and I report the bug [1]
> to archlinux three month ago. Yesterday I try to fix it myself, and after I
> revert this patch, compile the kernel and test, it works.
>
> [1] https://bugs.archlinux.org/task/71660?project=1&pagenum=2
>
>
> diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
> index 22ea1f4f2d66..73f4482d833a 100644
> --- a/drivers/usb/core/hub.h
> +++ b/drivers/usb/core/hub.h
> @@ -148,10 +148,8 @@ static inline unsigned hub_power_on_good_delay(struct
> usb_hub *hub)
>  {
>         unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
>
> -       if (!hub->hdev->parent) /* root hub */
> -               return delay;
> -       else /* Wait at least 100 msec for power to become stable */
> -               return max(delay, 100U);
> +       /* Wait at least 100 msec for power to become stable */
> +       return max(delay, 100U);
>  }

Mathias:

It looks like the bPwrOn2PwrGood value in xhci-hcd's hub descriptor is
too small for some USB 3.1 devices.

Can you look into this?

Alan Stern

> On 10/4/2021 09:20, Chunfeng Yun wrote:
> > Return the exactly delay time given by root hub descriptor,
> > this helps to reduce resume time etc.
> >
> > Due to the root hub descriptor is usually provided by the host
> > controller driver, if there is compatibility for a root hub,
> > we can fix it easily without affect other root hub
> >
> > Acked-by: Alan Stern<stern@rowland.harvard.edu>
> > Signed-off-by: Chunfeng Yun<chunfeng.yun@mediatek.com>
> > ---
> > v2: remove RFC tag, and add acked-by Alan
> > ---
> > drivers/usb/core/hub.h | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
> > index 73f4482d833a..22ea1f4f2d66 100644
> > --- a/drivers/usb/core/hub.h
> > +++ b/drivers/usb/core/hub.h
> > @@ -148,8 +148,10 @@ static inline unsigned hub_power_on_good_delay(struct usb_hub *hub)
> > {
> > unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
> > - /* Wait at least 100 msec for power to become stable */
> > - return max(delay, 100U);
> > + if (!hub->hdev->parent) /* root hub */
> > + return delay;
> > + else /* Wait at least 100 msec for power to become stable */
> > + return max(delay, 100U);
> > }
> > static inline int hub_port_debounce_be_connected(struct usb_hub *hub,