Re: MTX_DEF versus MTX_SPIN

From: <mdf_at_FreeBSD.org>
Date: Wed, 3 Nov 2010 10:04:13 -0700
On Wed, Nov 3, 2010 at 9:42 AM, Andriy Gapon <avg_at_icyb.net.ua> wrote:
> on 03/11/2010 18:27 mdf_at_FreeBSD.org said the following:
>> It's not clear to me from the man pages (perhaps I didn't look at the
>> right one?) in which environments I need a spinlock.  For example, I
>> wouldn't think it's safe to use a MTX_DEF in a hard interrupt handler
>> (i.e one that was registered with BUS_SETUP_INTR), but I see some code
>> lying around here that does it and nothing I'm aware of has broken.
>
> Such a handler runs in an interrupt thread.
> The "harder" interrupt handler is called interrupt filter in FreeBSD terminology.
>  I think that it was formerly known as fast interrupt.

So a MTX_DEF is okay in that environment?

What would "best practices" be considered for what code should be run
in the interrupt handler versus a soft interrupt?  In this case the
kinds of things we have to do at some level of interrupt are:

 - handle a heartbeat interrupt from firmware a few times a second
 - get a DMA completion interrupt (completely handling this requires
calling biodone on all the associated bios)
 - receive an ECC interrupt (this requires reading registers off the
card for details)

At the moment we're on stable/7, but we will be migrating the code
base to something more recent in another year or so, if that affects
the answer.

Is there any documentation on best practices for writing a FreeBSD driver?

Thanks,
matthew
Received on Wed Nov 03 2010 - 16:04:14 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:08 UTC