From owner-svn-src-all@freebsd.org Wed Mar 16 20:27:45 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 3B914AD32EE; Wed, 16 Mar 2016 20:27:45 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 0C2D3666; Wed, 16 Mar 2016 20:27:44 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id u2GKRcWs077538 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Mar 2016 13:27:38 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id u2GKRcnQ077537; Wed, 16 Mar 2016 13:27:38 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Wed, 16 Mar 2016 13:27:38 -0700 From: Gleb Smirnoff To: John Baldwin Cc: Hans Petter Selasky , 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 Message-ID: <20160316202738.GL1328@FreeBSD.org> References: <201603151547.u2FFlQKN078643@repo.freebsd.org> <2420759.o4YiE5Za4X@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2420759.o4YiE5Za4X@ralph.baldwin.cx> User-Agent: Mutt/1.5.24 (2015-08-30) 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: Wed, 16 Mar 2016 20:27:45 -0000 On Tue, Mar 15, 2016 at 10:43:53AM -0700, John Baldwin wrote: J> > Log: J> > Fix witness panic in the ipoib_ioctl() function when unloading the J> > ipoib module. J> > J> > The bpfdetach() function is trying to turn off promiscious mode on the J> > network interface it is attached to while holding a mutex. The fix J> > consists of ignoring any further calls to the ipoib_ioctl() function J> > when the network interface is going to be detached. The ipoib_ioctl() J> > function might sleep. J> > J> > Sponsored by: Mellanox Technologies J> > MFC after: 1 week J> J> In all of the other NIC drivers I have worked on the fix has been to call J> if_detach (or ether_ifdetach) as the first step in your detach method before J> you try to stop the interface. The idea is to remove external connections J> from your driver first, and the only after those have drained do you actually J> shut down the hardware. Given you are calling if_detach() just before J> if_free() below, ipoib just seems to be broken here. J> J> For example, detach in a typical NIC driver does this: J> J> struct foo_softc *sc; J> J> sc = device_get_softc(dev); J> ether_ifdetach(sc->sc_ifp); J> FOO_LOCK(sc); J> foo_stop(sc); J> FOO_UNLOCK(sc); J> callout_drain(&sc->timer); J> bus_teardown_intr(...); J> bus_release_resource(...); J> if_free(sc->sc_ifp); J> J> Similarly, devices with a character device in /dev should be calling J> destroy_dev() first before shutting down hardware, etc. In the new KPI in the projects/ifnet branch, I am doing the following: - there is only one if_detach(), that does both detach and free - if_detach() is called at the very last stage, after stopping hardware (if hw is still present) - driver is responsible to be ready to be called from upper half of the stack, regardless of the state of hardware. Ususally it means that it should lock internal mutex, and check internal RUNNING flag. Note, that hardware can go away asynchronously, so demand to call if_detach() before stopping hardware can't be fulfiled. -- Totus tuus, Glebius.