[pvrusb2] pvrusb2 & USB/IP

Mike Isely isely at isely.net
Tue Jul 24 19:01:02 CDT 2007


On Wed, 25 Jul 2007, Olivier Oswald wrote:

> The USB/IP project (see http://usbip.sourceforge.net) provides sharing of
> USB devices over IP.
> 
> I'm currently testing this with a WinTV PVR - however usbip treats the
> device reset during the pvrusb2 initialization phase as if the device was
> physically disconnected - and terminates the sharing of the device. I've
> already set initusbreset=0, but this didn't help. Any chance to initialize
> the device without resetting it?

Olivier:

Sorry, there's not much that can be done about this.  Let me explain...

The device uses a Cypress FX2 microcontroller which sits at the end of 
the USB cable and effectively acts as a proxy for the host to operate 
the various bits and pieces inside the enclosure.  This microcontroller 
is built around an 8051 core with lots of fun stuff glommed onto it for 
handling USB traffic.  In the case of the Hauppauge PVR USB2, this chip 
needs to be loaded with firmware from the host (the FX2 architecture 
also makes possible loading of firmware from a local I2C-connected PROM 
but Hauppauge didn't do this, very likely because firmware loading from 
the host is far more flexible and allows for after-the-fact bug 
fixes...).

The FX2 architecture handles firmware loading via a silicon function in 
the USB device logic.  The host uses this function to force the 8051 
core into reset, load the firmware, then release the 8051 from reset.  
When the 8051 comes up, the loaded firmware then reprograms the USB 
subsystem in the chip, reseting its parameters and otherwise doing 
various things that disrupt the USB interface.  This action requires 
that the device drop off the bus and then reconnect.  It's really needed 
because the newly programmed USB interface can potentially "look" 
entirely different to the host than it did before and because of this it 
really has to disconnect / reconnect.  The FX2 documentation actually 
describes this behavior as a feature and applies a cutesy trademarked 
name (IIRC) to it called "renumeration" or some such strangeness.

That's why the device disconnects.

It's really a pain for hosts because that means that a driver for such a 
device must somehow have some kind of memory persisted across the 
disconnect / reconnect action.  I finessed this in the pvrusb2 driver by 
implementing a means for the driver to detect the device's state (loaded 
or not loaded) so then when the Linux USB core instantiates the driver a 
second time it doesn't need to "remember" that the device had already 
appeared once.

Now, if the pvrusb2 driver determines that it does not need to load the 
FX2 firmware, this behavior won't take place.  In that case the device 
remains connected and everything initializes.  You can observe this 
effect by plugging in a device that is still powered on from the last 
time it was plugged in (and thus still running the previously loaded FX2 
firmware).  However on a "cold" PVR USB2 device, this firmware ALWAYS 
has to be loaded and thus you see the disconnect.

The initusbreset switch is a different thing in the driver.  Turning 
that switch on (it's normally off) causes the pvrusb2 driver to force an 
additional reset to the device, via a standard USB command.  I 
implemented that in an attempt to make it possible for the driver to get 
control over a crashed device (and IIRC it will only do this if the 
switch is on AND the device won't communicate).  In practice however 
I've never had a case where this action actually helped.  If the device 
was so far gone that it won't communicate then initusbreset generally 
doesn't help anyway.

The only suggestion I can make is to maybe get some kind of feature 
implemented in the usbip project so that it can handle a reconnect like 
this.  Pretty much any USB device with an FX2 in it is probably going to 
have this issue - unless it boots entirely from an internal PROM but 
this generally doesn't seem to be the case - and there are other devices 
out there like this.  I've also seen other flakey USB device which can 
spontaneously disconnect / reconnect.  I have a Conext 950 UPS here 
which unfortunately does this - and it drives me nuts because the NUT 
package doesn't seem to know how to reconnect to the UPS so my server 
every couple of days loses contact with its UPS, darn it.

  -Mike

-- 
                        |         Mike Isely          |     PGP fingerprint
     Spammers Die!!     |                             | 03 54 43 4D 75 E5 CC 92
                        |   isely @ pobox (dot) com   | 71 16 01 E2 B5 F5 C1 E8
                        |                             |


More information about the pvrusb2 mailing list