Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 May 2008 18:23:22 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 142395 for review
Message-ID:  <200805271823.m4RINMnT020912@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805271823.m4RINMnT020912>