On Fri, 18 Jun 2004, David Brownell wrote:

> Alan Stern wrote:
> > Greg:
> > 
> > This patch fixes another bug in the dummy_hcd driver.  When a gadget 
> > driver unregisters (simulating a device disconnect), dummy_hcd stops the 
> > timer that it uses for processing outstanding URBs.  Unfortunately this 
> > means that those URBs will never be given back.  The patch lets the timer 
> > continue running; when it expires all the remaining URBs will fail so the 
> > timer won't be reinitialized.
> 
> Wouldn't it be better to just force the timer to run
> right away?  And fail all URBs and usb_requests right
> at that point.  The timer needs to stop running at
> clearly defined points, notably "before rmmod" ...

I thought about this and no, it wouldn't be better, for a couple of 
reasons:

        Real host controllers don't fail URBs as soon as the device
        disconnects.  They continue to transmit, and get protocol errors
        when there's no reply.  The dummy_hcd simulation should work
        the same way.

        Just because the gadget driver has unregistered doesn't mean
        the timer can't keep running.  It's only when the corresponding
        usb_device has been freed or dummy_hcd is exiting that we need
        the timer to stop.

As you note, rmmod presents a potential problem.  Obviously we don't want
the timer to fire when the code is being unloaded!  But in this regard 
dummy_hcd is no different from any other host controller driver:

        The timer doesn't run when there are no outstanding URBs.

        If there are outstanding URBs then the usb_device must exist,
        since the hcd glue layer guarantees that an URB in flight
        owns a reference to the usb_device.

        The usb_device and the root hub device both own a reference
        to the usb_bus.

        The HCD's bus-release callback won't get called until after all
        references to the bus are dropped.  This can be after the
        unregister_bus call returns (although I would like to change
        usbcore so that it can't be).

        If an HCD is unloaded from memory before its bus-release
        routine runs, there's a problem.  That's true for any HCD.

As you can see, any issues are generic and ought to be solved in the core.  
They aren't specific to dummy_hcd.

Alan Stern



-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to