ahc/ahd locking

Matthew Dillon dillon at apollo.backplane.com
Mon Dec 31 08:37:08 PST 2007


    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.

						-Matt






More information about the Kernel mailing list