Re: [RFC 04/13] USB: Calculate USB 3.0 exit latencies for LPM.

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

 



On Thu, May 17, 2012 at 03:04:10PM -0400, Alan Stern wrote:
> On Wed, 16 May 2012, Sarah Sharp wrote:
> 
> > There are several different exit latencies associated with coming out of
> > the U1 or U2 lower power link state.
> > 
> > Device Exit Latency (DEL) is the maximum time it takes for the USB
> > device to bring its upstream link into U0.  That can be found in the
> > SuperSpeed Extended Capabilities BOS descriptor for the device.  The
> > time it takes for a particular link in the tree to exit to U0 is the
> > maximum of either the parent hub's U1/U2 DEL, or the child's U1/U2 DEL.
> ...
> 
> > --- a/include/linux/usb.h
> > +++ b/include/linux/usb.h
> > @@ -378,6 +378,39 @@ enum usb_device_removable {
> >  	USB_DEVICE_FIXED,
> >  };
> >  
> > +/*
> > + * USB 3.0 Link Power Management (LPM) parameters.
> > + *
> > + * PEL and SEL are USB 3.0 Link PM latencies for device-initiated LPM exit.
> > + * MEL is the USB 3.0 Link PM latency for host-initiated LPM exit.
> > + * All three are stored in nanoseconds.
> > + */
> > +struct usb3_lpm_parameters {
> > +	/*
> > +	 * Maximum exit latency (MEL) for the host to send a packet to the
> > +	 * device (either a Ping for isoc endpoints, or a data packet for
> > +	 * interrupt endpoints), the hubs to decode the packet, and for all hubs
> > +	 * in the path to transition the links to U0.
> > +	 */
> > +	unsigned long long mel;
> 
> Do these have to be long long?  Are any of the values ever going to be
> bigger than 1 second?

Hmmm, let me work out the worst-case scenario.

[Short answer: no, these don't need to be long longs.  I will fix this.]


Max U2 device exit latency can be up to 2047 us, or 2047000 ns.

We could have a device behind up to 5 hubs.  The PEL for the hub
attached to the roothub is

PEL = max( max(U2del(hub1), U2del(host)) * 1000, port2portEL * 1000 + PEL(host))

The PEL of the host is zero.  Let's assume the U2del of hub1 is the max
(2047 us), and the U1del is the minimum non-zero value (1 us).
Port2PortEL for U2 is (1 + host(U2del) - host(U1del)).  Assume the host
has the same U2 and U2 DELs as hub1.  Then the equation becomes:

PEL = max( max(2047, 2047) * 1000, (1 + 2047 - 1) * 1000 + 0) = 2,047,000 ns

The SEL for hub1 will be

SEL = PEL + 2.1 us (for first-tier external hub) + 250 ns * (num external hubs - 1) +
      250 ns * (num external hubs)

Since we have no external hubs between the roothub and hub1, that will
be just 2,047,000 ns.

Extrapolating for the device behind the fifth hub,  the PEL will be

PEL = 5 * 2,047,000 = 

SEL = 5 * 2,047,000 + 2100 + 250 * (5 - 1) + 250 * 5 = 10,239,350 ns = 10 ms

That should fit in a 32-bit number, so an unsigned int ought to suffice.

For MEL, it's the sum of the max U2del for each link, plus an additional
delay per hub for the bHubHdrDecLat.  The header decode latency can't be
greater than 0.4 us per hub, so the MEL for the device would be

MEL = 5 * 2,047,000 + 400 * 5 = 10,237,000 ns

Which again, ought to fit in 32 bits.

> > @@ -507,6 +540,8 @@ struct usb_device {
> >  	struct wusb_dev *wusb_dev;
> >  	int slot_id;
> >  	enum usb_device_removable removable;
> > +	struct usb3_lpm_parameters u1_params;
> > +	struct usb3_lpm_parameters u2_params;
> 
> No kerneldoc entries added for these two new fields.

Ok, I'll fix this too.

Sarah Sharp
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

  Powered by Linux