From owner-freebsd-arch@FreeBSD.ORG Mon Oct 3 16:44:55 2005 Return-Path: X-Original-To: arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 919DE16A41F; Mon, 3 Oct 2005 16:44:55 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from mv.twc.weather.com (mv.twc.weather.com [65.212.71.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA98743D46; Mon, 3 Oct 2005 16:44:54 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from [10.50.41.233] (Not Verified[10.50.41.233]) by mv.twc.weather.com with NetIQ MailMarshal (v6, 0, 3, 8) id ; Mon, 03 Oct 2005 13:01:00 -0400 From: John Baldwin To: arch@FreeBSD.org Date: Mon, 3 Oct 2005 12:46:13 -0400 User-Agent: KMail/1.8 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200510031246.14835.jhb@FreeBSD.org> Cc: ru@FreeBSD.org, M.@WarnerLosh Subject: Ethernet driver teardown X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Oct 2005 16:44:55 -0000 So, I was thinking about the problem with ethernet driver detach races this morning and had an idea. What if the sequence for detach() was altered such that we called ether_ifdetach() before the driver's stop() routine? Thus, you would end up with something like this: foo_detach() { ether_ifdetach(sc->foo_ifp); FOO_LOCK(sc); foo_stop(sc); FOO_UNLOCK(sc); callout_drain(...); bus_teardown_intr(...); if_free(sc->foo_ifp); bus_release_resources(...); ... } Would that solve the various races including letting BPF turn off promiscuous mode cleanly without requiring detaching flags in each driver to bail out of foo_ioctl()? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org