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;
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to