DragonFly kernel List (threaded) for 2007-12
Re: ahc/ahd locking
FreeBSD mutexes get abused a lot and don't translate to our spinlocks.
Basically DFly spinlocks should only be used for very short code
sections that do not make any complex procedure calls.
For device drivers with interrupt handlers, such as ahc/ahd, it may
be beneficial to use the serializing locks because you can pass a
serializing lock directly to the kernel interrupt subsystem and let
the kernel deal with it for interrupts. You would then use
the lwkt_serialize*() API for the main-line AHC/AHD code to interlock
against the code that runs via the interrupt.
Lockmgr locks can be used for more general locking.
I suggest trying to use the serializing locks (kern/lwkt_serialize.c).
Look at various network device drivers on how to install a serializing
lock w/ the interrupt. Note that some reworking of the code might be
needed since the ahc/ahd interrupt code probably tries to release/reaquire
and/or do other nasty things when, in fact, you just want it to hold the
lock through the whole mess.
Typically the serializing lock is implemented on a per-controller basis,
NOT a per-device basis. Find the per-controller soft structure for
ahc/ahd and throw the lock in there.