From owner-freebsd-current@FreeBSD.ORG Mon Apr 28 15:56:05 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 13D9337B401; Mon, 28 Apr 2003 15:56:05 -0700 (PDT) Received: from mta4.rcsntx.swbell.net (mta4.rcsntx.swbell.net [151.164.30.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7597D43F93; Mon, 28 Apr 2003 15:56:04 -0700 (PDT) (envelope-from hsu@FreeBSD.org) Received: from FreeBSD.org (adsl-63-193-112-125.dsl.snfc21.pacbell.net [63.193.112.125])h3SMtuPi008021; Mon, 28 Apr 2003 17:55:56 -0500 (CDT) Message-Id: <200304282255.h3SMtuPi008021@mta4.rcsntx.swbell.net> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: jhb@FreeBSD.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 28 Apr 2003 16:04:46 -0700 From: Jeffrey Hsu cc: current@FreeBSD.org cc: imp@bsdimp.com 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 22:56:05 -0000 > 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(...) > ... mtx_destroy(&sc->sc_mtx); <--- note this > } > foo_intr() > { > FOO_LOCK(sc); > if (sc->sc_dead) { > FOO_UNLOCK(sc); > return; > } > ... > } The sc_dead flag doesn't protect against foo_intr() attempting to lock a mutex that has been destroyed. fxp has the same problem and is one of the reasons, among others, I wasn't too happy with the fxp softc locks introduced there. The solution I have in mind involves using the DEAD flag in the interrupt handler to defer destroying the mutex if the interrupt handler is active. Jeffrey