Date: Wed, 2 Aug 2006 14:37:55 +0200 From: Hans Petter Selasky <hselasky@c2i.net> To: freebsd-hackers@freebsd.org Subject: miibus + USB = problem Message-ID: <200608021437.55500.hselasky@c2i.net>
next in thread | raw e-mail | index | archive | help
Hi,
I am currently in the progress of porting "if_aue.c" to my new USB API, and
have hit a problem that needs to be solved. The problem is that the USB
system sleeps under "miibus_xxx". Questions are:
Is this allowed?
What locks are held when these functions are called ?
Reference:
/* MII interface */
DEVMETHOD(miibus_readreg, aue_miibus_readreg),
DEVMETHOD(miibus_writereg, aue_miibus_writereg),
DEVMETHOD(miibus_statchg, aue_miibus_statchg),
The problem with USB devices, is that the read-register process is very slow.
It can take up to several milliseconds. And if the device is suddenly
detached one has to think about adding exit code everywhere.
The solution I see with USB devices is something like this:
if (sc->device_gone) {
exit mutexes ;
kthread_exit(0);
}
Of course I cannot "kthread_exit()" when the call comes from read/write/ioctl,
because there is a stack, that expects a returning call. If the kernel code
was objective C, then maybe one could throw an exception or do something
alike so that the processor gets out of the USB-read procedure.
Solutions:
1) use USB hardware polling, not releasing any mutexes, simply using DELAY(),
until read/writes complete.
2) pre-read all read registers regularly. How can I do this with "miibus"?
Anyone have any comments?
--HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608021437.55500.hselasky>
