From owner-freebsd-arm@FreeBSD.ORG Thu Nov 19 16:38:33 2009 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0806106568B for ; Thu, 19 Nov 2009 16:38:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 969938FC27 for ; Thu, 19 Nov 2009 16:38:33 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 30BD546B2C for ; Thu, 19 Nov 2009 11:38:33 -0500 (EST) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 7FB6F8A020 for ; Thu, 19 Nov 2009 11:38:32 -0500 (EST) From: John Baldwin To: arm@freebsd.org Date: Thu, 19 Nov 2009 11:22:02 -0500 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200911191122.02975.jhb@freebsd.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Thu, 19 Nov 2009 11:38:32 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: Subject: [PATCH] Fix a few nits in ate(4) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2009 16:38:33 -0000 I ran into this while working on purging if_watchdog/if_timer use from the tree. This patch fixes a few things in ate(4): - Initialize callout before it is used in atestop() during attach. - Fixup detach. By fixing detach, I mean that it calls ether_ifdetach() to remove outside references to the device before shutting down the device. Please test. --- //depot/vendor/freebsd/src/sys/arm/at91/if_ate.c 2009/06/26 11:50:17 +++ //depot/user/jhb/cleanup/sys/arm/at91/if_ate.c 2009/11/17 18:08:42 @@ -75,8 +75,7 @@ /* * Driver-specific flags. */ -#define ATE_FLAG_DETACHING 0x01 -#define ATE_FLAG_MULTICAST 0x02 +#define ATE_FLAG_MULTICAST 0x01 struct ate_softc { @@ -196,6 +195,7 @@ sc = device_get_softc(dev); sc->dev = dev; ATE_LOCK_INIT(sc); + callout_init_mtx(&sc->tick_ch, &sc->sc_mtx, 0); /* * Allocate resources. @@ -233,7 +233,6 @@ ATE_LOCK(sc); atestop(sc); ATE_UNLOCK(sc); - callout_init_mtx(&sc->tick_ch, &sc->sc_mtx, 0); if ((err = ate_get_mac(sc, eaddr)) != 0) { /* @@ -311,12 +309,11 @@ KASSERT(sc != NULL, ("[ate: %d]: sc is NULL", __LINE__)); ifp = sc->ifp; if (device_is_attached(dev)) { + ether_ifdetach(ifp); ATE_LOCK(sc); - sc->flags |= ATE_FLAG_DETACHING; - atestop(sc); + atestop(sc); ATE_UNLOCK(sc); callout_drain(&sc->tick_ch); - ether_ifdetach(ifp); } if (sc->miibus != NULL) { device_delete_child(dev, sc->miibus); @@ -1109,11 +1105,9 @@ & (IFF_PROMISC | IFF_ALLMULTI)) != 0) ate_rxfilter(sc); } else { - if ((sc->flags & ATE_FLAG_DETACHING) == 0) - ateinit_locked(sc); + ateinit_locked(sc); } } else if ((drv_flags & IFF_DRV_RUNNING) != 0) { - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; atestop(sc); } sc->if_flags = flags; -- John Baldwin