svn commit: r204521 - in head/sys/dev/ath/ath_hal: . ar5212 ar5416

Rui Paulo rpaulo at FreeBSD.org
Mon Mar 1 17:04:19 UTC 2010


Author: rpaulo
Date: Mon Mar  1 17:04:19 2010
New Revision: 204521
URL: http://svn.freebsd.org/changeset/base/204521

Log:
  Properly setup the TX FIFO threshold for AR5416 based chipsets,
  including the AR9285. This seems to fix some users's problems.
  
  Submitted by:	Jorge Boncompte [DTI2] <jorge at dti2.net>

Modified:
  head/sys/dev/ath/ath_hal/ah_internal.h
  head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c
  head/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c
  head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
  head/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c
  head/sys/dev/ath/ath_hal/ar5416/ar9285_attach.c

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Mon Mar  1 16:52:11 2010	(r204520)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Mon Mar  1 17:04:19 2010	(r204521)
@@ -281,6 +281,8 @@ struct ath_hal_private {
 	uint16_t	ah_maxPowerLevel;	/* calculated max tx power */
 	u_int		ah_tpScale;		/* tx power scale factor */
 	uint32_t	ah_11nCompat;		/* 11n compat controls */
+	uint8_t		ah_txtrig_level;	/* current Tx trigger level */
+	uint8_t		ah_max_txtrig_level;	/* max tx trigger level */
 
 	/*
 	 * State for regulatory domain handling.

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c	Mon Mar  1 16:52:11 2010	(r204520)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c	Mon Mar  1 17:04:19 2010	(r204521)
@@ -149,6 +149,9 @@ static const struct ath_hal_private ar52
 	.ah_getInterrupts		= ar5212GetInterrupts,
 	.ah_setInterrupts		= ar5212SetInterrupts },
 
+	.ah_txtrig_level		= INIT_TX_FIFO_THRESHOLD,
+	.ah_max_txtrig_level		= MAX_TX_FIFO_THRESHOLD,
+
 	.ah_getChannelEdges		= ar5212GetChannelEdges,
 	.ah_getWirelessModes		= ar5212GetWirelessModes,
 	.ah_eepromRead			= ar5212EepromRead,

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c	Mon Mar  1 16:52:11 2010	(r204520)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c	Mon Mar  1 17:04:19 2010	(r204521)
@@ -48,16 +48,20 @@ ar5212UpdateTxTrigLevel(struct ath_hal *
 	uint32_t txcfg, curLevel, newLevel;
 	HAL_INT omask;
 
+	if (AH_PRIVATE(ah)->ah_txtrig_level >=
+	    AH_PRIVATE(ah)->ah_max_txtrig_level)
+		return AH_FALSE;
+
 	/*
 	 * Disable interrupts while futzing with the fifo level.
 	 */
-	omask = ar5212SetInterrupts(ah, ahp->ah_maskReg &~ HAL_INT_GLOBAL);
+	omask = ah->ah_setInterrupts(ah, ahp->ah_maskReg &~ HAL_INT_GLOBAL);
 
 	txcfg = OS_REG_READ(ah, AR_TXCFG);
 	curLevel = MS(txcfg, AR_FTRIG);
 	newLevel = curLevel;
 	if (bIncTrigLevel) {		/* increase the trigger level */
-		if (curLevel < MAX_TX_FIFO_THRESHOLD)
+		if (curLevel < AH_PRIVATE(ah)->ah_max_txtrig_level)
 			newLevel++;
 	} else if (curLevel > MIN_TX_FIFO_THRESHOLD)
 		newLevel--;
@@ -66,8 +70,10 @@ ar5212UpdateTxTrigLevel(struct ath_hal *
 		OS_REG_WRITE(ah, AR_TXCFG,
 			(txcfg &~ AR_FTRIG) | SM(newLevel, AR_FTRIG));
 
+	AH_PRIVATE(ah)->ah_txtrig_level = newLevel;
+
 	/* re-enable chip interrupts */
-	ar5212SetInterrupts(ah, omask);
+	ah->ah_setInterrupts(ah, omask);
 
 	return (newLevel != curLevel);
 }

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Mon Mar  1 16:52:11 2010	(r204520)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Mon Mar  1 17:04:19 2010	(r204521)
@@ -454,7 +454,10 @@ ar5416InitDMA(struct ath_hal *ah)
 	OS_REG_WRITE(ah, AR_RXCFG, 
 		(OS_REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_DMASZ_MASK) | AR_RXCFG_DMASZ_128B);
 
-	/* XXX restore TX trigger level */
+	/* restore TX trigger level */
+	OS_REG_WRITE(ah, AR_TXCFG,
+		(OS_REG_READ(ah, AR_TXCFG) &~ AR_FTRIG) |
+		    SM(AH_PRIVATE(ah)->ah_txtrig_level, AR_FTRIG));
 
 	/*
 	 * Setup receive FIFO threshold to hold off TX activities

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c	Mon Mar  1 16:52:11 2010	(r204520)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c	Mon Mar  1 17:04:19 2010	(r204521)
@@ -568,7 +568,8 @@ ar5416ProcTxDesc(struct ath_hal *ah,
 
 	/* handle tx trigger level changes internally */
 	if ((ts->ts_status & HAL_TXERR_FIFO) ||
-	    (ts->ts_flags & (HAL_TX_DATA_UNDERRUN | HAL_TX_DELIM_UNDERRUN)))
+	    (ts->ts_flags & HAL_TX_DATA_UNDERRUN) ||
+	    (ts->ts_flags & HAL_TX_DELIM_UNDERRUN))
 		ar5212UpdateTxTrigLevel(ah, AH_TRUE);
 
 	return HAL_OK;

Modified: head/sys/dev/ath/ath_hal/ar5416/ar9285_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar9285_attach.c	Mon Mar  1 16:52:11 2010	(r204520)
+++ head/sys/dev/ath/ath_hal/ar5416/ar9285_attach.c	Mon Mar  1 17:04:19 2010	(r204521)
@@ -121,6 +121,8 @@ ar9285Attach(uint16_t devid, HAL_SOFTC s
 	AH5416(ah)->ah_writeIni		= ar9285WriteIni;
 	AH5416(ah)->ah_rx_chainmask	= AR9285_DEFAULT_RXCHAINMASK;
 	AH5416(ah)->ah_tx_chainmask	= AR9285_DEFAULT_TXCHAINMASK;
+	
+	AH_PRIVATE(ah)->ah_max_txtrig_level = MAX_TX_FIFO_THRESHOLD >> 1;
 
 	if (!ar5416SetResetReg(ah, HAL_RESET_POWER_ON)) {
 		/* reset chip */


More information about the svn-src-head mailing list