Re: pccbb crashes when detaching (unsafe interrupt handler)

From: M. Warner Losh <imp_at_bsdimp.com>
Date: Fri, 16 Jul 2004 23:29:58 -0600 (MDT)
In message: <20040715180854.GZ1626_at_green.homeunix.org>
            Brian Fundakowski Feldman <green_at_freebsd.org> writes:
:  	if (sc->flags & CBB_CARD_OK) {
: +		int needgiant = 0;
: +
: +		sx_slock(&sc->intrsx);
:  		STAILQ_FOREACH(ih, &sc->intr_handlers, entries) {
: -			if ((ih->flags & INTR_MPSAFE) == 0)
: -				mtx_lock(&Giant);
: -			(*ih->intr)(ih->arg);
: -			if ((ih->flags & INTR_MPSAFE) == 0)
: -				mtx_unlock(&Giant);
: +			if ((ih->flags & INTR_MPSAFE) == 0) {
: +				needgiant = 1;
: +				break;
: +			}
: +		}
: +		if (!needgiant) {
: +			STAILQ_FOREACH(ih, &sc->intr_handlers, entries)
: +				(*ih->intr)(ih->arg);
: +			sx_sunlock(&sc->intrsx);
: +			return;
:  		}
: +		sx_sunlock(&sc->intrsx);
: +		mtx_lock(&Giant);
: +		sx_slock(&sc->intrsx);
: +		STAILQ_FOREACH(ih, &sc->intr_handlers, entries)
: +			(*ih->intr)(ih->arg);
: +		sx_sunlock(&sc->intrsx);
: +		mtx_unlock(&Giant);
:  	}
:  }

I also don't like this patch because it takes out GIANT for the
duration of ALL handlers, not just the ones that need that.  Why is
that necesary?

Warner
Received on Sat Jul 17 2004 - 03:32:39 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:02 UTC