]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: refine rtw89_core_tx_wait_complete()
authorFedor Pchelkin <pchelkin@ispras.ru>
Tue, 4 Nov 2025 13:57:11 +0000 (16:57 +0300)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 6 Nov 2025 06:28:42 +0000 (14:28 +0800)
Pass TX status value directly into rtw89_core_tx_wait_complete().  This
will make it a bit in sync with further patches and will give flexibility
in future work.  Also use scope based RCU locking which simplifies the
code of the function.

Found by Linux Verification Center (linuxtesting.org).

Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20251104135720.321110-5-pchelkin@ispras.ru
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/pci.c
drivers/net/wireless/realtek/rtw89/pci.h

index 97cb0e5f08986ce3e869374191a742506f8d9cce..d23ec4d4095a3427d38690ad0caa4573339ee1a4 100644 (file)
@@ -3509,6 +3509,11 @@ struct rtw89_phy_rate_pattern {
        bool enable;
 };
 
+#define RTW89_TX_DONE                  0x0
+#define RTW89_TX_RETRY_LIMIT           0x1
+#define RTW89_TX_LIFE_TIME             0x2
+#define RTW89_TX_MACID_DROP            0x3
+
 #define RTW89_TX_WAIT_WORK_TIMEOUT msecs_to_jiffies(500)
 struct rtw89_tx_wait_info {
        struct rcu_head rcu_head;
@@ -7388,25 +7393,20 @@ static inline struct sk_buff *rtw89_alloc_skb_for_rx(struct rtw89_dev *rtwdev,
 
 static inline bool rtw89_core_tx_wait_complete(struct rtw89_dev *rtwdev,
                                               struct rtw89_tx_skb_data *skb_data,
-                                              bool tx_done)
+                                              u8 tx_status)
 {
        struct rtw89_tx_wait_info *wait;
-       bool ret = false;
 
-       rcu_read_lock();
+       guard(rcu)();
 
        wait = rcu_dereference(skb_data->wait);
        if (!wait)
-               goto out;
+               return false;
 
-       ret = true;
-       wait->tx_done = tx_done;
+       wait->tx_done = tx_status == RTW89_TX_DONE;
        /* Don't access skb anymore after completion */
        complete_all(&wait->completion);
-
-out:
-       rcu_read_unlock();
-       return ret;
+       return true;
 }
 
 static inline bool rtw89_is_mlo_1_1(struct rtw89_dev *rtwdev)
index 0ee5f8579447642129090c8d1a6add95510e9b89..b1985193a18f0f36a95a34c476c69089a22acae5 100644 (file)
@@ -464,7 +464,7 @@ static void rtw89_pci_tx_status(struct rtw89_dev *rtwdev,
        struct rtw89_tx_skb_data *skb_data = RTW89_TX_SKB_CB(skb);
        struct ieee80211_tx_info *info;
 
-       if (rtw89_core_tx_wait_complete(rtwdev, skb_data, tx_status == RTW89_TX_DONE))
+       if (rtw89_core_tx_wait_complete(rtwdev, skb_data, tx_status))
                return;
 
        info = IEEE80211_SKB_CB(skb);
index cb05c83dfd567ed717221c9806289f6240a488d2..16dfb0e79d7731b34084e507b731c0490acb8307 100644 (file)
@@ -1487,10 +1487,6 @@ struct rtw89_pci_tx_addr_info_32_v1 {
 #define RTW89_PCI_RPP_POLLUTED         BIT(31)
 #define RTW89_PCI_RPP_SEQ              GENMASK(30, 16)
 #define RTW89_PCI_RPP_TX_STATUS                GENMASK(15, 13)
-#define RTW89_TX_DONE                  0x0
-#define RTW89_TX_RETRY_LIMIT           0x1
-#define RTW89_TX_LIFE_TIME             0x2
-#define RTW89_TX_MACID_DROP            0x3
 #define RTW89_PCI_RPP_QSEL             GENMASK(12, 8)
 #define RTW89_PCI_RPP_MACID            GENMASK(7, 0)