On Tue, 30 Aug 2005, David Brownell wrote:

> > > Consider a device that needs 250mA of power to do more than just
> > > enumeration ... which has a small battery and these configurations:
> > >
> > >   #1 "Self powered" and bMaxPower is 100mA.  The remaining
> > >      150 mA comes from the battery.
> > >   #2 "Bus powered" and bMaxPower is 350mA.  All power comes
> > >      from VBUS, and the battery is recharging.
> > >
> > > If the battery is missing and the device can power up using
> > > just VBUS (for "config #0", to the tune of at most 100mA),
> > > maybe Linux should avoid config #1 ... in fact maybe it should
> > > always prefer #2 unless Linux is running on batteries.  :)
> > 
> > 
> > You mean, given a choice between a self-powered and a bus-powered config,
> > Linux should prefer the bus-powered config if the parent has an external
> > power supply? 
> 
> I had assumed that if the "self powered" device status was off,
> Linux could deduce "can't use config #1".  Just ruling out the
> option of defaulting to some broken configuration.

Okay, I get it (I think).  You're saying that if the device status
indicates there's no external power source then Linux shouldn't choose a
self-powered config, right?

> The smiley was about the _host_ Linux running on batteries.

So I gathered.

> It's a simple policy choice to save power; a choice that Linux
> is currently making, though with a different outcome in that case;
> and one that folk will likely argue about.

Right now choose_configuration isn't aware of whether or not the host is
running on batteries.  In principle it could be made aware of whether or
not the root hub supplies less than 500 mA per port; would that be
essentially equivalent?

> > There doesn't seem to be any way of telling whether a 
> > device uses a battery, whether the battery is present, or whether the
> > battery gets recharged. 
> 
> Other than for example users saying either of those things.

Yes.  And there's no way for the user to tell choose_configuration
anything of the sort.

Earlier you seemed to be making a different point: If a battery-powered
device is plugged into an externally-powered hub (or root hub) then the
kernel should prefer a config that recharges the battery over one that
discharges the battery.  This seems like a poor heuristic, because there's
no way of telling when to apply it.


> > (Unless I've misunderstood the spec and it wants 
> > "local power supply" and "external power supply" to mean different
> > things.)
> 
> I'm not sure you should expect such nuances to be treated
> consistently in that spec.  Neither case would be "exclusively
> bus powered", devices with either would set the "self powered"
> device status bit.

Specifications often are nit-picky about such nuances.  They have to be
and they're expected to be.  (Consider for instance the care with which
the spec distinguishes among "packet", "transaction", "stage", and
"message".)  In this case, though, it looks like the spec messed up and
allowed a potential ambiguity to slip through the cracks.


> > BTW, the calculation of the "per-port ceiling" in hub_power_remaining is
> > wrong. The ceiling is set to 100 mA when (for externally-powered hubs and
> > root hubs) it should be 500 mA.
> 
> The real issue is power limited root hubs, e.g. 250 mA on the one port.

Will it always be true that power-limited root hubs have only one port?  
If not, there's a possibility of confusion over whether 
hcd->power_budget refers to the total or the per-port value.


> > In fact, the whole idea of a per-hub power budget is a little dodgy.
> 
> Right, that code was originally not-to-spec and it changed to this.
> Which works mostly OK, except in the case of things like root hubs
> with a 250 mA current limit (in that one port!) powering a bus powered
> hub AND something downstream of that.
> 
> 
> >      It would be better to keep
> > track of the maximum current available for each port, and verify that each
> > port individually is not over-budget.
> 
> Yes.

Okay, I'll work on it.  Overall it should make things simpler.

There's one aspect that's not clear.  7.2.1 says "Battery-powered hubs
may supply either one or five unit loads per port."  How does usbcore know
if a hub can only supply one unit load/port?  There's nothing in any
descriptor to indicate such a limitation.

Alan Stern



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to