Commit 328e35c7 authored by Felix Fietkau's avatar Felix Fietkau
Browse files

wifi: mt76: mt7915: improve hardware restart reliability

- use reconfig_complete to restart mac_work / queues
- reset full wtbl after firmware init
- clear wcid and vif mask to avoid leak
- fix sta poll list corruption

Link: https://patch.msgid.link/20240827093011.18621-19-nbd@nbd.name


Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent b2141ead
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -1463,26 +1463,27 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
		if (!mt7915_mac_restart(dev))
			break;
	}
	mutex_unlock(&dev->mt76.mutex);

	if (i == 10)
		dev_err(dev->mt76.dev, "chip full reset failed\n");

	ieee80211_restart_hw(mt76_hw(dev));
	if (ext_phy)
		ieee80211_restart_hw(ext_phy->hw);
	spin_lock_bh(&dev->mt76.sta_poll_lock);
	while (!list_empty(&dev->mt76.sta_poll_list))
		list_del_init(dev->mt76.sta_poll_list.next);
	spin_unlock_bh(&dev->mt76.sta_poll_lock);

	ieee80211_wake_queues(mt76_hw(dev));
	if (ext_phy)
		ieee80211_wake_queues(ext_phy->hw);
	memset(dev->mt76.wcid_mask, 0, sizeof(dev->mt76.wcid_mask));
	dev->mt76.vif_mask = 0;

	i = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA);
	dev->mt76.global_wcid.idx = i;
	dev->recovery.hw_full_reset = false;
	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work,
				     MT7915_WATCHDOG_TIME);

	mutex_unlock(&dev->mt76.mutex);

	ieee80211_restart_hw(mt76_hw(dev));
	if (ext_phy)
		ieee80211_queue_delayed_work(ext_phy->hw,
					     &ext_phy->mac_work,
					     MT7915_WATCHDOG_TIME);
		ieee80211_restart_hw(ext_phy->hw);
}

/* system error recovery */
+12 −0
Original line number Diff line number Diff line
@@ -1682,6 +1682,17 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw,
}
#endif

static void
mt7915_reconfig_complete(struct ieee80211_hw *hw,
			 enum ieee80211_reconfig_type reconfig_type)
{
	struct mt7915_phy *phy = mt7915_hw_phy(hw);

	ieee80211_wake_queues(hw);
	ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
				     MT7915_WATCHDOG_TIME);
}

const struct ieee80211_ops mt7915_ops = {
	.add_chanctx = ieee80211_emulate_add_chanctx,
	.remove_chanctx = ieee80211_emulate_remove_chanctx,
@@ -1740,4 +1751,5 @@ const struct ieee80211_ops mt7915_ops = {
	.net_fill_forward_path = mt7915_net_fill_forward_path,
	.net_setup_tc = mt76_wed_net_setup_tc,
#endif
	.reconfig_complete = mt7915_reconfig_complete,
};
+2 −0
Original line number Diff line number Diff line
@@ -2362,6 +2362,8 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
	if (ret)
		return ret;

	mt76_connac_mcu_del_wtbl_all(&dev->mt76);

	if ((mtk_wed_device_active(&dev->mt76.mmio.wed) &&
	     is_mt7915(&dev->mt76)) ||
	    !mtk_wed_get_rx_capa(&dev->mt76.mmio.wed))