From owner-freebsd-current@FreeBSD.ORG Mon Apr 28 14:16:21 2003 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 270C437B401 for ; Mon, 28 Apr 2003 14:16:21 -0700 (PDT) Received: from mail.speakeasy.net (mail12.speakeasy.net [216.254.0.212]) by mx1.FreeBSD.org (Postfix) with ESMTP id 888C543FCB for ; Mon, 28 Apr 2003 14:16:20 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 30360 invoked from network); 28 Apr 2003 21:16:28 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender )encrypted SMTP for ; 28 Apr 2003 21:16:28 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.8/8.12.8) with ESMTP id h3SLGIOv016137; Mon, 28 Apr 2003 17:16:18 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20030428.150307.83622281.imp@bsdimp.com> Date: Mon, 28 Apr 2003 17:16:23 -0400 (EDT) From: John Baldwin To: "M. Warner Losh" cc: freebsd-current@FreeBSD.org cc: shinra@j10n.org Subject: Re: panic: sleeping thread owns a mutex 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: Mon, 28 Apr 2003 21:16:21 -0000 On 28-Apr-2003 M. Warner Losh wrote: > In message: > John Baldwin writes: >: >: On 26-Apr-2003 AIDA Shinra wrote: >: > My kernel always panics when I remove my wi pccard (WLI-PCM-S11). >: > I am using OLDCARD and enabling hw.pcic.intr_path=1. With NEWCARD no >: > cards work. I reported this bug 2 weeks ago but even today's kernel >: > panics in exactly the same way. Anyone experiencing the same problem? >: > Or just my misconfiguration? >: >: Can you try this patch: >: >: Index: if_wi.c >: =================================================================== >: RCS file: /usr/cvs/src/sys/dev/wi/if_wi.c,v >: retrieving revision 1.137 >: diff -u -r1.137 if_wi.c >: --- if_wi.c 10 Apr 2003 07:55:55 -0000 1.137 >: +++ if_wi.c 28 Apr 2003 20:39:37 -0000 >: @@ -486,10 +486,10 @@ >: ifmedia_removeall(&sc->sc_media); >: >: ieee80211_ifdetach(ifp); >: + WI_UNLOCK(sc); >: bus_teardown_intr(dev, sc->irq, sc->wi_intrhand); >: wi_free(dev); >: >: - WI_UNLOCK(sc); >: #if __FreeBSD_version >= 500000 >: mtx_destroy(&sc->sc_mtx); >: #endif >: >: It is not ok to hold a lock when calling bus_teardown_intr() or >: bus_setup_intr(). > > This brings up another problem. > > If wi is on a shared interrupt, what happens if an interrupt comes in > while the device is being torn down? Eg, as soon as you drop that > lock, the wi_intr gets the lock and bad things happen at the > mtx_destroy potentially. How do we keep from racing? Set a flag in your driver before you drop the wi lock that the wiintr() function can check and bail out immediately if it is set. For example: foo_detach() { ... sc->sc_dead = 1; FOO_UNLOCK(sc); bus_teardown_intr(...) ... } foo_intr() { FOO_LOCK(sc); if (sc->sc_dead) { FOO_UNLOCK(sc); return; } ... } -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/