ath9k: never read from the AR_IMR_S2 register
PATCH 1/1 ath9k: never read from the AR_IMR_S2 register
The AR_IMR_S2 register sometimes cannot be read correctly. Instead of a valid value, 0xdeadbeef is returned. The driver has been observed writing that value back to AR_IMR_S2 after changing a few bits.
Cache the register value in ah->imrs2_reg and always write chached value to the register.
--- drivers/net/wireless/ath/ath9k/hw.c | 16 +++++++--------- drivers/net/wireless/ath/ath9k/hw.h | 1 + drivers/net/wireless/ath/ath9k/mac.c | 6 ++++-- 3 files changed, 12 insertions(+), 11 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +7 -9
@@ -1151,7 +1151,8 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah, ah->mask_reg |=AR_IMR_MIB ;REG_WRITE (ah,AR_IMR , ah->mask_reg); -REG_WRITE (ah,AR_IMR_S2 ,REG_READ (ah,AR_IMR_S2 ) |AR_IMR_S2_GTT ); + ah->imrs2_reg |=AR_IMR_S2_GTT ; +REG_WRITE (ah,AR_IMR_S2 , ah->imrs2_reg);if (!AR_SREV_9100 (ah)) {REG_WRITE (ah,AR_INTR_SYNC_CAUSE ,0xFFFFFFFF );
@@ -2910,14 +2911,11 @@ enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints)ath_print (common,ATH_DBG_INTERRUPT ,"new IMR 0x%x\n" , mask);REG_WRITE (ah,AR_IMR , mask); - mask =REG_READ (ah,AR_IMR_S2 ) & ~(AR_IMR_S2_TIM | -AR_IMR_S2_DTIM | -AR_IMR_S2_DTIMSYNC | -AR_IMR_S2_CABEND | -AR_IMR_S2_CABTO | -AR_IMR_S2_TSFOOR | -AR_IMR_S2_GTT |AR_IMR_S2_CST ); -REG_WRITE (ah,AR_IMR_S2 , mask | mask2); + ah->imrs2_reg &= ~(AR_IMR_S2_TIM |AR_IMR_S2_DTIM |AR_IMR_S2_DTIMSYNC | +AR_IMR_S2_CABEND |AR_IMR_S2_CABTO | +AR_IMR_S2_TSFOOR |AR_IMR_S2_GTT |AR_IMR_S2_CST ); + ah->imrs2_reg |= mask2; +REG_WRITE (ah,AR_IMR_S2 , ah->imrs2_reg); ah->mask_reg = ints;if (!(pCap->hw_caps &ATH9K_HW_CAP_AUTOSLEEP )) {
drivers/net/wireless/ath/ath9k/hw.h +1 -0
@@ -479,6 +479,7 @@ struct ath_hw {int16_t curchan_rad_index;u32 mask_reg; +u32 imrs2_reg;u32 txok_interrupt_mask;u32 txerr_interrupt_mask;u32 txdesc_interrupt_mask;
drivers/net/wireless/ath/ath9k/mac.c +4 -2
@@ -31,8 +31,10 @@ static void ath9k_hw_set_txq_interrupts(struct ath_hw *ah,REG_WRITE (ah,AR_IMR_S1 ,SM (ah->txerr_interrupt_mask,AR_IMR_S1_QCU_TXERR ) |SM (ah->txeol_interrupt_mask,AR_IMR_S1_QCU_TXEOL )); -REG_RMW_FIELD (ah,AR_IMR_S2 , -AR_IMR_S2_QCU_TXURN , ah->txurn_interrupt_mask); + + ah->imrs2_reg &= ~AR_IMR_S2_QCU_TXURN ; + ah->imrs2_reg |= (ah->txurn_interrupt_mask &AR_IMR_S2_QCU_TXURN ); +REG_WRITE (ah,AR_IMR_S2 , ah->imrs2_reg); }u32 ath9k_hw_gettxbuf (struct ath_hw *ah,u32 q)
Quoted 8 lines · Pavel Roskin
The
AR_IMR_S2register sometimes cannot be read correctly. Instead of a valid value,0xdeadbeefis returned. The driver has been observed writing that value back toAR_IMR_S2after changing a few bits.Cache the register value in
ah->imrs2_regand always write chached value to the register.Signed-off-by Pavel Roskin <[email protected]>
What hardware was this seen with ? Can you enable PS debug to see if perhaps PS is left enabled when we try to configure hardware. When we touch some registers PS needs to be enabled, this could be a PS issue, unless of course you see this also when PS is disabled by default.
Luis
Quoted 8 lines · Luis R. Rodriguez
Quoted 7 lines · Pavel Roskin
The
AR_IMR_S2register sometimes cannot be read correctly. Instead of a valid value,0xdeadbeefis returned. The driver has been observed writing that value back toAR_IMR_S2after changing a few bits.Cache the register value in
ah->imrs2_regand always write chached value to the register.
Quoted 6 lines
Quoted 1 line
Signed-off-by Pavel Roskin <[email protected]>What hardware was this seen with ? Can you enable PS debug to see if perhaps PS is left enabled when we try to configure hardware. When we touch some registers PS needs to be enabled, this could be a PS issue, unless of course you see this also when PS is disabled by default.
I saw reading 0xdeadbeef from AR_IMR_S2 on AR5416 (CardBus D-Link DWA-645) and on AR9220 (miniPCI Ubiquiti SR71-12). I can confirm it on AR9285 (ExpressCard) now.
Power saving is disabled by default (and never enabled) on all systems where I checked for reading 0xdeadbeef.
There are other cases where 0xdeadbeef is read from other registers. For instance, the "wiphy" file on debugfs is full of that stuff when the interface is in managed mode and not associated.
cat /sys/kernel/debug/ath9k/phy3/wiphy
primary: phy3 (ACTIVE chan=0 ht=0)
addr: ef:be:ad:de:ef:be
addrmask: ef:be:ad:de:ef:be
However, the problem with AR_IMR_S2 is that a derivative of 0xdeadbeef is written back to the register (0xdeadbc00 is written in my tests). I don't know of any observable negative consequences of that fact, but I think it's better not to set bits we don't know about.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 32 lines · Pavel Roskin
Quoted 8 lines · Luis R. Rodriguez
Quoted 7 lines · Pavel Roskin
The
AR_IMR_S2register sometimes cannot be read correctly. Instead of a valid value,0xdeadbeefis returned. The driver has been observed writing that value back toAR_IMR_S2after changing a few bits.Cache the register value in
ah->imrs2_regand always write chached value to the register.Quoted 6 lines
Quoted 1 line
Signed-off-by Pavel Roskin <[email protected]>What hardware was this seen with ? Can you enable PS debug to see if perhaps PS is left enabled when we try to configure hardware. When we touch some registers PS needs to be enabled, this could be a PS issue, unless of course you see this also when PS is disabled by default.
I saw reading
0xdeadbeeffromAR_IMR_S2on AR5416 (CardBus D-Link DWA-645) and on AR9220 (miniPCI Ubiquiti SR71-12). I can confirm it on AR9285 (ExpressCard) now.Power saving is disabled by default (and never enabled) on all systems where I checked for reading
0xdeadbeef.There are other cases where
0xdeadbeefis read from other registers. For instance, the "wiphy" file on debugfs is full of that stuff when the interface is in managed mode and not associated.cat
/sys/kernel/debug/ath9k/phy3/wiphy
primary: phy3 (ACTIVE chan=0 ht=0)
addr: ef:be:ad:de:ef:be
addrmask: ef:be:ad:de:ef:be
Quoted 4 lines
However, the problem with
AR_IMR_S2is that a derivative of0xdeadbeefis written back to the register (0xdeadbc00is written in my tests). I don't know of any observable negative consequences of that fact, but I think it's better not to set bits we don't know about.
Thanks for the details, indeed this seems reasonable.
Luis