From owner-svn-src-head@FreeBSD.ORG Sun Oct 28 18:46:07 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EE5DF81A; Sun, 28 Oct 2012 18:46:06 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C62E98FC08; Sun, 28 Oct 2012 18:46:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9SIk6sl075526; Sun, 28 Oct 2012 18:46:06 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9SIk6iM075524; Sun, 28 Oct 2012 18:46:06 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201210281846.q9SIk6iM075524@svn.freebsd.org> From: Adrian Chadd Date: Sun, 28 Oct 2012 18:46:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r242258 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Oct 2012 18:46:07 -0000 Author: adrian Date: Sun Oct 28 18:46:06 2012 New Revision: 242258 URL: http://svn.freebsd.org/changeset/base/242258 Log: Add a temporary (for values of "temporary") work around for hotplug support with ath(4) and VIMAGE. Right now the VIMAGE code doesn't supply a default vnet context during: * hotplug attach; * any device detach. It special cases kldload/boot time probing (by setting the context to vnet0) but that doesn't occur when probing devices during a bus rescan - eg, adding a cardbus card. These will eventually go away when the VIMAGE support extends to providing default contexts to hotplug attach/detach. Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Sun Oct 28 18:45:04 2012 (r242257) +++ head/sys/dev/ath/if_ath.c Sun Oct 28 18:46:06 2012 (r242258) @@ -281,6 +281,7 @@ ath_attach(u_int16_t devid, struct ath_s DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid); + CURVNET_SET(vnet0); ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211); if (ifp == NULL) { device_printf(sc->sc_dev, "can not if_alloc()\n"); @@ -292,6 +293,7 @@ ath_attach(u_int16_t devid, struct ath_s /* set these up early for if_printf use */ if_initname(ifp, device_get_name(sc->sc_dev), device_get_unit(sc->sc_dev)); + CURVNET_RESTORE(); ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, sc->sc_eepromdata, &status); @@ -887,8 +889,11 @@ bad2: bad: if (ah) ath_hal_detach(ah); - if (ifp != NULL) + if (ifp != NULL) { + CURVNET_SET(ifp->if_vnet); if_free(ifp); + CURVNET_RESTORE(); + } sc->sc_invalid = 1; return error; } @@ -930,7 +935,10 @@ ath_detach(struct ath_softc *sc) ath_rxdma_teardown(sc); ath_tx_cleanup(sc); ath_hal_detach(sc->sc_ah); /* NB: sets chip in full sleep */ + + CURVNET_SET(ifp->if_vnet); if_free(ifp); + CURVNET_RESTORE(); return 0; }