[][MAC80211][mt76][fix issue that when one phy is scanning and another phy occur packet loss]

[Description]
Fix issue submit:
1. fix issue that when one phy is scanning and another phy occur packet loss
2. only set MT76_MCU_RESET for the main phy
3. rebase 1050-wifi-mt76-try-more-times-when-send-message-timeout.patch resolve conflicts

[Release-log]
N/A

Change-Id: I4caeb6dfc10d8aefba98d533a63ed6aab4d818ed
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8760903
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/0016-wifi-mt76-fix-issue-that-when-one-phy-is-scanning-an.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/0016-wifi-mt76-fix-issue-that-when-one-phy-is-scanning-an.patch
new file mode 100644
index 0000000..c75f18d
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/0016-wifi-mt76-fix-issue-that-when-one-phy-is-scanning-an.patch
@@ -0,0 +1,50 @@
+From 43185c6fd277538d378db3fb9e2d0520d9c5dfb2 Mon Sep 17 00:00:00 2001
+From: Bo Jiao <Bo.Jiao@mediatek.com>
+Date: Thu, 7 Mar 2024 10:57:09 +0800
+Subject: [PATCH] wifi: mt76: fix issue that when one phy is scanning and
+ another phy occur packet loss
+
+Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
+---
+ dma.c        | 5 ++++-
+ mt7915/mac.c | 2 +-
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/dma.c b/dma.c
+index 72a7bd5..b4701d5 100644
+--- a/dma.c
++++ b/dma.c
+@@ -543,13 +543,16 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
+ 		.skb = skb,
+ 	};
+ 	struct ieee80211_hw *hw;
++	struct mt76_phy *phy;
+ 	int len, n = 0, ret = -ENOMEM;
+ 	struct mt76_txwi_cache *t;
+ 	struct sk_buff *iter;
+ 	dma_addr_t addr;
+ 	u8 *txwi;
+ 
+-	if (test_bit(MT76_RESET, &dev->phy.state))
++	hw = mt76_phy_hw(dev, wcid->phy_idx);
++	phy = hw->priv;
++	if (test_bit(MT76_RESET, &phy->state))
+ 		goto free_skb;
+ 
+ 	t = mt76_get_txwi(dev);
+diff --git a/mt7915/mac.c b/mt7915/mac.c
+index faa5ed3..4addbd3 100644
+--- a/mt7915/mac.c
++++ b/mt7915/mac.c
+@@ -1421,7 +1421,7 @@ out:
+ 	/* reset done */
+ 	clear_bit(MT76_RESET, &dev->mphy.state);
+ 	if (phy2)
+-		clear_bit(MT76_RESET, &phy2->mt76->state);
++		clear_bit(MT76_RESET, &ext_phy->state);
+ 
+ 	local_bh_disable();
+ 	napi_enable(&dev->mt76.tx_napi);
+-- 
+2.18.0
+
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/0017-wifi-mt76-mt7915-only-set-MT76_MCU_RESET-for-the-mai.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/0017-wifi-mt76-mt7915-only-set-MT76_MCU_RESET-for-the-mai.patch
new file mode 100644
index 0000000..764db2b
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/0017-wifi-mt76-mt7915-only-set-MT76_MCU_RESET-for-the-mai.patch
@@ -0,0 +1,31 @@
+From 95c3ad0174d9bb082699aa66c834de8802523e2b Mon Sep 17 00:00:00 2001
+From: Bo Jiao <Bo.Jiao@mediatek.com>
+Date: Thu, 7 Mar 2024 11:03:08 +0800
+Subject: [PATCH] wifi: mt76: mt7915: only set MT76_MCU_RESET for the main phy
+
+MT76_MCU_RESET is shared by all Phys, therefore it is only set for the main Phy.
+
+Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
+---
+ mt7915/mac.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/mt7915/mac.c b/mt7915/mac.c
+index 4addbd3..27041e8 100644
+--- a/mt7915/mac.c
++++ b/mt7915/mac.c
+@@ -1338,10 +1338,8 @@ mt7915_mac_restart(struct mt7915_dev *dev)
+ 	set_bit(MT76_RESET, &dev->mphy.state);
+ 	set_bit(MT76_MCU_RESET, &dev->mphy.state);
+ 	wake_up(&dev->mt76.mcu.wait);
+-	if (ext_phy) {
++	if (ext_phy)
+ 		set_bit(MT76_RESET, &ext_phy->state);
+-		set_bit(MT76_MCU_RESET, &ext_phy->state);
+-	}
+ 
+ 	/* lock/unlock all queues to ensure that no tx is pending */
+ 	mt76_txq_schedule_all(&dev->mphy);
+-- 
+2.18.0
+
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1050-wifi-mt76-try-more-times-when-send-message-timeout.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1050-wifi-mt76-try-more-times-when-send-message-timeout.patch
index 9dd4eee..c1b3e5f 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/patches/1050-wifi-mt76-try-more-times-when-send-message-timeout.patch
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1050-wifi-mt76-try-more-times-when-send-message-timeout.patch
@@ -1,18 +1,18 @@
-From 6095169dd81a2dc26314ded00075544ff2717350 Mon Sep 17 00:00:00 2001
+From ca842f6d403a5d4fd11944d10a4a1d7be4b65290 Mon Sep 17 00:00:00 2001
 From: Bo Jiao <Bo.Jiao@mediatek.com>
-Date: Tue, 6 Feb 2024 14:32:46 +0800
-Subject: [PATCH 1/2] wifi: mt76: try more times when send message timeout.
+Date: Thu, 7 Mar 2024 11:13:45 +0800
+Subject: [PATCH] wifi: mt76: try more times when send message timeout.
 
 CR-Id: WCNCR00334773
 Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
 ---
  dma.c        |  7 ++++--
  mcu.c        | 66 ++++++++++++++++++++++++++++++++++++----------------
- mt7915/mac.c | 45 +++++++++++------------------------
- 3 files changed, 64 insertions(+), 54 deletions(-)
+ mt7915/mac.c | 43 +++++++++++-----------------------
+ 3 files changed, 64 insertions(+), 52 deletions(-)
 
 diff --git a/dma.c b/dma.c
-index bbae84f..11de65c 100644
+index c8ed758..bb943d5 100644
 --- a/dma.c
 +++ b/dma.c
 @@ -504,9 +504,12 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q,
@@ -132,25 +132,23 @@
  
  	return ret;
 diff --git a/mt7915/mac.c b/mt7915/mac.c
-index aebfaf2..dd15d88 100644
+index e63e599..c49d73a 100644
 --- a/mt7915/mac.c
 +++ b/mt7915/mac.c
-@@ -1392,14 +1392,6 @@ mt7915_mac_restart(struct mt7915_dev *dev)
+@@ -1392,12 +1392,6 @@ mt7915_mac_restart(struct mt7915_dev *dev)
  		}
  	}
  
 -	set_bit(MT76_RESET, &dev->mphy.state);
 -	set_bit(MT76_MCU_RESET, &dev->mphy.state);
 -	wake_up(&dev->mt76.mcu.wait);
--	if (ext_phy) {
+-	if (ext_phy)
 -		set_bit(MT76_RESET, &ext_phy->state);
--		set_bit(MT76_MCU_RESET, &ext_phy->state);
--	}
 -
  	/* lock/unlock all queues to ensure that no tx is pending */
  	mt76_txq_schedule_all(&dev->mphy);
  	if (ext_phy)
-@@ -1500,11 +1492,18 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
+@@ -1498,11 +1492,18 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
  
  	dev->recovery.hw_full_reset = true;
  
@@ -170,7 +168,7 @@
  	cancel_delayed_work_sync(&dev->mphy.mac_work);
  	if (ext_phy)
  		cancel_delayed_work_sync(&ext_phy->mac_work);
-@@ -1592,20 +1591,15 @@ void mt7915_mac_reset_work(struct work_struct *work)
+@@ -1590,20 +1591,15 @@ void mt7915_mac_reset_work(struct work_struct *work)
  
  	set_bit(MT76_RESET, &dev->mphy.state);
  	set_bit(MT76_MCU_RESET, &dev->mphy.state);
@@ -194,7 +192,7 @@
  	if (mtk_wed_device_active(&dev->mt76.mmio.wed))
  		mtk_wed_device_stop(&dev->mt76.mmio.wed);
  
-@@ -1629,8 +1623,8 @@ void mt7915_mac_reset_work(struct work_struct *work)
+@@ -1627,8 +1623,8 @@ void mt7915_mac_reset_work(struct work_struct *work)
  
  	clear_bit(MT76_MCU_RESET, &dev->mphy.state);
  	clear_bit(MT76_RESET, &dev->mphy.state);
@@ -205,7 +203,7 @@
  
  	local_bh_disable();
  	mt76_for_each_q_rx(&dev->mt76, i) {
-@@ -1652,21 +1646,8 @@ void mt7915_mac_reset_work(struct work_struct *work)
+@@ -1650,21 +1646,8 @@ void mt7915_mac_reset_work(struct work_struct *work)
  	if (ext_phy)
  		ieee80211_wake_queues(ext_phy->hw);