Linux wireless drivers development
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 14/19] wifi: mt76: connac: return a negative error for a firmware status
Date: Tue, 17 Nov 2026 19:01:29 +0100	[thread overview]
Message-ID: <20261117180134.2940930-14-nbd@nbd.name> (raw)
In-Reply-To: <20261117180134.2940930-1-nbd@nbd.name>

The parse_response functions of mt7615, mt7921 and mt7925 return the
status of a UNI event unchanged, so callers that test for a negative
return take a firmware failure as success. For example,
mt76_connac_mcu_uni_add_dev() activates the BSS after the firmware
failed the device activation.

Return -EREMOTEIO for a non-zero status, and -ENOLINK for the WLAN
failure status, which mt76_connac_mcu_bss_deact_err() ignores because
the firmware also returns it for the deactivation of an inactive BSS.

Fixes: df5ab0d58b2e ("mt76: mt7615: parse mcu return code for unified commands")
Fixes: 1c099ab44727 ("mt76: mt7921: add MCU support")
Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt7615/mcu.c    |  2 +-
 .../net/wireless/mediatek/mt76/mt76_connac_mcu.h   | 14 +++++++++++++-
 drivers/net/wireless/mediatek/mt76/mt7921/mcu.c    |  3 ++-
 drivers/net/wireless/mediatek/mt76/mt7925/mcu.c    |  3 ++-
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index e5c2ad5fb458..65c57d5a480a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -178,7 +178,7 @@ int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
 			return -EMSGSIZE;
 		skb_pull(skb, sizeof(*rxd));
 		event = (struct mt76_connac_mcu_uni_event *)skb->data;
-		ret = le32_to_cpu(event->status);
+		ret = mt76_connac_mcu_status_err(le32_to_cpu(event->status));
 	} else if (cmd == MCU_CE_QUERY(REG_READ)) {
 		struct mt76_connac_mcu_reg_event *event;
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 2acaae9830fb..cac47c8702e3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1960,10 +1960,22 @@ mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid,
 
 #define MT76_CONNAC_MCU_STATUS_WLAN_FAILURE	0xc0000001
 
+static inline int
+mt76_connac_mcu_status_err(u32 status)
+{
+	if (!status)
+		return 0;
+
+	if (status == MT76_CONNAC_MCU_STATUS_WLAN_FAILURE)
+		return -ENOLINK;
+
+	return -EREMOTEIO;
+}
+
 static inline int
 mt76_connac_mcu_bss_deact_err(struct mt76_dev *mdev, int err, bool enable)
 {
-	if (err != (int)MT76_CONNAC_MCU_STATUS_WLAN_FAILURE)
+	if (err != -ENOLINK)
 		return err;
 
 	/* Ignore wlan_failure state false alarm when deactivating an
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index 2bcd5f085cd4..a16f41eda2bb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -62,10 +62,11 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,
 
 		skb_pull(skb, sizeof(*rxd));
 		event = (struct mt76_connac_mcu_uni_event *)skb->data;
-		ret = le32_to_cpu(event->status);
 		/* skip invalid event */
 		if (mcu_cmd != event->cid)
 			ret = -EAGAIN;
+		else
+			ret = mt76_connac_mcu_status_err(le32_to_cpu(event->status));
 	} else if (cmd == MCU_CE_QUERY(REG_READ)) {
 		struct mt76_connac_mcu_reg_event *event;
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index d3806d8dfbbf..bf8cc4b1f539 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -77,10 +77,11 @@ int mt7925_mcu_parse_response(struct mt76_dev *mdev, int cmd,
 
 		skb_pull(skb, sizeof(*rxd));
 		event = (struct mt7925_mcu_uni_event *)skb->data;
-		ret = le32_to_cpu(event->status);
 		/* skip invalid event */
 		if (mcu_cmd != event->cid)
 			ret = -EAGAIN;
+		else
+			ret = mt76_connac_mcu_status_err(le32_to_cpu(event->status));
 	} else {
 		skb_pull(skb, sizeof(*rxd));
 	}
-- 
2.47.3


  parent reply	other threads:[~2026-11-17 18:01 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 02/19] wifi: mt76: mt7996: return a negative error for a firmware status Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 03/19] wifi: mt76: mt7996: use the default timeout for STA_REC and BSS_INFO Felix Fietkau
2026-11-18  8:22   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 04/19] wifi: mt76: mt7915: " Felix Fietkau
2026-11-18  8:23   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 05/19] wifi: mt76: delete only the RX NAPIs that were added Felix Fietkau
2026-11-18  8:32   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 06/19] wifi: mt76: mt7996: report radar on the channel context of its band Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 07/19] wifi: mt76: mt7996: stop WED before the DMA reset of a full reset Felix Fietkau
2026-11-18  8:38   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 08/19] wifi: mt76: skip the radiotap TLVs in mt76_skb_get_hdr() Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 09/19] wifi: mt76: find the first A-MSDU subframe behind the radiotap data Felix Fietkau
2026-11-18  8:43   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 10/19] wifi: mt76: mark all but the last subframe of an A-MSDU chain Felix Fietkau
2026-11-18  8:47   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 11/19] wifi: mt76: mt7996: set qos_ctl of a frame that hardware reordered Felix Fietkau
2026-11-18  8:50   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 12/19] wifi: mt76: check the PN of a BA session frame at its release Felix Fietkau
2026-11-18  8:55   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 13/19] wifi: mt76: check the RX PN of CCMP-256, GCMP and GCMP-256 keys Felix Fietkau
2026-11-17 18:01 ` Felix Fietkau [this message]
2026-11-17 18:01 ` [PATCH mt76-next 15/19] wifi: mt76: guard the tx_list of every phy with one lock Felix Fietkau
2026-11-18  8:52   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 16/19] wifi: mt76: keep an unpublished wcid off the TX and poll lists Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 17/19] wifi: mt76: mt7925: do not take iflist_mtx under the mutex Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 18/19] wifi: mt76: mt7925: take each polled link under sta_poll_lock Felix Fietkau
2026-11-18  8:58   ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 19/19] wifi: mt76: mt7615: take each polled station " Felix Fietkau
2026-11-18  8:57   ` Lorenzo Bianconi
2026-11-18  8:20 ` [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Lorenzo Bianconi

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=20261117180134.2940930-14-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