wifi: mt76: mt7915: keep the tx worker off the txq scheduler during hw restart
Subsystems (2)
PATCH 1/1 wifi: mt76: mt7915: keep the tx worker off the txq scheduler during hw restart
mt7915_mac_full_reset() calls ieee80211_restart_hw(), whose asynchronous mac80211 reconfiguration tears down and rebuilds every station's TXQs. Nothing keeps the mt76 tx worker off the mac80211 txq scheduler in that window, so it dereferences freed TXQs and panics in the mt76-tx kthread.
mt76_txq_schedule_list <- mt76_tx_worker_run <- mt76_tx_worker
Gate the worker at its entry point instead. Add a reset_pending counter to struct mt76_dev, raised per band in mt7915_mac_full_reset() and released as each band's reconfig completes in mt7915_reconfig_complete(). mt76_tx_worker_run() returns immediately while the counter is nonzero, and the worker is kicked once it drops back to zero. A run already in flight when the reset starts is serialized by the existing mt76_worker_disable() in mt7915_mac_restart().
The worker cannot simply be parked across the restart. Driver callbacks invoked during the reconfiguration (mt7915_mcu_add_tx_ba(), __mt76_set_channel()) pause and unconditionally resume it, and kthread parking does not nest.
On MT7981 the panic reproduces within a few resets under tx load via the sys_recovery debugfs knob. With this patch it no longer occurs, across forced resets and two weeks of production firmware-triggered resets.
The same restart/reconfig pattern exists in mt7996.
--- mt76.h | 2 ++ mt7915/mac.c | 3 +++ mt7915/main.c | 5 +++++ tx.c | 3 +++ 4 files changed, 13 insertions(+)
mt76.h +2 -0
@@ -974,6 +974,8 @@ struct mt76_dev {enum mt76_hwrro_mode hwrro_mode;struct mt76_worker tx_worker; +/* nonzero while a hw restart reconfig is rebuilding the TXQs */ +atomic_t reset_pending;struct napi_struct tx_napi;spinlock_t token_lock;
mt7915/mac.c +3 -0
@@ -1428,6 +1428,9 @@ mt7915_mac_full_reset(struct mt7915_dev *dev) dev->recovery.hw_full_reset = true; +/* released per band in mt7915_reconfig_complete() */ +atomic_add (ext_phy ?2 :1 , &dev->mt76.reset_pending); +set_bit (MT76_MCU_RESET , &dev->mphy.state);wake_up (&dev->mt76.mcu.wait);ieee80211_stop_queues (mt76_hw (dev));
mt7915/main.c +5 -0
@@ -1833,6 +1833,11 @@ mt7915_reconfig_complete(struct ieee80211_hw *hw, enum ieee80211_reconfig_type reconfig_type) {struct mt7915_phy *phy =mt7915_hw_phy (hw); +struct mt7915_dev *dev = phy->dev; + +if (reconfig_type ==IEEE80211_RECONFIG_TYPE_RESTART && + !atomic_dec_if_positive (&dev->mt76.reset_pending)) +mt76_worker_schedule (&dev->mt76.tx_worker);ieee80211_wake_queues (hw); ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
tx.c +3 -0
@@ -767,6 +767,9 @@ void mt76_tx_worker_run(struct mt76_dev *dev)struct mt76_phy *phy;int i; +if (atomic_read (&dev->reset_pending)) +return ; +mt76_txq_schedule_all (&dev->phy);for (i =0 ; i <ARRAY_SIZE (dev->phys); i++) { phy = dev->phys[i];
Signature · 1 line
2.47.3
PATCH 1/1 wifi: mt76: mt7915: keep the tx worker off the txq scheduler during hw restart
mt7915_mac_full_reset() calls ieee80211_restart_hw(), whose asynchronous mac80211 reconfiguration tears down and rebuilds every station's TXQs. Nothing keeps the mt76 tx worker off the mac80211 txq scheduler in that window, so it dereferences freed TXQs and panics in the mt76-tx kthread.
mt76_txq_schedule_list <- mt76_tx_worker_run <- mt76_tx_worker
Gate the worker at its entry point instead. Add a reset_pending counter to struct mt76_dev, raised per band in mt7915_mac_full_reset() and released as each band's reconfig completes in mt7915_reconfig_complete(). mt76_tx_worker_run() returns immediately while the counter is nonzero, and the worker is kicked once it drops back to zero. A run already in flight when the reset starts is serialized by the existing mt76_worker_disable() in mt7915_mac_restart().
The worker cannot simply be parked across the restart. Driver callbacks invoked during the reconfiguration (mt7915_mcu_add_tx_ba(), __mt76_set_channel()) pause and unconditionally resume it, and kthread parking does not nest.
On MT7981 the panic reproduces within a few resets under tx load via the sys_recovery debugfs knob. With this patch it no longer occurs, across forced resets and two weeks of production firmware-triggered resets.
The same restart/reconfig pattern exists in mt7996.
---
Resent from my own address; please disregard the earlier copy of this patch sent from an unrelated account by mistake.
mt76.h | 2 ++ mt7915/mac.c | 3 +++ mt7915/main.c | 5 +++++ tx.c | 3 +++ 4 files changed, 13 insertions(+)
mt76.h +2 -0
@@ -974,6 +974,8 @@ struct mt76_dev {enum mt76_hwrro_mode hwrro_mode;struct mt76_worker tx_worker; +/* nonzero while a hw restart reconfig is rebuilding the TXQs */ +atomic_t reset_pending;struct napi_struct tx_napi;spinlock_t token_lock;
mt7915/mac.c +3 -0
@@ -1428,6 +1428,9 @@ mt7915_mac_full_reset(struct mt7915_dev *dev) dev->recovery.hw_full_reset = true; +/* released per band in mt7915_reconfig_complete() */ +atomic_add (ext_phy ?2 :1 , &dev->mt76.reset_pending); +set_bit (MT76_MCU_RESET , &dev->mphy.state);wake_up (&dev->mt76.mcu.wait);ieee80211_stop_queues (mt76_hw (dev));
mt7915/main.c +5 -0
@@ -1833,6 +1833,11 @@ mt7915_reconfig_complete(struct ieee80211_hw *hw, enum ieee80211_reconfig_type reconfig_type) {struct mt7915_phy *phy =mt7915_hw_phy (hw); +struct mt7915_dev *dev = phy->dev; + +if (reconfig_type ==IEEE80211_RECONFIG_TYPE_RESTART && + !atomic_dec_if_positive (&dev->mt76.reset_pending)) +mt76_worker_schedule (&dev->mt76.tx_worker);ieee80211_wake_queues (hw); ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
tx.c +3 -0
@@ -767,6 +767,9 @@ void mt76_tx_worker_run(struct mt76_dev *dev)struct mt76_phy *phy;int i; +if (atomic_read (&dev->reset_pending)) +return ; +mt76_txq_schedule_all (&dev->phy);for (i =0 ; i <ARRAY_SIZE (dev->phys); i++) { phy = dev->phys[i];
Signature · 1 line
2.47.3