From 9eef190a0659b0b5b53e3bfa17cf126d441cb79b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 21:51:04 +0000 Subject: [PATCH 1/4] Initial plan From 6559ffe838702ef1fbcb868a2c805d64d2b25fdc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 21:57:00 +0000 Subject: [PATCH 2/4] mt76x2: fix high-band 5GHz channel stability for channels 157-165 Adjust AGC settings for channels 157-165 (including problematic channels 161 and 165) to improve stability and prevent disconnections. This fix: - Reduces AGC gain (0x6868 vs 0x7070) for channels 157+ during initialization - Adjusts AGC 35 register value for better gain control on high-band channels - Applies to both PCIe (mt76x2e) and USB (mt76x2u) variants Co-authored-by: HiGarfield <32226909+HiGarfield@users.noreply.github.com> --- mt76x2/pci_phy.c | 6 +++++- mt76x2/phy.c | 2 ++ mt76x2/usb_phy.c | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mt76x2/pci_phy.c b/mt76x2/pci_phy.c index 8831337d..ed98b1ec 100644 --- a/mt76x2/pci_phy.c +++ b/mt76x2/pci_phy.c @@ -227,7 +227,11 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev, mt76_wr(dev, MT_BBP(AGC, 61), 0xFF64A4E2); mt76_wr(dev, MT_BBP(AGC, 7), 0x08081010); mt76_wr(dev, MT_BBP(AGC, 11), 0x00000404); - mt76_wr(dev, MT_BBP(AGC, 2), 0x00007070); + /* Adjust AGC 2 for high-band 5GHz channels (157-165) to improve stability */ + if (band == NL80211_BAND_5GHZ && chan->hw_value >= 157) + mt76_wr(dev, MT_BBP(AGC, 2), 0x00006868); + else + mt76_wr(dev, MT_BBP(AGC, 2), 0x00007070); mt76_wr(dev, MT_TXOP_CTRL_CFG, 0x04101B3F); if (scan) diff --git a/mt76x2/phy.c b/mt76x2/phy.c index 8faffc8f..ae5f1d25 100644 --- a/mt76x2/phy.c +++ b/mt76x2/phy.c @@ -321,6 +321,8 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) agc_35 = agc_37 = 0x08080808; else if (dev->mphy.chandef.width == NL80211_CHAN_WIDTH_80) agc_35 = 0x10101014; + else if (dev->mphy.chandef.chan->hw_value >= 157) + agc_35 = 0x0f0f0f14; else agc_35 = 0x11111116; diff --git a/mt76x2/usb_phy.c b/mt76x2/usb_phy.c index a04a98f5..55042ba5 100644 --- a/mt76x2/usb_phy.c +++ b/mt76x2/usb_phy.c @@ -161,7 +161,11 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev, mt76_wr(dev, MT_BBP(AGC, 61), 0xff64a4e2); mt76_wr(dev, MT_BBP(AGC, 7), 0x08081010); mt76_wr(dev, MT_BBP(AGC, 11), 0x00000404); - mt76_wr(dev, MT_BBP(AGC, 2), 0x00007070); + /* Adjust AGC 2 for high-band 5GHz channels (157-165) to improve stability */ + if (chan->band == NL80211_BAND_5GHZ && chan->hw_value >= 157) + mt76_wr(dev, MT_BBP(AGC, 2), 0x00006868); + else + mt76_wr(dev, MT_BBP(AGC, 2), 0x00007070); mt76_wr(dev, MT_TXOP_CTRL_CFG, 0X04101b3f); mt76_set(dev, MT_BBP(TXO, 4), BIT(25)); From b065b19999093893a361efdcaa875b804d2a9e48 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 21:58:05 +0000 Subject: [PATCH 3/4] mt76x2: add band check for high-band AGC adjustment in phy.c Add explicit 5GHz band check before applying high-band channel AGC settings to prevent incorrect application to 2.4GHz channels. This ensures consistency with the logic in pci_phy.c and usb_phy.c. Co-authored-by: HiGarfield <32226909+HiGarfield@users.noreply.github.com> --- mt76x2/phy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mt76x2/phy.c b/mt76x2/phy.c index ae5f1d25..b797c5b3 100644 --- a/mt76x2/phy.c +++ b/mt76x2/phy.c @@ -321,7 +321,8 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) agc_35 = agc_37 = 0x08080808; else if (dev->mphy.chandef.width == NL80211_CHAN_WIDTH_80) agc_35 = 0x10101014; - else if (dev->mphy.chandef.chan->hw_value >= 157) + else if (dev->mphy.chandef.chan->band == NL80211_BAND_5GHZ && + dev->mphy.chandef.chan->hw_value >= 157) agc_35 = 0x0f0f0f14; else agc_35 = 0x11111116; From 7fbce2f88323a6a529233cf66735b31d62c66dd9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 21:58:31 +0000 Subject: [PATCH 4/4] Complete MT7612 channels 161/165 stability fix Co-authored-by: HiGarfield <32226909+HiGarfield@users.noreply.github.com> --- _codeql_detected_source_root | 1 + 1 file changed, 1 insertion(+) create mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 00000000..945c9b46 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +. \ No newline at end of file