mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-14 06:24:53 +08:00
mt76: mt7615: load ROM patch before checking patch semaphore status
For MT7663, the availability of the patch files is used to detect, which corresponding firmware is going to be used (AP firmware or STA offload firmware). If the ROM patch was already applied, it could attempt to load the wrong firmware (without considering the alternative). Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
5c7d374444
commit
4efcfd5c36
@ -1341,25 +1341,26 @@ static int mt7615_load_patch(struct mt7615_dev *dev, u32 addr, const char *name)
|
||||
const struct firmware *fw = NULL;
|
||||
int len, ret, sem;
|
||||
|
||||
sem = mt76_connac_mcu_patch_sem_ctrl(&dev->mt76, true);
|
||||
switch (sem) {
|
||||
case PATCH_IS_DL:
|
||||
return 0;
|
||||
case PATCH_NOT_DL_SEM_SUCCESS:
|
||||
break;
|
||||
default:
|
||||
dev_err(dev->mt76.dev, "Failed to get patch semaphore\n");
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
ret = firmware_request_nowarn(&fw, name, dev->mt76.dev);
|
||||
if (ret)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
if (!fw || !fw->data || fw->size < sizeof(*hdr)) {
|
||||
dev_err(dev->mt76.dev, "Invalid firmware\n");
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
goto release_fw;
|
||||
}
|
||||
|
||||
sem = mt76_connac_mcu_patch_sem_ctrl(&dev->mt76, true);
|
||||
switch (sem) {
|
||||
case PATCH_IS_DL:
|
||||
goto release_fw;
|
||||
case PATCH_NOT_DL_SEM_SUCCESS:
|
||||
break;
|
||||
default:
|
||||
dev_err(dev->mt76.dev, "Failed to get patch semaphore\n");
|
||||
ret = -EAGAIN;
|
||||
goto release_fw;
|
||||
}
|
||||
|
||||
hdr = (const struct mt7615_patch_hdr *)(fw->data);
|
||||
@ -1388,8 +1389,6 @@ static int mt7615_load_patch(struct mt7615_dev *dev, u32 addr, const char *name)
|
||||
dev_err(dev->mt76.dev, "Failed to start patch\n");
|
||||
|
||||
out:
|
||||
release_firmware(fw);
|
||||
|
||||
sem = mt76_connac_mcu_patch_sem_ctrl(&dev->mt76, false);
|
||||
switch (sem) {
|
||||
case PATCH_REL_SEM_SUCCESS:
|
||||
@ -1400,6 +1399,9 @@ out:
|
||||
break;
|
||||
}
|
||||
|
||||
release_fw:
|
||||
release_firmware(fw);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user