From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794590738; b=D2eVLtlsqu3z8zwqh1cv9JXXiFK/DWy4VECFIEgdqZDljXxd7J7yWWBdyVSC3irR7fpJ 6HfL3iKLd7YSlrqmg1e8Zs7EjG8c//fw6MzPx9akd6sK8PBTi0wKHDMuSQMBup/ZbECfT Iual/tWw776cQkmbBCBxLMe6buakPaz7CGzST3PRMir+c+TO/etHg2LyARE2dWHlbPLhx RVPnzZ2Sr6rwqxqbDObf3DITs7s3ob70Pu2ctVVn8IZ/HlUsvTJrVutg7X40iyF5mVWzD F8Rd+iUHA9FqGB/a+vs+03ZssaGHNnbyZQOoGtfCenF/nXPy7S/bQHPPPMQD/upOwnA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794590738; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=fo56axDQYi5AtOKOve4XTcj+UO+RSHidyAaaU19RMZU=; b=wRPbMEpmTL8oihf3IPbj0RX2V39KM1YQZ63DE8DrdUqDHkORfGZrRbMIe0vapPvyesdk vWmnfbHkUz/p9TB0zIUJ8MDwiNbcBCJsE6xiXBtUMaFxbd1d6EJWCStCJDEEn7gzKbPG2 LiEIqPSJNGE3Aroc0zxWt/XSXMJZxsnd6QjsDbIRZNLZv9nvNhifLeIaRklP64bbexA/l Eh06kAP6QPNRA8O6q8K9XT9hQaBTqU5yznibkU2CcnFPJJJ3ryjvJv+iaW63wOsiuFkhb fhmBi/tu5Va+dSohm907wz4Ky1qfUxn8rF/gU95/1KAgRenqJWR7f+D9sql/RlVHCYA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="D/3/+8jM"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1496E607B58F; Fri, 13 Nov 2026 17:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=D/3/+8jM Received: by smtp.kernel.org (Postfix) with ESMTPSA id B52D71F000C7; Fri, 13 Nov 2026 17:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794590737; bh=fo56axDQYi5AtOKOve4XTcj+UO+RSHidyAaaU19RMZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D/3/+8jMaRDNeyjh+ihxB/iPek83+SOLk/fTdciWhmUbJLHpsNxBhUXIKVT9ytkaI exKJO+0aP2486J6edZWHBkRSAqojm5h2ypxmT+RBD9MCfjRESPuhE8kDHEnPLEWUO/ V05LImEA85ixNH2FRTNXLTyImfS6q9hjmp6giQhQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris , Devin Wittmayer , Felix Fietkau , Sasha Levin Subject: [PATCH 6.18 604/686] wifi: mt76: move the channel survey when the channel changes Date: Fri, 13 Nov 2026 10:52:17 -0500 Message-ID: <20261113153842.387227881@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153820.902362109@linuxfoundation.org> References: <20261113153820.902362109@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Devin Wittmayer [ Upstream commit 68342a7bd7e5e273e2969e3c0f4c62ee3d006ce8 ] mt7921 and mt7925 report every survey counter against one channel and never mark the one in use. With firmware channel management, both use channel contexts and never call __mt76_set_channel(), so phy->chan_state, phy->chandef and phy->main_chandef keep the first channel of the band. Update them when a context is assigned or changed, after booking the time spent on the old channel. This also makes the legacy rate lookup in mt76_connac2_mac_fill_txs() and mt7925_mac_add_txs_skb() use the band of the current channel. With two channel contexts (multi-channel or MLO), the survey follows the context that was assigned or changed last, since the driver reads the band 0 counters only. Tested on MT7922 over PCIe, MT7921AU and MT7925 over USB. Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support") Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Cc: stable@vger.kernel.org Reported-by: Chris Closes: https://lore.kernel.org/linux-wireless/CAHaeJsT8O8Nhq351hFp3NAL8e0iU85N-LBdYZ9nYHFHVy7t_hQ@mail.gmail.com/ Signed-off-by: Devin Wittmayer Link: https://patch.msgid.link/20261001003501.2425492-1-lucid_duck@justthetip.ca Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mac80211.c | 14 ++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++ drivers/net/wireless/mediatek/mt76/mt7921/main.c | 1 + drivers/net/wireless/mediatek/mt76/mt7925/main.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt792x_core.c | 1 + 5 files changed, 20 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index 2d8cd627ef4c6..53c9cd0cfadb7 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -1034,6 +1034,20 @@ void mt76_update_survey(struct mt76_phy *phy) } EXPORT_SYMBOL_GPL(mt76_update_survey); +void mt76_phy_chandef_set(struct mt76_phy *phy, + struct cfg80211_chan_def *chandef) +{ + if (!chandef->chan) + return; + + mt76_update_survey(phy); + + phy->chandef = *chandef; + phy->main_chandef = *chandef; + phy->chan_state = mt76_channel_state(phy, chandef->chan); +} +EXPORT_SYMBOL_GPL(mt76_phy_chandef_set); + int __mt76_set_channel(struct mt76_phy *phy, struct cfg80211_chan_def *chandef, bool offchannel) { diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 6ca5f3b2c6ba8..9542c4fbdee23 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -1531,6 +1531,8 @@ void mt76_sta_ps_transition(struct mt76_dev *dev, struct mt76_wcid *wcid, bool mt76_has_tx_pending(struct mt76_phy *phy); int mt76_update_channel(struct mt76_phy *phy); void mt76_update_survey(struct mt76_phy *phy); +void mt76_phy_chandef_set(struct mt76_phy *phy, + struct cfg80211_chan_def *chandef); void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time); int mt76_get_survey(struct ieee80211_hw *hw, int idx, struct survey_info *survey); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 1e9070a010345..26595de275bff 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -1411,6 +1411,7 @@ mt7921_change_chanctx(struct ieee80211_hw *hw, } else { mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx); } + mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def); mt792x_mutex_release(phy->dev); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c index 7c63c7f5caf3e..70068c9eb8ea8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c @@ -1864,6 +1864,7 @@ mt7925_change_chanctx(struct ieee80211_hw *hw, link_conf, ctx); } } + mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def); mt792x_mutex_release(phy->dev); } @@ -2176,6 +2177,7 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw, mconf->mt76.ctx = ctx; mctx->bss_conf = mconf; + mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def); mutex_unlock(&dev->mt76.mutex); return 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c index d00807075c71f..62c40450472af 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c @@ -342,6 +342,7 @@ int mt792x_assign_vif_chanctx(struct ieee80211_hw *hw, mutex_lock(&dev->mt76.mutex); mvif->bss_conf.mt76.ctx = ctx; mctx->bss_conf = &mvif->bss_conf; + mt76_phy_chandef_set(&dev->mphy, &ctx->def); mutex_unlock(&dev->mt76.mutex); return 0; -- 2.53.0