2013-05-13 08:23:03

by linux fddl

[permalink] [raw]
Subject: usb: why we need a msleep(5) in ehci_bus_suspend/resume

Hi,

From the ehci-hub.c, I find that ehci_bus_suspend/resume have some
code like this:

if (time_before(jiffies, ehci->netx_statechange))
msleep(5);
...
ehci->next_statechange = jiffies + msec_to_jiffies(10);

and

if (time_before(jiffies, ehci->netx_statechange))
msleep(5);
...
ehci->next_statechange = jiffies + msec_to_jiffies(5);

but I don't know why such a short sleep is needed, and why one is
[ehci->next_statechange = jiffies + msec_to_jiffies(10)] and the other is
[ehci->next_statechange = jiffies + msec_to_jiffies(5)],
I googled for a long time, but it seems that there is no explanation.

Anyone knows why and can give any explanation?

Thanks very much!

Best Regards!
ShiJinghui


2013-05-13 14:15:35

by Alan Stern

[permalink] [raw]
Subject: Re: usb: why we need a msleep(5) in ehci_bus_suspend/resume

On Mon, 13 May 2013, linux fddl wrote:

> Hi,
>
> From the ehci-hub.c, I find that ehci_bus_suspend/resume have some
> code like this:
>
> if (time_before(jiffies, ehci->netx_statechange))
> msleep(5);
> ...
> ehci->next_statechange = jiffies + msec_to_jiffies(10);
>
> and
>
> if (time_before(jiffies, ehci->netx_statechange))
> msleep(5);
> ...
> ehci->next_statechange = jiffies + msec_to_jiffies(5);
>
> but I don't know why such a short sleep is needed, and why one is
> [ehci->next_statechange = jiffies + msec_to_jiffies(10)] and the other is
> [ehci->next_statechange = jiffies + msec_to_jiffies(5)],
> I googled for a long time, but it seems that there is no explanation.
>
> Anyone knows why and can give any explanation?

At this point I don't think anybody knows. The person who originally
wrote that code died a few years ago.

Alan Stern