Commit 5b8f1840 authored by Sean Wang's avatar Sean Wang Committed by Felix Fietkau

mt76: drop MCU header size from buffer size in __mt76_mcu_send_firmware

Each firmware piece with mt7915 and mt7921 do not have the MCU header to
reroute the packet to the internal RAM. So we do not need to consider the
MCU header size in __mt76_mcu_send_firmware.
Move the MCU header overhead calculation to mt76_mcu_send_firmware (for
older chipsets)

Fixes: e57b7901 ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Fixes: 1c099ab4 ("mt76: mt7921: add MCU support")
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 215a2efa
......@@ -112,7 +112,7 @@ int __mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data,
int err, cur_len;
while (len > 0) {
cur_len = min_t(int, max_len - dev->mcu_ops->headroom, len);
cur_len = min_t(int, max_len, len);
err = mt76_mcu_send_msg(dev, cmd, data, cur_len, false);
if (err)
......
......@@ -1264,7 +1264,9 @@ static inline int
mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data,
int len)
{
return __mt76_mcu_send_firmware(dev, cmd, data, len, 4096);
int max_len = 4096 - dev->mcu_ops->headroom;
return __mt76_mcu_send_firmware(dev, cmd, data, len, max_len);
}
static inline int
......
......@@ -2648,8 +2648,8 @@ static int mt7915_load_patch(struct mt7915_dev *dev)
goto out;
}
ret = mt76_mcu_send_firmware(&dev->mt76, MCU_CMD(FW_SCATTER),
dl, len);
ret = __mt76_mcu_send_firmware(&dev->mt76, MCU_CMD(FW_SCATTER),
dl, len, 4096);
if (ret) {
dev_err(dev->mt76.dev, "Failed to send patch\n");
goto out;
......@@ -2717,8 +2717,8 @@ mt7915_mcu_send_ram_firmware(struct mt7915_dev *dev,
return err;
}
err = mt76_mcu_send_firmware(&dev->mt76, MCU_CMD(FW_SCATTER),
data + offset, len);
err = __mt76_mcu_send_firmware(&dev->mt76, MCU_CMD(FW_SCATTER),
data + offset, len, 4096);
if (err) {
dev_err(dev->mt76.dev, "Failed to send firmware.\n");
return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment