wifi: ath9k: fix AR9003 mac hardware hang check register offset calculation
Subsystems (3)
PATCH 1/1 wifi: ath9k: fix AR9003 mac hardware hang check register offset calculation
Fix ath9k_hw_verify_hang()/ar9003_hw_detect_mac_hang() register offset calculation (do not overflow the shift for the second register/queues above five, use the register layout described in the comments above ath9k_hw_verify_hang() instead).
---
Notes:
- tested with MikroTik R11e-5HnD/Atheros AR9300 Rev:4 (lspci: 168c:0033 Qualcomm Atheros AR958x 802.11abgn Wireless Network Adapter (rev 01)) card
--- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_hw.c +18 -9
@@ -1099,17 +1099,22 @@ static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) {u32 dma_dbg_chain, dma_dbg_complete;u8 dcu_chain_state, dcu_complete_state; +unsigned int dbg_reg, reg_offset;int i; -for (i =0 ; i <NUM_STATUS_READS ; i++) { -if (queue <6 ) - dma_dbg_chain =REG_READ (ah,AR_DMADBG_4 ); -else - dma_dbg_chain =REG_READ (ah,AR_DMADBG_5 ); +if (queue <6 ) { + dbg_reg =AR_DMADBG_4 ; + reg_offset = i *5 ; + }else { + dbg_reg =AR_DMADBG_5 ; + reg_offset = (i -6 ) *5 ; + } +for (i =0 ; i <NUM_STATUS_READS ; i++) { + dma_dbg_chain =REG_READ (ah, dbg_reg); dma_dbg_complete =REG_READ (ah,AR_DMADBG_6 ); - dcu_chain_state = (dma_dbg_chain >> (5 * queue)) &0x1f ; + dcu_chain_state = (dma_dbg_chain >> reg_offset) &0x1f ; dcu_complete_state = dma_dbg_complete &0x3 ;if ((dcu_chain_state !=0x6 ) || (dcu_complete_state !=0x1 ))
@@ -1128,6 +1133,7 @@ static bool ar9003_hw_detect_mac_hang(struct ath_hw *ah)u8 dcu_chain_state, dcu_complete_state;bool dcu_wait_frdone = false;unsigned long chk_dcu =0 ; +unsigned int reg_offset;unsigned int i =0 ; dma_dbg_4 =REG_READ (ah,AR_DMADBG_4 );
@@ -1139,12 +1145,15 @@ static bool ar9003_hw_detect_mac_hang(struct ath_hw *ah) goto exit;for (i =0 ; i <ATH9K_NUM_TX_QUEUES ; i++) { -if (i <6 ) +if (i <6 ) { chk_dbg = dma_dbg_4; -else + reg_offset = i *5 ; + }else { chk_dbg = dma_dbg_5; + reg_offset = (i -6 ) *5 ; + } - dcu_chain_state = (chk_dbg >> (5 * i)) &0x1f ; + dcu_chain_state = (chk_dbg >> reg_offset) &0x1f ;if (dcu_chain_state ==0x6 ) { dcu_wait_frdone = true; chk_dcu |=BIT (i);
Signature · 1 line
2.40.0
Quoted 10 lines · Peter Seiderer
Fix ath9k_hw_verify_hang()/ar9003_hw_detect_mac_hang() register offset calculation (do not overflow the shift for the second register/queues above five, use the register layout described in the comments above
ath9k_hw_verify_hang()instead).Fixes 222e04830ff0 ("ath9k: Fix MAC HW hang check for AR9003")
Thanks for writing up the patch!
Quoted 28 lines · Peter Seiderer
Fix ath9k_hw_verify_hang()/ar9003_hw_detect_mac_hang() register offset calculation (do not overflow the shift for the second register/queues above five, use the register layout described in the comments above
ath9k_hw_verify_hang()instead).Fixes 222e04830ff0 ("ath9k: Fix MAC HW hang check for AR9003")Reported-by Gregg Wonderly <[email protected]>Signed-off-by Peter Seiderer <[email protected]>---
Notes:
- tested with MikroTik R11e-5HnD/Atheros AR9300 Rev:4 (lspci: 168c:0033 Qualcomm Atheros AR958x 802.11abgn Wireless Network Adapter (rev 01)) card--- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/net/wireless/ath/ath9k/ar9003_hw.c +1
-0@@ -1099,17 +1099,22 @@ static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) {u32 dma_dbg_chain, dma_dbg_complete;u8 dcu_chain_state, dcu_complete_state; +unsigned int dbg_reg, reg_offset;
drivers/net/wireless/ath/ath9k/ar9003_hw.c static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) · line 1107
Quoted 10 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +3
-5int i; -for (i =0 ; i <NUM_STATUS_READS ; i++) { -if (queue <6 ) - dma_dbg_chain =REG_READ (ah,AR_DMADBG_4 ); -else - dma_dbg_chain =REG_READ (ah,AR_DMADBG_5 ); +if (queue <6 ) { + dbg_reg =AR_DMADBG_4 ; + reg_offset = i *5 ;
Hi Peter,
unless my eyes are deceiving me, i is not initialised here.
drivers/net/wireless/ath/ath9k/ar9003_hw.c static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) · line 1110
Quoted 3 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +3
-0+ }else { + dbg_reg =AR_DMADBG_5 ; + reg_offset = (i -6 ) *5 ;
Or here.
Quoted 11 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +4
-1+ } +for (i =0 ; i <NUM_STATUS_READS ; i++) { + dma_dbg_chain =REG_READ (ah, dbg_reg); dma_dbg_complete =REG_READ (ah,AR_DMADBG_6 ); - dcu_chain_state = (dma_dbg_chain >> (5 * queue)) &0x1f ; + dcu_chain_state = (dma_dbg_chain >> reg_offset) &0x1f ; dcu_complete_state = dma_dbg_complete &0x3 ;if ((dcu_chain_state !=0x6 ) || (dcu_complete_state !=0x1 ))
Hello Simon,
Quoted 42 lines · Simon Horman
Quoted 28 lines · Peter Seiderer
Fix ath9k_hw_verify_hang()/ar9003_hw_detect_mac_hang() register offset calculation (do not overflow the shift for the second register/queues above five, use the register layout described in the comments above
ath9k_hw_verify_hang()instead).Fixes 222e04830ff0 ("ath9k: Fix MAC HW hang check for AR9003")Reported-by Gregg Wonderly <[email protected]>Signed-off-by Peter Seiderer <[email protected]>---
Notes:
- tested with MikroTik R11e-5HnD/Atheros AR9300 Rev:4 (lspci: 168c:0033 Qualcomm Atheros AR958x 802.11abgn Wireless Network Adapter (rev 01)) card--- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/net/wireless/ath/ath9k/ar9003_hw.c +1
-0@@ -1099,17 +1099,22 @@ static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) {u32 dma_dbg_chain, dma_dbg_complete;u8 dcu_chain_state, dcu_complete_state; +unsigned int dbg_reg, reg_offset;drivers/net/wireless/ath/ath9k/ar9003_hw.c static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) · line 1107
Quoted 10 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +3
-5int i; -for (i =0 ; i <NUM_STATUS_READS ; i++) { -if (queue <6 ) - dma_dbg_chain =REG_READ (ah,AR_DMADBG_4 ); -else - dma_dbg_chain =REG_READ (ah,AR_DMADBG_5 ); +if (queue <6 ) { + dbg_reg =AR_DMADBG_4 ; + reg_offset = i *5 ;Hi Peter,
Quoted 7 lines
unless my eyes are deceiving me, i is not initialised here.
drivers/net/wireless/ath/ath9k/ar9003_hw.c static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) · line 1110
Quoted 3 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +3
-0+ }else { + dbg_reg =AR_DMADBG_5 ; + reg_offset = (i -6 ) *5 ;Or here.
You are absolutely right, it should be queue instead if i here..., will provide (and test) an updated version of the patch..., many thanks for review!
Regards,
Peter
Quoted 12 lines
Quoted 12 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +4
-1+ } +for (i =0 ; i <NUM_STATUS_READS ; i++) { + dma_dbg_chain =REG_READ (ah, dbg_reg); dma_dbg_complete =REG_READ (ah,AR_DMADBG_6 ); - dcu_chain_state = (dma_dbg_chain >> (5 * queue)) &0x1f ; + dcu_chain_state = (dma_dbg_chain >> reg_offset) &0x1f ; dcu_complete_state = dma_dbg_complete &0x3 ;if ((dcu_chain_state !=0x6 ) || (dcu_complete_state !=0x1 ))
Toke Høiland-Jørgensen
maintainerQuoted 42 lines · Simon Horman
Quoted 28 lines · Peter Seiderer
Fix ath9k_hw_verify_hang()/ar9003_hw_detect_mac_hang() register offset calculation (do not overflow the shift for the second register/queues above five, use the register layout described in the comments above
ath9k_hw_verify_hang()instead).Fixes 222e04830ff0 ("ath9k: Fix MAC HW hang check for AR9003")Reported-by Gregg Wonderly <[email protected]>Signed-off-by Peter Seiderer <[email protected]>---
Notes:
- tested with MikroTik R11e-5HnD/Atheros AR9300 Rev:4 (lspci: 168c:0033 Qualcomm Atheros AR958x 802.11abgn Wireless Network Adapter (rev 01)) card--- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/net/wireless/ath/ath9k/ar9003_hw.c +1
-0@@ -1099,17 +1099,22 @@ static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) {u32 dma_dbg_chain, dma_dbg_complete;u8 dcu_chain_state, dcu_complete_state; +unsigned int dbg_reg, reg_offset;drivers/net/wireless/ath/ath9k/ar9003_hw.c static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) · line 1107
Quoted 10 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +3
-5int i; -for (i =0 ; i <NUM_STATUS_READS ; i++) { -if (queue <6 ) - dma_dbg_chain =REG_READ (ah,AR_DMADBG_4 ); -else - dma_dbg_chain =REG_READ (ah,AR_DMADBG_5 ); +if (queue <6 ) { + dbg_reg =AR_DMADBG_4 ; + reg_offset = i *5 ;Hi Peter,
Quoted 1 line
unless my eyes are deceiving me, i is not initialised here.
Nice catch! Hmm, I wonder why my test compile didn't complain about that? Or maybe it did and I overlooked it? Anyway, Kalle, I already delegated this patch to you in patchwork, so please drop it and I'll try to do better on reviewing the next one :)
-Toke
Quoted 44 lines · Toke Høiland-Jørgensen
Quoted 42 lines · Simon Horman
Quoted 28 lines · Peter Seiderer
Fix ath9k_hw_verify_hang()/ar9003_hw_detect_mac_hang() register offset calculation (do not overflow the shift for the second register/queues above five, use the register layout described in the comments above
ath9k_hw_verify_hang()instead).Fixes 222e04830ff0 ("ath9k: Fix MAC HW hang check for AR9003")Reported-by Gregg Wonderly <[email protected]>Signed-off-by Peter Seiderer <[email protected]>---
Notes:
- tested with MikroTik R11e-5HnD/Atheros AR9300 Rev:4 (lspci: 168c:0033 Qualcomm Atheros AR958x 802.11abgn Wireless Network Adapter (rev 01)) card--- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/net/wireless/ath/ath9k/ar9003_hw.c +1
-0@@ -1099,17 +1099,22 @@ static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) {u32 dma_dbg_chain, dma_dbg_complete;u8 dcu_chain_state, dcu_complete_state; +unsigned int dbg_reg, reg_offset;drivers/net/wireless/ath/ath9k/ar9003_hw.c static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) · line 1107
Quoted 10 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +3
-5int i; -for (i =0 ; i <NUM_STATUS_READS ; i++) { -if (queue <6 ) - dma_dbg_chain =REG_READ (ah,AR_DMADBG_4 ); -else - dma_dbg_chain =REG_READ (ah,AR_DMADBG_5 ); +if (queue <6 ) { + dbg_reg =AR_DMADBG_4 ; + reg_offset = i *5 ;Hi Peter,
Quoted 6 lines
Quoted 1 line
unless my eyes are deceiving me, i is not initialised here.
Nice catch! Hmm, I wonder why my test compile didn't complain about that? Or maybe it did and I overlooked it? Anyway, Kalle, I already delegated this patch to you in patchwork, so please drop it and I'll try to do better on reviewing the next one :)
No warning reported because of Makefile:
1038 # Enabled with W=2, disabled by default as noisy 1039 ifdef CONFIG_CC_IS_GCC
1040 KBUILD_CFLAGS += -Wno-maybe-uninitialized 1041 endif
Regards,
Peter
Quoted 2 lines
-Toke
Toke Høiland-Jørgensen
maintainerQuoted 53 lines · Peter Seiderer
Quoted 44 lines · Toke Høiland-Jørgensen
Quoted 42 lines · Simon Horman
Quoted 28 lines · Peter Seiderer
Fix ath9k_hw_verify_hang()/ar9003_hw_detect_mac_hang() register offset calculation (do not overflow the shift for the second register/queues above five, use the register layout described in the comments above
ath9k_hw_verify_hang()instead).Fixes 222e04830ff0 ("ath9k: Fix MAC HW hang check for AR9003")Reported-by Gregg Wonderly <[email protected]>Signed-off-by Peter Seiderer <[email protected]>---
Notes:
- tested with MikroTik R11e-5HnD/Atheros AR9300 Rev:4 (lspci: 168c:0033 Qualcomm Atheros AR958x 802.11abgn Wireless Network Adapter (rev 01)) card--- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/net/wireless/ath/ath9k/ar9003_hw.c +1
-0@@ -1099,17 +1099,22 @@ static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) {u32 dma_dbg_chain, dma_dbg_complete;u8 dcu_chain_state, dcu_complete_state; +unsigned int dbg_reg, reg_offset;drivers/net/wireless/ath/ath9k/ar9003_hw.c static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) · line 1107
Quoted 10 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +3
-5int i; -for (i =0 ; i <NUM_STATUS_READS ; i++) { -if (queue <6 ) - dma_dbg_chain =REG_READ (ah,AR_DMADBG_4 ); -else - dma_dbg_chain =REG_READ (ah,AR_DMADBG_5 ); +if (queue <6 ) { + dbg_reg =AR_DMADBG_4 ; + reg_offset = i *5 ;Hi Peter,
Quoted 6 lines
Quoted 1 line
unless my eyes are deceiving me, i is not initialised here.
Nice catch! Hmm, I wonder why my test compile didn't complain about that? Or maybe it did and I overlooked it? Anyway, Kalle, I already delegated this patch to you in patchwork, so please drop it and I'll try to do better on reviewing the next one :)
Quoted 6 lines
No warning reported because of
Makefile:1038 # Enabled with W=2, disabled by default as noisy 1039 ifdef
CONFIG_CC_IS_GCC
1040KBUILD_CFLAGS+= -Wno-maybe-uninitialized 1041 endif
Ah, I see! Right then, that explains it :)
-Toke
Quoted 13 lines · Toke Høiland-Jørgensen
Quoted 11 lines · Simon Horman
drivers/net/wireless/ath/ath9k/ar9003_hw.c static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) · line 1107
Quoted 8 lines
drivers/net/wireless/ath/ath9k/ar9003_hw.c +3
-5-for (i =0 ; i <NUM_STATUS_READS ; i++) { -if (queue <6 ) - dma_dbg_chain =REG_READ (ah,AR_DMADBG_4 ); -else - dma_dbg_chain =REG_READ (ah,AR_DMADBG_5 ); +if (queue <6 ) { + dbg_reg =AR_DMADBG_4 ; + reg_offset = i *5 ;Hi Peter,
Quoted 5 lines
Quoted 1 line
unless my eyes are deceiving me, i is not initialised here.
Nice catch! Hmm, I wonder why my test compile didn't complain about that? Or maybe it did and I overlooked it? Anyway, Kalle, I already delegated this patch to you in patchwork, so please drop it
Ok, will drop.
Quoted 1 line
and I'll try to do better on reviewing the next one :)
No worries, reviewing is hard and things always slip past. But great that we now have more people reviewing, thanks Simon for catching this.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches