wifi: rt2x00: restart beacon queue when hardware reset
authorShiji Yang <yangshiji66@outlook.com>
Sat, 4 Nov 2023 08:58:00 +0000 (16:58 +0800)
committerKalle Valo <kvalo@kernel.org>
Wed, 8 Nov 2023 18:14:10 +0000 (20:14 +0200)
When a hardware reset is triggered, all registers are reset, so all
queues are forced to stop in hardware interface. However, mac80211
will not automatically stop the queue. If we don't manually stop the
beacon queue, the queue will be deadlocked and unable to start again.
This patch fixes the issue where Apple devices cannot connect to the
AP after calling ieee80211_restart_hw().

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/TYAP286MB031530EB6D98DCE4DF20766CBCA4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
drivers/net/wireless/ralink/rt2x00/rt2x00mac.c

index c88ce446e1175619dff07ad140d87e67922d3e3c..9e7d9dbe954cf7597d08e926b670f5088a5d94e2 100644 (file)
@@ -101,6 +101,7 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
        rt2x00link_stop_tuner(rt2x00dev);
        rt2x00queue_stop_queues(rt2x00dev);
        rt2x00queue_flush_queues(rt2x00dev, true);
+       rt2x00queue_stop_queue(rt2x00dev->bcn);
 
        /*
         * Disable radio.
@@ -1286,6 +1287,7 @@ int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
        rt2x00dev->intf_ap_count = 0;
        rt2x00dev->intf_sta_count = 0;
        rt2x00dev->intf_associated = 0;
+       rt2x00dev->intf_beaconing = 0;
 
        /* Enable the radio */
        retval = rt2x00lib_enable_radio(rt2x00dev);
@@ -1312,6 +1314,7 @@ void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev)
        rt2x00dev->intf_ap_count = 0;
        rt2x00dev->intf_sta_count = 0;
        rt2x00dev->intf_associated = 0;
+       rt2x00dev->intf_beaconing = 0;
 }
 
 static inline void rt2x00lib_set_if_combinations(struct rt2x00_dev *rt2x00dev)
index 4202c65177839fa7b2ce419eddbbd2d726c0d1b0..75fda72c14ca950890c490e1357b105cc1bdcbe4 100644 (file)
@@ -598,6 +598,17 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
         */
        if (changes & BSS_CHANGED_BEACON_ENABLED) {
                mutex_lock(&intf->beacon_skb_mutex);
+
+               /*
+                * Clear the 'enable_beacon' flag and clear beacon because
+                * the beacon queue has been stopped after hardware reset.
+                */
+               if (test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags) &&
+                   intf->enable_beacon) {
+                       intf->enable_beacon = false;
+                       rt2x00queue_clear_beacon(rt2x00dev, vif);
+               }
+
                if (!bss_conf->enable_beacon && intf->enable_beacon) {
                        rt2x00dev->intf_beaconing--;
                        intf->enable_beacon = false;