Skip to contentSkip to conversation

wifi: mac80211: export ieee80211_purge_tx_queue() for drivers

PATCH Superseded Ping-Ke Shih 2 participants 5 messages Aug 19, 2024 – Aug 22, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ping-Ke Shih

author maintainer
#0 lore raw

PATCH 1/2 wifi: mac80211: export ieee80211_purge_tx_queue() for drivers

Drivers need to purge TX SKB when stopping. Use skb_queue_purge() can't report TX status to mac80211, causing ieee80211_free_ack_frame() warns "Have pending ack frames!".

---
Hi Johannes,

If this patch is accepted, please merge it ahead and I will merge the second patch via rtw tree after pulling wireless-next tree. I think this can reduce possible conflicts.

---
 include/net/mac80211.h | 11 +++++++++++
 net/mac80211/status.c  |  1 +
 2 files changed, 12 insertions(+)
include/net/mac80211.h +11 -0
index 0a04eaf5343c..f11844f0c80f 100644
@@ -3180,6 +3180,17 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
  */
 void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
 
+/**
+ * ieee80211_purge_tx_queue - purge TX skb queue
+ * @hw: the hardware
+ * @skbs: the skbs
+ *
+ * Free a set of transmit skbs. Use this function when device is going to stop
+ * but some transmit skbs without TX status are still queued.
+ */
+void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
+			      struct sk_buff_head *skbs);
+
 /**
  * DOC: Hardware crypto acceleration
  *
net/mac80211/status.c +1 -0
index dd8f857a1fbc..d1cf987de13b 100644
@@ -1301,3 +1301,4 @@ void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
 	while ((skb = __skb_dequeue(skbs)))
 		ieee80211_free_txskb(hw, skb);
 }
+EXPORT_SYMBOL(ieee80211_purge_tx_queue);
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 2/2 wifi: rtw88: use ieee80211_purge_tx_queue() to purge TX skb

When removing kernel modules by:
rmmod rtw88_8723cs rtw88_8703b rtw88_8723x rtw88_sdio rtw88_core

Driver uses skb_queue_purge() to purge TX skb, but not report tx status causing "Have pending ack frames!" warning. Use ieee80211_purge_tx_queue() to correct this.

wlan0: deauthenticating from aa:f5:fd:60:4c:a8 by local
choice (Reason: 3=DEAUTH_LEAVING)

   ------------[ cut here ]------------
   Have pending ack frames!
   WARNING: CPU: 3 PID: 9232 at net/mac80211/main.c:1691
       ieee80211_free_ack_frame+0x5c/0x90 [mac80211]
   CPU: 3 PID: 9232 Comm: rmmod Tainted: G         C
       6.10.1-200.fc40.aarch64 #1
   Hardware name: pine64 Pine64 PinePhone Braveheart
      (1.1)/Pine64 PinePhone Braveheart (1.1), BIOS 2024.01 01/01/2024
   pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
   pc : ieee80211_free_ack_frame+0x5c/0x90 [mac80211]
   lr : ieee80211_free_ack_frame+0x5c/0x90 [mac80211]
   sp : ffff80008c1b37b0
   x29: ffff80008c1b37b0 x28: ffff000003be8000 x27: 0000000000000000
   x26: 0000000000000000 x25: ffff000003dc14b8 x24: ffff80008c1b37d0
   x23: ffff000000ff9f80 x22: 0000000000000000 x21: 000000007fffffff
   x20: ffff80007c7e93d8 x19: ffff00006e66f400 x18: 0000000000000000
   x17: ffff7ffffd2b3000 x16: ffff800083fc0000 x15: 0000000000000000
   x14: 0000000000000000 x13: 2173656d61726620 x12: 6b636120676e6964
   x11: 0000000000000000 x10: 000000000000005d x9 : ffff8000802af2b0
   x8 : ffff80008c1b3430 x7 : 0000000000000001 x6 : 0000000000000001
   x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
   x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000003be8000
   Call trace:
    ieee80211_free_ack_frame+0x5c/0x90 [mac80211]
    idr_for_each+0x74/0x110
    ieee80211_free_hw+0x44/0xe8 [mac80211]
    rtw_sdio_remove+0x9c/0xc0 [rtw88_sdio]
    sdio_bus_remove+0x44/0x180
    device_remove+0x54/0x90
    device_release_driver_internal+0x1d4/0x238
    driver_detach+0x54/0xc0
    bus_remove_driver+0x78/0x108
    driver_unregister+0x38/0x78
    sdio_unregister_driver+0x2c/0x40
    rtw_8723cs_driver_exit+0x18/0x1000 [rtw88_8723cs]
    __do_sys_delete_module.isra.0+0x190/0x338
    __arm64_sys_delete_module+0x1c/0x30
    invoke_syscall+0x74/0x100
    el0_svc_common.constprop.0+0x48/0xf0
    do_el0_svc+0x24/0x38
    el0_svc+0x3c/0x158
    el0t_64_sync_handler+0x120/0x138
    el0t_64_sync+0x194/0x198
   ---[ end trace 0000000000000000 ]---
---
 drivers/net/wireless/realtek/rtw88/sdio.c | 2 +-
 drivers/net/wireless/realtek/rtw88/usb.c  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/sdio.c +1 -1
index 21d0754dd7f6..949ea155dde8 100644
@@ -1298,7 +1298,7 @@ static void rtw_sdio_deinit_tx(struct rtw_dev *rtwdev)
 	int i;
 
 	for (i = 0; i < RTK_MAX_TX_QUEUE_NUM; i++)
-		skb_queue_purge(&rtwsdio->tx_queue[i]);
+		ieee80211_purge_tx_queue(rtwdev->hw, &rtwsdio->tx_queue[i]);
 
 	flush_workqueue(rtwsdio->txwq);
 	destroy_workqueue(rtwsdio->txwq);
drivers/net/wireless/realtek/rtw88/usb.c +2 -1
index e83ab6fb83f5..e3a094b10753 100644
@@ -423,10 +423,11 @@ static void rtw_usb_tx_handler(struct work_struct *work)
 
 static void rtw_usb_tx_queue_purge(struct rtw_usb *rtwusb)
 {
+	struct rtw_dev *rtwdev = rtwusb->rtwdev;
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(rtwusb->tx_queue); i++)
-		skb_queue_purge(&rtwusb->tx_queue[i]);
+		ieee80211_purge_tx_queue(rtwdev->hw, &rtwusb->tx_queue[i]);
 }
 
 static void rtw_usb_write_port_complete(struct urb *urb)
Signature · 1 line
2.25.1
maintainer
#2 lore raw
In reply to Ping-Ke Shih
Quoted 1 line · Ping-Ke Shih

Drivers need to purge TX SKB when stopping. Use skb_queue_purge() can't

"Using"?

Quoted 2 lines

report TX status to mac80211, causing ieee80211_free_ack_frame() warns "Have pending ack frames!".

Should say what you do - i.e. "Export ... to not have to reimplement it" or so?

include/net/mac80211.h ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, · line 3192

Quoted 10 lines
include/net/mac80211.h +10 -0
+/**
+ * ieee80211_purge_tx_queue - purge TX skb queue
+ * @hw: the hardware
+ * @skbs: the skbs
+ *
+ * Free a set of transmit skbs. Use this function when device is going to stop
+ * but some transmit skbs without TX status are still queued.
+ */
+void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
+			      struct sk_buff_head *skbs);

Unlike skb_queue_purge()/skb_queue_purge_reason(), this doesn't take the lock, that seems important to note here?

net/mac80211/status.c void ieee80211_purge_tx_queue(struct ieee80211_hw *hw, · line 1304

Quoted 6 lines

+++ b/net/mac80211/status.c

net/mac80211/status.c +1 -0
@@ -1301,3 +1301,4 @@ void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
 	while ((skb = __skb_dequeue(skbs)))
 		ieee80211_free_txskb(hw, skb);
 }
+EXPORT_SYMBOL(ieee80211_purge_tx_queue);

see the context here.

johannes

author maintainer
#3 lore raw
Quoted 5 lines · Johannes Berg
Quoted 5 lines

+/**
+ * ieee80211_purge_tx_queue - purge TX skb queue
+ * @hw: the hardware
+ * @skbs: the skbs
+ *

Quoted 8 lines

include/net/mac80211.h ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, · line 3192

Quoted 5 lines

+ * Free a set of transmit skbs. Use this function when device is going to stop
+ * but some transmit skbs without TX status are still queued.
+ */

include/net/mac80211.h +2 -0
+void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
+                           struct sk_buff_head *skbs);

Unlike skb_queue_purge()/skb_queue_purge_reason(), this doesn't take the lock, that seems important to note here?

Thanks. I wasn't aware of lock, and rtw88 needs a lock version because its TX work isn't stopped yet while calling ieee80211_purge_tx_queue().

I have three candidate options:

1. add spin_lock by driver before calling ieee80211_purge_tx_queue().

2. move original ieee80211_purge_tx_queue() to __ieee80211_purge_tx_queue(), and add an new lock version of ieee80211_purge_tx_queue().

3. change rtw88 deinit flow to ensure stopping TX work before calling ieee80211_purge_tx_queue()

I prefer option 3. But want your opinion if option 2 is worth to do?

Ping-Ke

author maintainer
#4 lore raw
Quoted 22 lines · Ping-Ke Shih
Quoted 5 lines · Johannes Berg
Quoted 5 lines

+/**
+ * ieee80211_purge_tx_queue - purge TX skb queue
+ * @hw: the hardware
+ * @skbs: the skbs
+ *

Quoted 8 lines

include/net/mac80211.h ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, · line 3192

Quoted 5 lines

+ * Free a set of transmit skbs. Use this function when device is going to stop
+ * but some transmit skbs without TX status are still queued.
+ */

include/net/mac80211.h +2 -0
+void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
+                           struct sk_buff_head *skbs);

Unlike skb_queue_purge()/skb_queue_purge_reason(), this doesn't take the lock, that seems important to note here?

Thanks. I wasn't aware of lock, and rtw88 needs a lock version because its TX work isn't stopped yet while calling ieee80211_purge_tx_queue().

I have three candidate options:

1. add spin_lock by driver before calling ieee80211_purge_tx_queue().

Quoted 8 lines

2. move original ieee80211_purge_tx_queue() to __ieee80211_purge_tx_queue(), and add an new lock version of ieee80211_purge_tx_queue().

3. change rtw88 deinit flow to ensure stopping TX work before calling ieee80211_purge_tx_queue()

I prefer option 3. But want your opinion if option 2 is worth to do?

I have chosen option 3, so just export ieee80211_purge_tx_queue() and no need to touch ieee80211_purge_tx_queue() further. Sent v2 along with suggested comments.