diff mbox

[16/18] ath9k: use REG_RMW and rmw buffer in ath9k_hw_4k_set_gain

Message ID 1426855138-6121-17-git-send-email-linux@rempel-privat.de (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show

Commit Message

Oleksij Rempel March 20, 2015, 12:38 p.m. UTC
it is possible to reduce time needed for this function
by rplacing REG_WRITE with REG_RMW (plus dummy 0) and putt all commands
in same buffer.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
 drivers/net/wireless/ath/ath9k/eeprom_4k.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Comments

Felix Fietkau March 20, 2015, 1 p.m. UTC | #1
On 2015-03-20 13:38, Oleksij Rempel wrote:
> it is possible to reduce time needed for this function
> by rplacing REG_WRITE with REG_RMW (plus dummy 0) and putt all commands
> in same buffer.
> 
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
>  drivers/net/wireless/ath/ath9k/eeprom_4k.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
> index 291c1d1..56621be 100644
> --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
> +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
> @@ -772,15 +772,16 @@ static void ath9k_hw_4k_set_gain(struct ath_hw *ah,
>  				 struct ar5416_eeprom_4k *eep,
>  				 u8 txRxAttenLocal)
>  {
> -	REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0,
> -		  pModal->antCtrlChain[0]);
> +	ENABLE_REG_RMW_BUFFER(ah);
> +	REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0,
> +		pModal->antCtrlChain[0], 0);
How about combining the WRITE/RMW buffering in ath9k_htc (automatically
deciding whether to use RMW or WRITE for the whole transaction), instead
of quirky looking REG_WRITE to REG_RMW conversions?

> -	REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0),
> -		  (REG_READ(ah, AR_PHY_TIMING_CTRL4(0)) &
> -		   ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF |
> -		     AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) |
> -		  SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
> -		  SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF));
> +	REG_RMW(ah, AR_PHY_TIMING_CTRL4(0),
> +		(REG_READ(ah, AR_PHY_TIMING_CTRL4(0)) &
> +		 ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF |
> +		   AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) |
> +		SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
> +		SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF), 0);
If you translate it to REG_RMW, you should get rid of the REG_READ part.

- Felix
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Oleksij Rempel March 21, 2015, 5:25 a.m. UTC | #2
Am 20.03.2015 um 14:00 schrieb Felix Fietkau:
> On 2015-03-20 13:38, Oleksij Rempel wrote:
>> it is possible to reduce time needed for this function
>> by rplacing REG_WRITE with REG_RMW (plus dummy 0) and putt all commands
>> in same buffer.
>>
>> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
>> ---
>>  drivers/net/wireless/ath/ath9k/eeprom_4k.c | 18 ++++++++++--------
>>  1 file changed, 10 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
>> index 291c1d1..56621be 100644
>> --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
>> +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
>> @@ -772,15 +772,16 @@ static void ath9k_hw_4k_set_gain(struct ath_hw *ah,
>>  				 struct ar5416_eeprom_4k *eep,
>>  				 u8 txRxAttenLocal)
>>  {
>> -	REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0,
>> -		  pModal->antCtrlChain[0]);
>> +	ENABLE_REG_RMW_BUFFER(ah);
>> +	REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0,
>> +		pModal->antCtrlChain[0], 0);
> How about combining the WRITE/RMW buffering in ath9k_htc (automatically
> deciding whether to use RMW or WRITE for the whole transaction), instead
> of quirky looking REG_WRITE to REG_RMW conversions?

Yea, i was thinking about this too, but decided to go readable way. Not
to produce unexpected behaviour of WRITE or READ cmd.

>> -	REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0),
>> -		  (REG_READ(ah, AR_PHY_TIMING_CTRL4(0)) &
>> -		   ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF |
>> -		     AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) |
>> -		  SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
>> -		  SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF));
>> +	REG_RMW(ah, AR_PHY_TIMING_CTRL4(0),
>> +		(REG_READ(ah, AR_PHY_TIMING_CTRL4(0)) &
>> +		 ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF |
>> +		   AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) |
>> +		SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
>> +		SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF), 0);
> If you translate it to REG_RMW, you should get rid of the REG_READ part.

Ok, thank you. I'll take a look.
diff mbox

Patch

diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
index 291c1d1..56621be 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
@@ -772,15 +772,16 @@  static void ath9k_hw_4k_set_gain(struct ath_hw *ah,
 				 struct ar5416_eeprom_4k *eep,
 				 u8 txRxAttenLocal)
 {
-	REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0,
-		  pModal->antCtrlChain[0]);
+	ENABLE_REG_RMW_BUFFER(ah);
+	REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0,
+		pModal->antCtrlChain[0], 0);
 
-	REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0),
-		  (REG_READ(ah, AR_PHY_TIMING_CTRL4(0)) &
-		   ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF |
-		     AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) |
-		  SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
-		  SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF));
+	REG_RMW(ah, AR_PHY_TIMING_CTRL4(0),
+		(REG_READ(ah, AR_PHY_TIMING_CTRL4(0)) &
+		 ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF |
+		   AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) |
+		SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
+		SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF), 0);
 
 	if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
 	    AR5416_EEP_MINOR_VER_3) {
@@ -819,6 +820,7 @@  static void ath9k_hw_4k_set_gain(struct ath_hw *ah,
 		      AR9280_PHY_RXGAIN_TXRX_ATTEN, txRxAttenLocal);
 	REG_RMW_FIELD(ah, AR_PHY_RXGAIN + 0x1000,
 		      AR9280_PHY_RXGAIN_TXRX_MARGIN, pModal->rxTxMarginCh[0]);
+	REG_RMW_BUFFER_FLUSH(ah);
 }
 
 /*