linux-brain/drivers/net/wireless/ath
Miaoqing Pan e37674e1a4 ath10k: fix wmi mgmt tx queue full due to race condition
[ Upstream commit b55379e343a3472c35f4a1245906db5158cab453 ]

Failed to transmit wmi management frames:

[84977.840894] ath10k_snoc a000000.wifi: wmi mgmt tx queue is full
[84977.840913] ath10k_snoc a000000.wifi: failed to transmit packet, dropping: -28
[84977.840924] ath10k_snoc a000000.wifi: failed to submit frame: -28
[84977.840932] ath10k_snoc a000000.wifi: failed to transmit frame: -28

This issue is caused by race condition between skb_dequeue and
__skb_queue_tail. The queue of ‘wmi_mgmt_tx_queue’ is protected by a
different lock: ar->data_lock vs list->lock, the result is no protection.
So when ath10k_mgmt_over_wmi_tx_work() and ath10k_mac_tx_wmi_mgmt()
running concurrently on different CPUs, there appear to be a rare corner
cases when the queue length is 1,

  CPUx (skb_deuque)			CPUy (__skb_queue_tail)
					next=list
					prev=list
  struct sk_buff *skb = skb_peek(list);	WRITE_ONCE(newsk->next, next);
  WRITE_ONCE(list->qlen, list->qlen - 1);WRITE_ONCE(newsk->prev, prev);
  next       = skb->next;		WRITE_ONCE(next->prev, newsk);
  prev       = skb->prev;		WRITE_ONCE(prev->next, newsk);
  skb->next  = skb->prev = NULL;	list->qlen++;
  WRITE_ONCE(next->prev, prev);
  WRITE_ONCE(prev->next, next);

If the instruction ‘next = skb->next’ is executed before
‘WRITE_ONCE(prev->next, newsk)’, newsk will be lost, as CPUx get the
old ‘next’ pointer, but the length is still added by one. The final
result is the length of the queue will reach the maximum value but
the queue is empty.

So remove ar->data_lock, and use 'skb_queue_tail' instead of
'__skb_queue_tail' to prevent the potential race condition. Also switch
to use skb_queue_len_lockless, in case we queue a few SKBs simultaneously.

Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1.c2-00033-QCAHLSWMTPLZ-1

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1608618887-8857-1-git-send-email-miaoqing@codeaurora.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-03-07 12:20:45 +01:00
..
ar5523 ar5523: Add USB ID of SMCWUSBT-G2 wireless adapter 2020-10-01 13:17:29 +02:00
ath5k PCI: Move ASPM declarations to linux/pci.h 2019-08-28 08:28:39 -05:00
ath6kl ath6kl: wmi: prevent a shift wrapping bug in ath6kl_wmi_delete_pstream_cmd() 2020-10-29 09:57:41 +01:00
ath9k ath9k: fix data bus crash when setting nf_override via debugfs 2021-03-04 10:26:16 +01:00
ath10k ath10k: fix wmi mgmt tx queue full due to race condition 2021-03-07 12:20:45 +01:00
carl9170 carl9170: remove P2P_GO support 2020-06-22 09:31:18 +02:00
wcn36xx wcn36xx: Fix reported 802.11n rx_highest rate wcn3660/wcn3680 2020-10-29 09:57:35 +01:00
wil6210 wil6210: select CONFIG_CRC32 2021-01-17 14:05:36 +01:00
ath.h
debug.c
dfs_pattern_detector.c ath: DFS JP domain W56 fixed pulse type 3 RADAR detection 2019-04-29 17:58:51 +03:00
dfs_pattern_detector.h ath: add support to get the detected radar specifications 2018-05-25 13:15:21 +03:00
dfs_pri_detector.c
dfs_pri_detector.h ath: add support to get the detected radar specifications 2018-05-25 13:15:21 +03:00
hw.c
Kconfig drivers: net: Fix Kconfig indentation 2019-09-26 08:56:17 +02:00
key.c
main.c
Makefile ath: fix SPDX tags 2019-06-26 18:11:06 +03:00
reg.h
regd_common.h ath: regd: add extra US coutry codes 2019-02-07 17:02:19 +02:00
regd.c
regd.h ath: drop duplicated define 2019-04-29 17:55:53 +03:00
spectral_common.h
trace.c
trace.h