From nobody Fri Jan 9 00:43:25 2026 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C3392417C3 for ; Mon, 5 Jan 2026 00:27:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767572830; cv=none; b=H+pghUqZOrKGgrGb2nBIAw/6C1ATTOF0XFKGgoZhDg9at3b21ZO8jBPJZc3ixYwAIp+/kT/WAkkNqfr2cUAeruvmlpu2U0abZ9uYcfOne49ftYoNdIE95ET/Uwbj3bb9xq9dFMPt9K653CwTXu9L9ZwOVZc0eBffUOv7Zr5wf2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767572830; c=relaxed/simple; bh=3BGhu95nJ27lYH43BGIMR+sgNyP0MZttqBXOand+UeI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YjpQ9Q+uupGnmgHK/Tgd0vOZWp+S95EufyPw/WLNu4EDurXezLCsa6Zkxn+F5gtkJTSiivkDxsVRVjsWpAKUAImbFTXh0E9JY+0wmWhSQtWkTjzEIUa/mq12LgvxoHsiIq6FxAgRF7a17GzIClVED4CMve5NpAvFxS9Ljm7DZEM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fMGnZ/cT; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fMGnZ/cT" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-81345800791so1266333b3a.0 for ; Sun, 04 Jan 2026 16:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767572827; x=1768177627; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RJjfGhYzMRnwgUAUKvlNtXxtk0atD56wzBEV6PIqpWc=; b=fMGnZ/cTJ9rXJcdQmGhnSwBIFeGKDF0I54sh/2akOMmMRq2WLGqJOFUdy3EsLrAY+T I0xjelcKsMYle74Lkp5ZkG9QhHBU7FXck7f4Xy+gDn2zAvY/yHPPXUmehChurvWdB9AC FzmYH+PfRSuRF3UZCTwzGpONDlZnhLHAh1HF5qMJGmuDSzuvwshHaJxs0JhdnjNF911m kMZdaO9C46vv1IK2IA4h0JLqMHKvvj3bbh1iV5UAvOSgqbwbfBdu4e1B4GosDNDWIHRT 3ShosIH8UPEdEnbxTTAL8Dk9IRyQLcQhnA3aJYo0bzVVEOZiu3dhh9+9m+t7s/QdQLtZ jGAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767572827; x=1768177627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RJjfGhYzMRnwgUAUKvlNtXxtk0atD56wzBEV6PIqpWc=; b=rlBgIzcsp2WFGTEHPq30VfbTzb5W4sFfM4jBdT517+dI57osemjps/8UB4VQxC9RMs F8gmRfoMVMiDDcehGGqELONMeYF6BF3o9AOSmoz+BIJeWQf0++et/d/nOm/T8uCcnrhb CUhxdt45jqFTr91QQ+Xo7ykUAbh23v9VI4GV1GFTs2h/zBxAtdp49sFugJYz/NN2wZdM d8WZ0T+Bkc8NKIzdlRj/R1lJqcDSE9J5/PbWZUdT5oIOFgVEDcf+gGh5gD+3oTe81HFW pjOPC0MZVvwWm6mfFK5GO1++yjJiIs4PXnV9WNKLD6I7IaJ/ABrmTPj0j5M9OU/i7aIW 1cpg== X-Forwarded-Encrypted: i=1; AJvYcCWT5U6jP/zZApl8luWgEBJgv9nIdYtsRGB5j2EdPuMKZm8KSG9p+/OPkLhpBXjG4bVVAGBDUwuYg9tw52c=@vger.kernel.org X-Gm-Message-State: AOJu0Yz1GaOtC0rJdQxMffnQ3f5eS8skMK6dR2Ysubxl6baewV65AfNa opewJl/+uOUwyP4aj572nzzRphJ+oPB9pGMZ+npc0BWaZxOWLaGKiDag X-Gm-Gg: AY/fxX7D7gzhMtJ+Ky8EmiOYIkKoIIbPmAdfpSkbFHuWTwkWp17B45F+KNBeuyULtMr m5WTsHtqTachY/FXV+Gi03kW6yLRcECO19hpSApEex5VLZF1UFPjDxDHznW182VBWzXVQhhUlWs r/nlVZ/ZtTbfBKZCxh+VvHjEl6gCCmJ+Kc7GQgWe71eWSa+SFhMKrga5qhfHRORr4dRQQ7KgQ9j bH3kw3oMqwUbl1Ml+qpte63XaBLCCZTjAOZ1cJbEUZNIpOOzujxTOQlKYLwyHfgrX3oom7S4CoM ER0v0Ep7gu+YRz2ieMFYfjGI1XGVoSPhOtq8bnAUfLPb4fxqHbiMNqz3Uok/aJMLLvEv5k4zsNo BgpNDfmMhRuWp8cT9m8F4R5mjgXNGAuxSe78qHxMJA1ty6titNFGn9yaqdwcMgtewqlwXuYq2x9 WE2IDW31/+4npyGRNtcq9rcby3cQdhpF7RTcXowyF4hd0q5kUbqxXQNwGqApSE/qw= X-Google-Smtp-Source: AGHT+IEgwdZc2sv9zKx5KjMOni7rSof10mVUH9VaD1BavVlI4TZ/Co6GlilKA9YVOKhSaEIPSjDGFQ== X-Received: by 2002:a05:701a:ca08:b0:11b:9386:825b with SMTP id a92af1059eb24-12172302a23mr38511025c88.48.1767572827042; Sun, 04 Jan 2026 16:27:07 -0800 (PST) Received: from zubuntu.bengal-mercat.ts.net ([2001:5a8:60d:bc9:9ebf:dff:fe00:f8f2]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-121724de268sm133378109c88.8.2026.01.04.16.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jan 2026 16:27:06 -0800 (PST) From: Zac Bowling To: zbowling@gmail.com Cc: deren.wu@mediatek.com, kvalo@kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-wireless@vger.kernel.org, lorenzo@kernel.org, nbd@nbd.name, ryder.lee@mediatek.com, sean.wang@mediatek.com Subject: [PATCH 15/17] wifi: mt76: mt792x: fix firmware reload failure after previous load crash Date: Sun, 4 Jan 2026 16:26:36 -0800 Message-ID: <20260105002638.668723-16-zbowling@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260105002638.668723-1-zbowling@gmail.com> References: <20260102200524.290779-1-zbowling@gmail.com> <20260105002638.668723-1-zbowling@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the firmware loading process crashes or is interrupted after acquiring the patch semaphore but before releasing it, subsequent firmware load attempts will fail with 'Failed to get patch semaphore' because the semaphore is still held. This issue manifests as devices becoming unusable after suspend/resume failures or firmware crashes, requiring a full hardware reboot to recover. This has been widely reported on MT7921 and MT7925 devices. Example error log: mt7921e 0000:c2:00.0: Failed to get patch semaphore mt7921e 0000:c2:00.0: probe with driver mt7921e failed with error -5 Apply the same fix that was applied to MT7915 in commit 79dd14f: 1. Release the patch semaphore before starting firmware load (in case it was held by a previous failed attempt) 2. Restart MCU firmware to ensure clean state 3. Wait briefly for MCU to be ready This fix applies to both MT7921 and MT7925 drivers which share the mt792x_load_firmware() function. Fixes: 583204ae70f9 ("wifi: mt76: mt792x: move mt7921_load_firmware in mt79= 2x-lib module") Link: https://github.com/openwrt/mt76/commit/79dd14f2e8161b656341b665326177= 9199aedbe4 Signed-off-by: Zac Bowling --- drivers/net/wireless/mediatek/mt76/mt792x_core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net= /wireless/mediatek/mt76/mt792x_core.c index 9dc768aa8b9c..05598202b488 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c @@ -936,6 +936,20 @@ int mt792x_load_firmware(struct mt792x_dev *dev) { int ret; =20 + /* Release semaphore if taken by previous failed load attempt. + * This prevents "Failed to get patch semaphore" errors when + * recovering from firmware crashes or suspend/resume failures. + */ + ret =3D mt76_connac_mcu_patch_sem_ctrl(&dev->mt76, false); + if (ret < 0) + dev_dbg(dev->mt76.dev, "Semaphore release returned %d (may be expected)\= n", ret); + + /* Always restart MCU to ensure clean state before loading firmware */ + mt76_connac_mcu_restart(&dev->mt76); + + /* Wait for MCU to be ready after restart */ + msleep(100); + ret =3D mt76_connac2_load_patch(&dev->mt76, mt792x_patch_name(dev)); if (ret) return ret; --=20 2.51.0