Having looked at the history of that misnamed API:
- Originally provided in 2.2.10 or so, I think OHCI was the only
user. It was misnamed at that time, given that it was used
only to handshake "device is gone".
- Sometime in the 2.3 series, someone made a change to make the
usage in usbcore match that misnaming: just free memory. But
whoever that was did not change that single implementation of
the method (ohci) to match the changed semantics.
- So that 2.3.x change created a bug where none existed before.
It would only appear with OHCI *and* with a device driver that
was buggy and didn't disconnect() or refcount correctly.
I made that change a long time ago when I implemented the reference
counting code (IIRC). I may have missed the change to OHCI, but that
doesn't mean it's misnamed.
We'll just have to disagree on that. It may not be misnamed
in terms of the approach you have in mind ... but it wasn't
a name that matched its original concept/design/behavior.
That's caused quite a lot of trouble because the mismatch was
subtle enough to only show in combination with other bugs.
That's the sort of problem that's pretty typical when too
much gets pushed into a "memory management" bucket.
Back to the patch I've attached. It's against 2.4.19-pre3 (I'll update
to Greg's CVS tree) and hasn't had the level of testing necessary to
call it good. I also want to recheck that I caught all of the necessary
paths.
Seems like the main change there is that after disconnect, EDs
get cleaned up in the IRQ handler ... which means that when
the IRQ handler doesn't fire, nothing gets cleaned up. That
means some power management situations will (unnecessarily)
leak a lot, as will clean-up after the host controller dies
(maybe because of UE or cardbus eject).
Is that basically what you were trying to achieve?
While not ready to be included, I wanted to let everyone see it.
One benefit is that it results in a net code reduction.
Yes, but "ohci-hcd" is an even bigger reduction ... :)
usb-ohci.c | 72 +++++++++++--------------------------------------------------
usb-ohci.h | 58 +++++++++++++++++++++++++++++++------------------
2 files changed, 50 insertions(+), 80 deletions(-)
FWIW, we were hitting the BUG() call in sohci_free_dev().
With what device driver? As I've said, EVERY time I've looked
at such problems, the device driver has been at fault. Sometimes
quite blatantly, sometimes less so. EVERY TIME.
I'm positive that if you fixed that device driver's bug(s),
you'd stop getting that BUG().
A less invasive "fix" would be to just make the BUG() be "return 0".
That'd just leak memory, without affecting those other cases.
And such a buggy device driver deserves to leak ... :)
Interestingly enough, the comment before sohci_free_dev is correct, but
the implementation doesn't follow those rules.
Right, I added it as part of a "document current calling conventions"
pass. It's missing a comment about those conventions being broken. :-P
- Dave
-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel