From owner-p4-projects@FreeBSD.ORG Tue May 27 18:23:23 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E37011065671; Tue, 27 May 2008 18:23:22 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3C6E106566C for ; Tue, 27 May 2008 18:23:22 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 956028FC15 for ; Tue, 27 May 2008 18:23:22 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m4RINM6w020914 for ; Tue, 27 May 2008 18:23:22 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m4RINMnT020912 for perforce@freebsd.org; Tue, 27 May 2008 18:23:22 GMT (envelope-from sam@freebsd.org) Date: Tue, 27 May 2008 18:23:22 GMT Message-Id: <200805271823.m4RINMnT020912@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 142395 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 May 2008 18:23:23 -0000 http://perforce.freebsd.org/chv.cgi?CH=142395 Change 142395 by sam@sam_ebb on 2008/05/27 18:23:17 Cleanup power handling: o do not put the chip into full sleep in ath_stop as it gains nothing (see below) and causes many parts to hang in ath_detach because we may touch the chip during vap teardown; this should also fix issues with unloading the module o fix comment in ath_resume now that it's been explained that pci cards are powered off on suspend; this is why the keycache is blown away and must be manually resumed (and why it's pointless to put the chip in low power mode on suspend) o add a note in ath_detach to explain ath_hal_detach puts the chip in low power mode; this is useful to know as it means unloading the module will place a pci device in the lowest possible power state o leave an #ifdef notyet marker for powering down the chip when a device is marked down; we can't do that until we handle all the ways the driver may be entered and touch the chip Affected files ... .. //depot/projects/vap/sys/dev/ath/if_ath.c#79 edit Differences ... ==== //depot/projects/vap/sys/dev/ath/if_ath.c#79 (text+ko) ==== @@ -707,7 +707,7 @@ ath_rate_detach(sc->sc_rc); ath_desc_free(sc); ath_tx_cleanup(sc); - ath_hal_detach(sc->sc_ah); + ath_hal_detach(sc->sc_ah); /* NB: sets chip in full sleep */ if_free(ifp); return 0; @@ -1064,6 +1064,11 @@ ath_stop(ifp); else ieee80211_suspend_all(ic); + /* + * NB: don't worry about putting the chip in low power + * mode; pci will power off our socket on suspend and + * cardbus detaches the device. + */ } /* @@ -1097,9 +1102,8 @@ __func__, ifp->if_flags); /* - * NB: the only reliable way to get the chip out of power - * down and ready for reload of the keycache appears - * to be a reset (e.g. just waking the chip doesn't work). + * Must reset the chip before we reload the + * keycache as we were powered down on suspend. */ ath_hal_reset(ah, sc->sc_opmode, &sc->sc_curchan, AH_FALSE, &status); ath_reset_keycache(sc); @@ -1125,6 +1129,7 @@ __func__, ifp->if_flags); ath_stop(ifp); + /* NB: no point powering down chip as we're about to reboot */ } /* @@ -1502,18 +1507,6 @@ ATH_LOCK(sc); ath_stop_locked(ifp); - if (!sc->sc_invalid) { - /* - * Set the chip in full sleep mode. Note that we are - * careful to do this only when bringing the interface - * completely to a stop. When the chip is in this state - * it must be carefully woken up or references to - * registers in the PCI clock domain may freeze the bus - * (and system). This varies by chip and is mostly an - * issue with newer parts that go to sleep more quickly. - */ - ath_hal_setpower(sc->sc_ah, HAL_PM_FULL_SLEEP); - } ATH_UNLOCK(sc); } @@ -6349,8 +6342,14 @@ */ if (!sc->sc_invalid) ath_init(sc); /* XXX lose error */ - } else + } else { ath_stop_locked(ifp); +#ifdef notyet + /* XXX must wakeup in places like ath_vap_delete */ + if (!sc->sc_invalid) + ath_hal_setpower(sc->sc_ah, HAL_PM_FULL_SLEEP); +#endif + } ATH_UNLOCK(sc); break; case SIOCGIFMEDIA: