From 2c62d03d69f5e20f1129041382289b0865afabaf Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 1 Mar 2019 13:04:45 +0100 Subject: [PATCH] mt76x02: clear running flag when resetting state on restart Use it to avoid unsafe calls to mt76_wake_tx_queue Signed-off-by: Felix Fietkau --- mt76x02_mmio.c | 9 +++++---- tx.c | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mt76x02_mmio.c b/mt76x02_mmio.c index 132c941f..6a34a6af 100644 --- a/mt76x02_mmio.c +++ b/mt76x02_mmio.c @@ -423,6 +423,8 @@ static void mt76x02_reset_state(struct mt76x02_dev *dev) { int i; + clear_bit(MT76_STATE_RUNNING, &dev->mt76.state); + rcu_read_lock(); ieee80211_iter_keys_rcu(dev->mt76.hw, NULL, mt76x02_key_sync, NULL); @@ -527,13 +529,12 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) napi_schedule(&dev->mt76.napi[i]); } - ieee80211_wake_queues(dev->mt76.hw); - - mt76_txq_schedule_all(&dev->mt76); - if (restart) { mt76x02_mcu_function_select(dev, Q_SELECT, 1); ieee80211_restart_hw(dev->mt76.hw); + } else { + ieee80211_wake_queues(dev->mt76.hw); + mt76_txq_schedule_all(&dev->mt76); } } diff --git a/tx.c b/tx.c index 4d38a540..fc7dffe0 100644 --- a/tx.c +++ b/tx.c @@ -580,6 +580,9 @@ void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq) struct mt76_txq *mtxq = (struct mt76_txq *) txq->drv_priv; struct mt76_queue *hwq = mtxq->hwq; + if (!test_bit(MT76_STATE_RUNNING, &dev->state)) + return; + spin_lock_bh(&hwq->lock); if (list_empty(&mtxq->list)) list_add_tail(&mtxq->list, &hwq->swq);