From owner-freebsd-current@FreeBSD.ORG Sat Jul 17 05:32:39 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C406016A4CE; Sat, 17 Jul 2004 05:32:39 +0000 (GMT) Received: from harmony.village.org (rover.village.org [168.103.84.182]) by mx1.FreeBSD.org (Postfix) with ESMTP id 342FC43D41; Sat, 17 Jul 2004 05:32:39 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.11/8.12.11) with ESMTP id i6H5Tpao003744; Fri, 16 Jul 2004 23:29:51 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Fri, 16 Jul 2004 23:29:58 -0600 (MDT) Message-Id: <20040716.232958.16681208.imp@bsdimp.com> To: green@freebsd.org From: "M. Warner Losh" In-Reply-To: <20040715180854.GZ1626@green.homeunix.org> References: <20040715180854.GZ1626@green.homeunix.org> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: current@freebsd.org Subject: Re: pccbb crashes when detaching (unsafe interrupt handler) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jul 2004 05:32:39 -0000 In message: <20040715180854.GZ1626@green.homeunix.org> Brian Fundakowski Feldman 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