From owner-svn-src-all@freebsd.org Tue Mar 15 17:53:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F85DAD1721; Tue, 15 Mar 2016 17:53:57 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 51A6113D7; Tue, 15 Mar 2016 17:53:57 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 5E7AEB98F; Tue, 15 Mar 2016 13:53:56 -0400 (EDT) From: John Baldwin To: Hans Petter Selasky Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r296909 - head/sys/ofed/drivers/infiniband/ulp/ipoib Date: Tue, 15 Mar 2016 10:43:53 -0700 Message-ID: <2420759.o4YiE5Za4X@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: <201603151547.u2FFlQKN078643@repo.freebsd.org> References: <201603151547.u2FFlQKN078643@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 15 Mar 2016 13:53:56 -0400 (EDT) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2016 17:53:57 -0000 On Tuesday, March 15, 2016 03:47:26 PM Hans Petter Selasky wrote: > Author: hselasky > Date: Tue Mar 15 15:47:26 2016 > New Revision: 296909 > URL: https://svnweb.freebsd.org/changeset/base/296909 > > Log: > Fix witness panic in the ipoib_ioctl() function when unloading the > ipoib module. > > The bpfdetach() function is trying to turn off promiscious mode on the > network interface it is attached to while holding a mutex. The fix > consists of ignoring any further calls to the ipoib_ioctl() function > when the network interface is going to be detached. The ipoib_ioctl() > function might sleep. > > Sponsored by: Mellanox Technologies > MFC after: 1 week In all of the other NIC drivers I have worked on the fix has been to call if_detach (or ether_ifdetach) as the first step in your detach method before you try to stop the interface. The idea is to remove external connections from your driver first, and the only after those have drained do you actually shut down the hardware. Given you are calling if_detach() just before if_free() below, ipoib just seems to be broken here. For example, detach in a typical NIC driver does this: struct foo_softc *sc; sc = device_get_softc(dev); ether_ifdetach(sc->sc_ifp); FOO_LOCK(sc); foo_stop(sc); FOO_UNLOCK(sc); callout_drain(&sc->timer); bus_teardown_intr(...); bus_release_resource(...); if_free(sc->sc_ifp); Similarly, devices with a character device in /dev should be calling destroy_dev() first before shutting down hardware, etc. -- John Baldwin