> > > > Driver disconnect() routines need to unlink ALL urbs as well as
> > > > make sure that no other driver entries (file operations, say) will
> > > > ever try to use that device again (even while unlinking proceeds).
> > > 
> > > Then I hope that disconnect() is not called on an irq!
> > 
> > Only in uncommon error recovery situations, AFAIK.  That's is a
> > good reason to use async unlink in disconnect() though.
> 
> disconnect is guaranteed to only happen in a process context (khubd,
> rmmod, etc)

Not when it's called from the pci_driver remove() method, which
Documentation/pci.txt says "can be called from interrupt context".
By my observation that's not common.   However, remove() must
currently be able to get rid of every driver-to-device binding... the
HCDs need that to happen before the root hub can vanish.


> > What disconnect() means is:  as of this instant, you can't depend on
> > being able to do I/O with this device any more.  And when that
> > disconnect() returns, the pointer becomes invalid/unusable.
> 
> Not exactly true. With the reference counting, the pointer can still be
> valid. It usually not usable tho since the device is gone now.

Well, focus on the "unusable" part.  Actually I should have said
"interface" not "device" ... sometimes drivers may need to get
disconnected while the device is still present (letting some other
driver connect, say).


> > So disconnect() should clear the usb_device pointer in the driver's
> > record.  That'd be one way that all other execution contexts in
> > the driver (timer, sleeping process/thread, etc) would know that
> > particular device is disconnected.  The driver would free its own
> > record of device state when the last context stopped using it.
> 
> Or take advantage of the reference counting.

I'd null the pointer in any case ... since we know that can produce
a consistent error, but violation of refcount rules produce really
strange errors.  Like one I just tripped over in usb.c ... :)

- Dave


> JE
> 
> 



_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
http://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to