mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Bauer <mail@david-bauer.net>
To: Felix Fietkau <nbd@nbd.name>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Ryder Lee <ryder.lee@mediatek.com>,
	Shayne Chen <shayne.chen@mediatek.com>,
	Sean Wang <sean.wang@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: [PATCH mt76] wifi: mt76: mt7603: track consecutive failed PSE resets
Date: Tue,  3 Nov 2026 01:35:33 +0100	[thread overview]
Message-ID: <20261103003534.176866-1-mail@david-bauer.net> (raw)

The current PSE recovery process uses the global reset cause counter to
clear the MT_MCU_DEBUG_RESET_PSE_S only every 3rd attempt. The counter
then wraps around.

This does not allow to track the total number of failed PSE reset
attempts. Introduce a new separate counter for consecutive failed resets
and clear the bit based on the value of that counter.

Keep RESET_FAILED reset cause as a cumulative statistic.

Also add a short comment about how the reset procedure handles the
failed case in terms of the retry limit.

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 .../net/wireless/mediatek/mt76/mt7603/mac.c   | 21 ++++++++++++-------
 .../wireless/mediatek/mt76/mt7603/mt7603.h    |  1 +
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
index fa0bf9a201ce2..549b0d3358f68 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
@@ -1342,7 +1342,7 @@ wait_for_wpdma(struct mt7603_dev *dev)
 static void mt7603_pse_reset(struct mt7603_dev *dev)
 {
 	/* Clear previous reset result */
-	if (!dev->reset_cause[RESET_CAUSE_RESET_FAILED])
+	if (!dev->failed_pse_reset_attempts)
 		mt76_clear(dev, MT_MCU_DEBUG_RESET, MT_MCU_DEBUG_RESET_PSE_S);
 
 	/* Reset PSE */
@@ -1351,15 +1351,22 @@ static void mt7603_pse_reset(struct mt7603_dev *dev)
 	if (!mt76_poll_msec(dev, MT_MCU_DEBUG_RESET,
 			    MT_MCU_DEBUG_RESET_PSE_S,
 			    MT_MCU_DEBUG_RESET_PSE_S, 500)) {
+		dev->failed_pse_reset_attempts++;
 		dev->reset_cause[RESET_CAUSE_RESET_FAILED]++;
 		mt76_clear(dev, MT_MCU_DEBUG_RESET, MT_MCU_DEBUG_RESET_PSE);
 	} else {
-		dev->reset_cause[RESET_CAUSE_RESET_FAILED] = 0;
+		dev->failed_pse_reset_attempts = 0;
 		mt76_clear(dev, MT_MCU_DEBUG_RESET, MT_MCU_DEBUG_RESET_QUEUES);
 	}
 
-	if (dev->reset_cause[RESET_CAUSE_RESET_FAILED] >= 3)
-		dev->reset_cause[RESET_CAUSE_RESET_FAILED] = 0;
+	/* Limit the number of consecutive failed PSE reset attempts.
+	 *
+	 * After 3 consecutive failed attempts, the reset limit is
+	 * reached, the counter is reset and the device will
+	 * return to normal operation.
+	 */
+	if (dev->failed_pse_reset_attempts >= 3)
+		dev->failed_pse_reset_attempts = 0;
 }
 
 void mt7603_mac_dma_start(struct mt7603_dev *dev)
@@ -1481,11 +1488,11 @@ static void mt7603_mac_watchdog_reset(struct mt7603_dev *dev)
 		mt76_queue_rx_reset(dev, i);
 	}
 
-	if (dev->reset_cause[RESET_CAUSE_RESET_FAILED] ||
+	if (dev->failed_pse_reset_attempts ||
 	    dev->cur_reset_cause == RESET_CAUSE_RX_PSE_BUSY)
 		mt7603_pse_reset(dev);
 
-	if (!dev->reset_cause[RESET_CAUSE_RESET_FAILED]) {
+	if (!dev->failed_pse_reset_attempts) {
 		mt7603_mac_dma_start(dev);
 
 		mt7603_irq_enable(dev, mask);
@@ -1920,7 +1927,7 @@ void mt7603_mac_work(struct work_struct *work)
 	    mt7603_watchdog_check(dev, &dev->mcu_hang,
 				  RESET_CAUSE_MCU_HANG,
 				  NULL) ||
-	    dev->reset_cause[RESET_CAUSE_RESET_FAILED]) {
+	    dev->failed_pse_reset_attempts) {
 		dev->beacon_check = 0;
 		dev->tx_dma_check = 0;
 		dev->tx_hang_check = 0;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h b/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h
index 5b0ecd01aad95..47f5be44292d6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h
@@ -155,6 +155,7 @@ struct mt7603_dev {
 
 	u32 reset_test;
 
+	u8 failed_pse_reset_attempts;
 	unsigned int reset_cause[__RESET_CAUSE_MAX];
 };
 
-- 
2.53.0


                 reply	other threads:[~2026-11-03  0:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261103003534.176866-1-mail@david-bauer.net \
    --to=mail@david-bauer.net \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=ryder.lee@mediatek.com \
    --cc=sean.wang@mediatek.com \
    --cc=shayne.chen@mediatek.com \
    /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

all inboxes | Powered by JetHome®