[PATCH 2/4] wifi: mt76: mt7615: wait while Bluetooth downloads the MT7663 patch

From: Ryan Brue

Date: Mon Oct 26 2026 - 15:12:46 EST


On MT7663 the Bluetooth SDIO function (btmtksdio) shares the ROM patch
with Wi-Fi, guarded by a semaphore in the firmware. When Bluetooth wins
the race at boot and is downloading the patch, the semaphore request
returns PATCH_NOT_DL_SEM_FAIL and mt7663s gave up:

mt7663s mmc2:0001:1: Failed to get patch semaphore
mt7663s mmc2:0001:1: failed to load mediatek/mt7663pr2h_rebb.bin

Retry every 100 ms, for up to 5 s, while the semaphore is held, then
find the patch downloaded. Tested on an MT7663 SDIO module with
btmtksdio built in: across repeated boots, whichever function downloads
the patch, both come up.

Fixes: a66cbdd6573d ("mt76: mt7615: introduce mt7663s support")
Signed-off-by: Ryan Brue <ryanbrue.dev@xxxxxxxxx>
---
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index 152b75178b27..e5c2ad5fb458 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -1241,7 +1241,7 @@ static int mt7615_load_patch(struct mt7615_dev *dev, u32 addr, const char *name)
{
const struct mt7615_patch_hdr *hdr;
const struct firmware *fw = NULL;
- int len, ret, sem;
+ int i, len, ret, sem;

ret = firmware_request_nowarn(&fw, name, dev->mt76.dev);
if (ret)
@@ -1253,7 +1253,17 @@ static int mt7615_load_patch(struct mt7615_dev *dev, u32 addr, const char *name)
goto release_fw;
}

- sem = mt76_connac_mcu_patch_sem_ctrl(&dev->mt76, true);
+ /*
+ * On MT7663 the Bluetooth function shares the ROM patch, and the
+ * semaphore is refused while it downloads the patch: wait for it.
+ */
+ for (i = 0; i < 50; i++) {
+ sem = mt76_connac_mcu_patch_sem_ctrl(&dev->mt76, true);
+ if (sem != PATCH_NOT_DL_SEM_FAIL)
+ break;
+ msleep(100);
+ }
+
switch (sem) {
case PATCH_IS_DL:
goto release_fw;

--
2.55.0