From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 20/20] wifi: mt76: mt7915: keep the firmware log settings across a reload
Date: Fri, 20 Nov 2026 18:44:59 +0100 [thread overview]
Message-ID: <20261120174459.1657382-20-nbd@nbd.name> (raw)
In-Reply-To: <20261120174459.1657382-1-nbd@nbd.name>
mt7915_mcu_init_firmware() turns the WM and WA firmware log off after
each firmware load, while dev->fw.debug_wm, dev->fw.debug_wa and
dev->fw.debug_bin keep the debugfs settings. Since the full system reset
loads the firmware again, a reset silently stops firmware logging, and
the debugfs files still report it as enabled.
Send the stored settings at each firmware load, and, where WM or WA
logging is enabled, the other commands and register writes that the
debugfs write sends. With logging off a load sends the same commands as
before, so probe is unchanged.
Fixes: 8a55712d124f ("wifi: mt76: mt7915: enable full system reset support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../wireless/mediatek/mt76/mt7915/debugfs.c | 49 +--------------
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 63 ++++++++++++++++++-
.../wireless/mediatek/mt76/mt7915/mt7915.h | 1 +
3 files changed, 64 insertions(+), 49 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
index a4e95073001d..f69457b0154f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
@@ -495,50 +495,11 @@ static int
mt7915_fw_debug_wm_set(void *data, u64 val)
{
struct mt7915_dev *dev = data;
- enum {
- DEBUG_TXCMD = 62,
- DEBUG_CMD_RPT_TX,
- DEBUG_CMD_RPT_TRIG,
- DEBUG_SPL,
- DEBUG_RPT_RX,
- } debug;
- bool tx, rx, en;
int ret;
dev->fw.debug_wm = val ? MCU_FW_LOG_TO_HOST : 0;
- if (dev->fw.debug_bin)
- val = 16;
- else
- val = dev->fw.debug_wm;
-
- tx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(1));
- rx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(2));
- en = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(0));
-
- ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, val);
- if (ret)
- goto out;
-
- for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) {
- if (debug == DEBUG_RPT_RX)
- val = en && rx;
- else
- val = en && tx;
-
- ret = mt7915_mcu_fw_dbg_ctrl(dev, debug, val);
- if (ret)
- goto out;
- }
-
- /* WM CPU info record control */
- mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0));
- mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) |
- (dev->fw.debug_wm ? 0 : BIT(0)));
- mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5));
- mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5));
-
-out:
+ ret = mt7915_mcu_fw_debug_set(dev, MCU_FW_LOG_WM, false);
if (ret)
dev->fw.debug_wm = 0;
@@ -566,13 +527,7 @@ mt7915_fw_debug_wa_set(void *data, u64 val)
dev->fw.debug_wa = val ? MCU_FW_LOG_TO_HOST : 0;
- ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, dev->fw.debug_wa);
- if (ret)
- goto out;
-
- ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
- MCU_WA_PARAM_PDMA_RX, !!dev->fw.debug_wa, 0);
-out:
+ ret = mt7915_mcu_fw_debug_set(dev, MCU_FW_LOG_WA, false);
if (ret)
dev->fw.debug_wa = 0;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 9b748b37624d..6e1c3e5e2fe9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -2221,6 +2221,65 @@ int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level)
sizeof(data), false);
}
+int mt7915_mcu_fw_debug_set(struct mt7915_dev *dev, u8 type, bool load)
+{
+ enum {
+ DEBUG_TXCMD = 62,
+ DEBUG_CMD_RPT_TX,
+ DEBUG_CMD_RPT_TRIG,
+ DEBUG_SPL,
+ DEBUG_RPT_RX,
+ } debug;
+ bool tx, rx, en;
+ u8 ctrl;
+ int ret;
+
+ if (type == MCU_FW_LOG_WA) {
+ ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA,
+ dev->fw.debug_wa);
+ if (ret || (load && !dev->fw.debug_wa))
+ return ret;
+
+ return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
+ MCU_WA_PARAM_PDMA_RX,
+ !!dev->fw.debug_wa, 0);
+ }
+
+ if (dev->fw.debug_bin)
+ ctrl = 16;
+ else
+ ctrl = dev->fw.debug_wm;
+
+ tx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(1));
+ rx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(2));
+ en = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(0));
+
+ ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, ctrl);
+ if (ret || (load && !en))
+ return ret;
+
+ for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) {
+ u8 level;
+
+ if (debug == DEBUG_RPT_RX)
+ level = en && rx;
+ else
+ level = en && tx;
+
+ ret = mt7915_mcu_fw_dbg_ctrl(dev, debug, level);
+ if (ret)
+ return ret;
+ }
+
+ mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0));
+ mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) |
+ (dev->fw.debug_wm ? 0 : BIT(0)));
+ mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5));
+ mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5));
+
+ return 0;
+}
+
int mt7915_mcu_muru_debug_set(struct mt7915_dev *dev, bool enabled)
{
struct {
@@ -2441,11 +2500,11 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
return ret;
set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
- ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0);
+ ret = mt7915_mcu_fw_debug_set(dev, MCU_FW_LOG_WM, true);
if (ret)
return ret;
- ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, 0);
+ ret = mt7915_mcu_fw_debug_set(dev, MCU_FW_LOG_WA, true);
if (ret)
return ret;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index 1a0aeed5073e..afb856febe3a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -551,6 +551,7 @@ int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
int mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3);
int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl);
int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level);
+int mt7915_mcu_fw_debug_set(struct mt7915_dev *dev, u8 type, bool load);
void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb);
void mt7915_mcu_exit(struct mt7915_dev *dev);
--
2.47.3
prev parent reply other threads:[~2026-11-20 17:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 02/20] wifi: mt76: mt7925: free removed vif links after an RCU grace period Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 03/20] wifi: mt76: remove a replayed station from the driver before the add Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 04/20] wifi: mt76: mt7925: run the reset link replay under the wiphy lock Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 05/20] wifi: mt76: mt7925: take the mutex before the link_info_changed lookup Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 06/20] wifi: mt76: mt7925: hold the mutex for the link lookup in conf_tx Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 07/20] wifi: mt76: mt7925: skip a polled link without a station Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 08/20] wifi: mt76: mt7925: skip a link without a link conf in the MLO PS update Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 09/20] wifi: mt76: mt7925: restore the beacon filter when monitor mode ends Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 10/20] wifi: mt76: usb: do not park the TX worker again under MT76_RESET Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 11/20] wifi: mt76: mt7925: keep the default link in the active links Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 12/20] wifi: mt76: mt7925: read the monitor state under the mutex for deep sleep Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 13/20] wifi: mt76: clear roc_link before the ROC link is freed Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 14/20] wifi: mt76: mt792x: handle all interfaces of a channel context Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 15/20] wifi: mt76: mt792x: set up the sniffer when a monitor gets its channel Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 16/20] wifi: mt76: buffer Disassociation frames for stations in power save Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 17/20] wifi: mt76: mt7921: read the monitor state under the mutex for deep sleep Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 18/20] wifi: mt76: mt7925: wake the device to unassign a channel context Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 19/20] wifi: mt76: mt7996: keep the firmware log settings across a reload Felix Fietkau
2026-11-20 17:44 ` Felix Fietkau [this message]
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=20261120174459.1657382-20-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