From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 11/20] wifi: mt76: mt7915: send mt7981 only the group units its firmware holds
Date: Mon, 23 Nov 2026 14:49:10 +0100 [thread overview]
Message-ID: <20261123134920.154270-11-nbd@nbd.name> (raw)
In-Reply-To: <20261123134920.154270-1-nbd@nbd.name>
Since the mt7981 group pre-calibration size follows the vendor flash
layout, mt7915_mcu_apply_group_cal() sends 144 units of 1024 bytes on
mt7981. The group store of the mt7981 firmware holds 94 units, as on
mt7986. Its handler checks neither the index nor the length of a chunk.
The units with index 94 to 143 thus overwrite 50 KiB of firmware memory
behind the store. This happens at each probe of a board with group
pre-calibration data.
Send only the units that the firmware stores. Keep the trailer and the
DPD data at their offsets of the flash layout.
Fixes: 2b660ee10a0c ("wifi: mt76: mt7915: fix mt7981 pre-calibration")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../wireless/mediatek/mt76/mt7915/eeprom.h | 2 ++
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 28 ++++++++++---------
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h
index 1dc285c72991..bfba4fce3f6d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h
@@ -51,6 +51,8 @@ enum mt7915_eeprom_field {
#define MT_EE_CAL_GROUP_SIZE_7976 (94 * MT_EE_CAL_UNIT + 16)
#define MT_EE_CAL_GROUP_SIZE_7916_6G (94 * MT_EE_CAL_UNIT + 16)
#define MT_EE_CAL_GROUP_SIZE_7981 (144 * MT_EE_CAL_UNIT + 16)
+/* the mt7981 firmware stores fewer group units than its flash layout holds */
+#define MT_EE_CAL_GROUP_FW_UNITS_7981 94
#define MT_EE_CAL_DPD_SIZE_V1 (54 * MT_EE_CAL_UNIT)
#define MT_EE_CAL_DPD_SIZE_V2 (300 * MT_EE_CAL_UNIT)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 02426feb6182..e9a10606c6aa 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -3105,33 +3105,35 @@ static int mt7915_mcu_set_pre_cal(struct mt7915_dev *dev, u8 idx,
int mt7915_mcu_apply_group_cal(struct mt7915_dev *dev)
{
- u8 idx = 0, *cal = dev->cal, *eep = dev->mt76.eeprom.data;
- u32 total = mt7915_get_cal_group_size(dev);
+ u8 idx, units, *cal = dev->cal, *eep = dev->mt76.eeprom.data;
+ u32 size = mt7915_get_cal_group_size(dev);
u32 offs = is_mt7915(&dev->mt76) ? MT_EE_DO_PRE_CAL : MT_EE_DO_PRE_CAL_V2;
+ u32 trailer = size % MT_EE_CAL_UNIT;
+ int ret;
if (!(eep[offs] & MT_EE_WIFI_CAL_GROUP))
return 0;
+ units = size / MT_EE_CAL_UNIT;
+ if (is_mt7981(&dev->mt76))
+ units = MT_EE_CAL_GROUP_FW_UNITS_7981;
+
/*
* Items: Rx DCOC, RSSI DCOC, Tx TSSI DCOC, Tx LPFG
* Tx FDIQ, Tx DCIQ, Rx FDIQ, Rx FIIQ, ADCDCOC
*/
- while (total > 0) {
- int ret, len;
-
- len = min_t(u32, total, MT_EE_CAL_UNIT);
-
- ret = mt7915_mcu_set_pre_cal(dev, idx, cal, len,
+ for (idx = 0; idx < units; idx++) {
+ ret = mt7915_mcu_set_pre_cal(dev, idx,
+ cal + idx * MT_EE_CAL_UNIT,
+ MT_EE_CAL_UNIT,
MCU_EXT_CMD(GROUP_PRE_CAL_INFO));
if (ret)
return ret;
-
- total -= len;
- cal += len;
- idx++;
}
- return 0;
+ /* the trailer follows all units of the flash layout */
+ return mt7915_mcu_set_pre_cal(dev, idx, cal + size - trailer, trailer,
+ MCU_EXT_CMD(GROUP_PRE_CAL_INFO));
}
static int mt7915_find_freq_idx(const u16 *freqs, int n_freqs, u16 cur)
--
2.47.3
next prev parent reply other threads:[~2026-11-23 13:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:49 [PATCH mt76-next 01/20] wifi: mt76: mt7925: undo the BSS of a failed interface add Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 02/20] wifi: mt76: mt7925: keep the embedded link's BMC wcid after a failed add Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 03/20] wifi: mt76: mt7915: read the PS sync state of mt7986 and mt7981 Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 04/20] wifi: mt76: mt7915: leave the BIP check of a group frame to mac80211 Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 05/20] wifi: mt76: mt7921: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 06/20] wifi: mt76: mt7925: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 07/20] wifi: mt76: mt7615: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 08/20] wifi: mt76: mt7925: use wcid_to_sta() in mt7925_mac_write_txwi_8023() Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 09/20] wifi: mt76: log the firmware status of a failed MCU command Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 10/20] wifi: mt76: mt7996: clear the ADM counters only in the airtime poll Felix Fietkau
2026-11-23 13:49 ` Felix Fietkau [this message]
2026-11-23 13:49 ` [PATCH mt76-next 12/20] wifi: mt76: take the DFS state from the off-channel flag Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 13/20] wifi: mt76: read roc_phy and roc_link once without the mutex Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 14/20] wifi: mt76: mt7996: add only the active links of a station MLD's peer Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: resume the radar TX stop at an operating channel set Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 16/20] wifi: mt76: mt7996: divide by the full TWT wake interval Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 17/20] wifi: mt76: mt7915: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 18/20] wifi: mt76: mt7996: send the SRG bitmaps in one block per band Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 19/20] wifi: mt76: connac: set the band of an RX block ack scoreboard reset Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 20/20] wifi: mt76: mt7915: reset the CCA statistics of band 1 on mt7916 Felix Fietkau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123134920.154270-11-nbd@nbd.name \
--to=nbd@nbd.name \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox