Re: xhci power to external device

2019-02-23 Thread Rhialto
I "solved" the problem by returning the disk in question ("performance
not as expected") and buying a "desktop" model (which has its own
external power supply). Since it is a 3,5" disk inside instead of a
2,5", it is a bit faster too.

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- "What good is a Ring of Power
\X/ rhialto/at/falu.nl  -- if you're unable...to Speak." - Agent Elrond


signature.asc
Description: PGP signature


Re: xhci power to external device

2019-02-19 Thread Michael van Elst
On Tue, Feb 19, 2019 at 11:30:22AM -0500, Greg Troxel wrote:
> > That information is mostly used to calculate the power budget, If
> > it would be exceeded, the device isn't allowed to draw more power.
> How common is it for USB controllers to actually do this calculation and
> selectively enable, vs being built to supply 500/900 per port?
> Looking at NetBSD drivers quickly, I don't see this.

usb_subr.c:707ff


> Certainly current limiting on power supplies is normal.

Probably. Hubs notice when the current limit is exceeded, I don't see
that our controllers could set a current limit but there is probably
some fuse or other current limiter to prevent damage.


Greetings,
-- 
Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: xhci power to external device

2019-02-19 Thread Greg Troxel
mlel...@serpens.de (Michael van Elst) writes:

> USB2 ports are limited to 100mA and devices may communicate that they
> want more (up to 500mA) and then are signaled to draw more power.
>
> USB3 is similar but allows other limits, 150mA default and 900mA max.
> There are also USB3 options that allow even more power, e.g. for
> USB chargers.

Thanks for straigtening me out!
>
> That information is mostly used to calculate the power budget, If
> it would be exceeded, the device isn't allowed to draw more power.

How common is it for USB controllers to actually do this calculation and
selectively enable, vs being built to supply 500/900 per port?
Looking at NetBSD drivers quickly, I don't see this.

> Many USB controllers cannot limit the power output, so even when
> a device is denied the extra power (or didn't even dare to communicate
> and is only allowed the minimum) it could just draw higher currents.

That seems cheaper to build.

>>  I have never heard of a port that can throttle what it supplies.
>
> Throttling would cause the voltage to drop, which of course happens
> when a device tries to draw more current than the port can provide.
> A USB controller that limits power output on a port does this to
> protect the port.

Certainly current limiting on power supplies is normal.   How common is
it for a USB controller to not only have current limiting for the
500/900 level (to protect the port hardware as you say) to also have
configured lower current limiting so that devices that should be under
100/150 will be prevented from going much over that?


Overall, it sounds to me like Rhialto's problem is more likely some kind
of bug, dodgy wiring, marginal power supply, etc.


Re: xhci power to external device

2019-02-18 Thread Michael van Elst
g...@lexort.com (Greg Troxel) writes:

>Rhialto  writes:

>> I have an external harddisk, like so: (output from usbdevs -v)
>>
>> Controller /dev/usb0:
>> addr 0: super speed, self powered, config 1, xHCI Root Hub(0x), vendor 
>> 8086(0x8086), rev 1.00(0x0100)
>>  port 1 addr 9: super speed, power 224 mA, config 1, Elements 25A1(0x25a1), 
>> Western Digital(0x1058), rev 10.14(0x1014), serial 
>>
>> I have some reason to believe it does nog get enough power from the
>> port. Is the "power 224 mA" how the current is actually limited? Or can
>> the device draw more without telling us?

>My impression is:

>  USB ports and devices are limited to 500 mA, per the spec.  (But,
>  there are various schemes for USB chargers to communciate that they
>  support more, so devices can be willing to draw more)


USB2 ports are limited to 100mA and devices may communicate that they
want more (up to 500mA) and then are signaled to draw more power.

USB3 is similar but allows other limits, 150mA default and 900mA max.
There are also USB3 options that allow even more power, e.g. for
USB chargers.

That information is mostly used to calculate the power budget, If
it would be exceeded, the device isn't allowed to draw more power.

Many USB controllers cannot limit the power output, so even when
a device is denied the extra power (or didn't even dare to communicate
and is only allowed the minimum) it could just draw higher currents.

Some USB controllers that can limit the power output only switch between
minimum and unlimited. That's also allowed so that a USB2 device asking
for 500mA can actually draw 900mA on a USB3 port without violating the
spec.


>  I have never heard of a port that can throttle what it supplies.

Throttling would cause the voltage to drop, which of course happens
when a device tries to draw more current than the port can provide.
A USB controller that limits power output on a port does this to
protect the port.


-- 
-- 
Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: xhci power to external device

2019-02-17 Thread Greg Troxel
Rhialto  writes:

> I have an external harddisk, like so: (output from usbdevs -v)
>
> Controller /dev/usb0:
> addr 0: super speed, self powered, config 1, xHCI Root Hub(0x), vendor 
> 8086(0x8086), rev 1.00(0x0100)
>  port 1 addr 9: super speed, power 224 mA, config 1, Elements 25A1(0x25a1), 
> Western Digital(0x1058), rev 10.14(0x1014), serial 
>
> I have some reason to believe it does nog get enough power from the
> port. Is the "power 224 mA" how the current is actually limited? Or can
> the device draw more without telling us?

My impression is:

  USB ports and devices are limited to 500 mA, per the spec.  (But,
  there are various schemes for USB chargers to communciate that they
  support more, so devices can be willing to draw more)

  what you are seeing is the device's declaration of how much power it
  will draw

  there is, very maybe, some notion that a computer will only enable a
  port if some power conditions are met, such as the total declared
  power of all enabled devices remains below some level believed to be
  what can in aggregate is supplied.  But I'm not sure this exists.

  I have never heard of a port that can throttle what it supplies.

  I have definitely seen problems from trying to pull too much power in
  various ways.

  I don't have a good reason to believe all ports in any one computer
  will have exactly the same behavior.

  if you have an external disk that is USB powered, and it's flaky, you
  should get a powered hub


Re: xhci power to external device

2019-02-17 Thread Rhialto
On Sun 17 Feb 2019 at 21:34:44 +0100, Rhialto wrote:
> I have an external harddisk, like so: (output from usbdevs -v)
> 
> Controller /dev/usb0:
> addr 0: super speed, self powered, config 1, xHCI Root Hub(0x), vendor 
> 8086(0x8086), rev 1.00(0x0100)
>  port 1 addr 9: super speed, power 224 mA, config 1, Elements 25A1(0x25a1), 
> Western Digital(0x1058), rev 10.14(0x1014), serial 

To make things more interesting, I connected it to a laptop which has
USB 2, not 3, and under Linux "lsusb -v" says

bmAttributes 0x80
  (Bus Powered)
MaxPower  500mA

On the same laptop, with NetBSD 8, also 500 mA:

Controller /dev/usb7:
addr 1: high speed, self powered, config 1, EHCI root hub(0x), vendor 
8086(0x8086), rev 1.00(0x0100)
 port 1 addr 2: high speed, power 500 mA, config 1, Elements 25A1(0x25a1), 
Western Digital(0x1058), rev 10.14(0x1014), serial 

When I try the same on the original computer in a USB 2 port, I get the
same result.

On a MacBook (which does have USB 3), "System Information" says
"Current Available (mA): 900" and "Current Required (mA): 896".

And on a laptop with Linux and USB 3 ports, the same "224 mA" number is
shown by lsusb -v.

So there seems some confusion about the number, which supposedly is
reported by the device and simply believed by the computer.

So inspired by seeing "500 mA" on USB-2 ports, I plugged the disk into
a USB-2 port on the original computer, and I don't see the symptoms
(yet??) that made me think that there was a power problem.

Can anyone shed some light on this?

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- "What good is a Ring of Power
\X/ rhialto/at/falu.nl  -- if you're unable...to Speak." - Agent Elrond


signature.asc
Description: PGP signature


xhci power to external device

2019-02-17 Thread Rhialto
I have an external harddisk, like so: (output from usbdevs -v)

Controller /dev/usb0:
addr 0: super speed, self powered, config 1, xHCI Root Hub(0x), vendor 
8086(0x8086), rev 1.00(0x0100)
 port 1 addr 9: super speed, power 224 mA, config 1, Elements 25A1(0x25a1), 
Western Digital(0x1058), rev 10.14(0x1014), serial 

I have some reason to believe it does nog get enough power from the
port. Is the "power 224 mA" how the current is actually limited? Or can
the device draw more without telling us?

For comparison, there is another device like so, which is a SD card
reader:

Controller /dev/usb3:
addr 1: high speed, self powered, config 1, EHCI root hub(0x), vendor 
8086(0x8086), rev 1.00(0x0100)
 port 1 addr 2: high speed, self powered, config 1, Rate Matching Hub(0x0024), 
Intel(0x8087), rev 0.00(0x)
...
  port 6 addr 3: high speed, power 500 mA, config 1, USB Storage(0x0723), 
Generic(0x05e3), rev 94.51(0x9451)

so at least some devices can draw that much.

If the given 224 mA are actually enforced, can I give the disk more
anyway?

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- "What good is a Ring of Power
\X/ rhialto/at/falu.nl  -- if you're unable...to Speak." - Agent Elrond


signature.asc
Description: PGP signature