linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: <kvalo@kernel.org>
Cc: <linux-wireless@vger.kernel.org>, <damon.chen@realtek.com>,
	<phhuang@realtek.com>
Subject: [PATCH 10/11] rtw89: pci: fix PCI doesn't reclaim TX BD properly
Date: Fri, 10 Jun 2022 15:26:09 +0800	[thread overview]
Message-ID: <20220610072610.27095-11-pkshih@realtek.com> (raw)
In-Reply-To: <20220610072610.27095-1-pkshih@realtek.com>

TX BD (TX ring index) and TX WD (WiFi descriptor buffer) are freed
asynchronously. With burst packets, we free TX WD, but the corresponding
TX BD couldn't be freed yet. Then, TX can possibly get stuck due to no
more TX BD.

To avoid this, ignore reclaiming TX BD only if TX WD is no free space,
because at this moment TX BD must have some spaces. Otherwise, we reclaim
TX BD to resolve TX stuck issue.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/pci.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/pci.c b/drivers/net/wireless/realtek/rtw89/pci.c
index fd5d9bde01085..73b3b7e9fe6f5 100644
--- a/drivers/net/wireless/realtek/rtw89/pci.c
+++ b/drivers/net/wireless/realtek/rtw89/pci.c
@@ -952,9 +952,10 @@ static u32 __rtw89_pci_check_and_reclaim_tx_resource(struct rtw89_dev *rtwdev,
 
 	if (wd_cnt == 0 || bd_cnt == 0) {
 		cnt = rtw89_pci_rxbd_recalc(rtwdev, rx_ring);
-		if (!cnt)
+		if (cnt)
+			rtw89_pci_release_tx(rtwdev, rx_ring, cnt);
+		else if (wd_cnt == 0)
 			goto out_unlock;
-		rtw89_pci_release_tx(rtwdev, rx_ring, cnt);
 
 		bd_cnt = rtw89_pci_get_avail_txbd_num(tx_ring);
 		if (bd_cnt == 0)
@@ -965,7 +966,9 @@ static u32 __rtw89_pci_check_and_reclaim_tx_resource(struct rtw89_dev *rtwdev,
 	wd_cnt = wd_ring->curr_num;
 	min_cnt = min(bd_cnt, wd_cnt);
 	if (min_cnt == 0)
-		rtw89_warn(rtwdev, "still no tx resource after reclaim\n");
+		rtw89_debug(rtwdev, rtwpci->low_power ? RTW89_DBG_TXRX : RTW89_DBG_UNEXP,
+			    "still no tx resource after reclaim: wd_cnt=%d bd_cnt=%d\n",
+			    wd_cnt, bd_cnt);
 
 out_unlock:
 	spin_unlock_bh(&rtwpci->trx_lock);
-- 
2.25.1


  parent reply	other threads:[~2022-06-10  7:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10  7:25 [PATCH 00/11] rtw89: add TDLS and various fixes Ping-Ke Shih
2022-06-10  7:26 ` [PATCH 01/11] rtw89: allocate address CAM and MAC ID to TDLS peer Ping-Ke Shih
2022-06-21  6:16   ` [01/11] wifi: " Kalle Valo
2022-06-10  7:26 ` [PATCH 02/11] rtw89: separate BSSID CAM operations Ping-Ke Shih
2022-06-10  7:26 ` [PATCH 03/11] rtw89: allocate BSSID CAM per TDLS peer Ping-Ke Shih
2022-06-10  7:26 ` [PATCH 04/11] rtw89: support TDLS Ping-Ke Shih
2022-06-10  7:26 ` [PATCH 05/11] rtw89: fix potential TX stuck Ping-Ke Shih
2022-06-10  7:26 ` [PATCH 06/11] rtw89: enable VO TX AMPDU Ping-Ke Shih
2022-06-10  7:26 ` [PATCH 07/11] rtw89: add UNEXP debug mask to keep monitor messages unexpected to happen frequently Ping-Ke Shih
2022-06-10  7:26 ` [PATCH 08/11] rtw89: drop invalid TX rate report of legacy rate Ping-Ke Shih
2022-06-10  7:26 ` [PATCH 09/11] rtw89: fix long RX latency in low power mode Ping-Ke Shih
2022-06-10  7:26 ` Ping-Ke Shih [this message]
2022-06-10  7:26 ` [PATCH 11/11] rtw89: disable invalid phy reports for all ICs Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220610072610.27095-11-pkshih@realtek.com \
    --to=pkshih@realtek.com \
    --cc=damon.chen@realtek.com \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=phhuang@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).