Commit 0d28ec72 authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau

mt76: mt7915: improve error handling for fw_debug knobs

In case fw.debug_wm/wa might be unavailable.
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 5eb14a0c
...@@ -447,20 +447,20 @@ mt7915_fw_debug_wm_set(void *data, u64 val) ...@@ -447,20 +447,20 @@ mt7915_fw_debug_wm_set(void *data, u64 val)
bool tx, rx, en; bool tx, rx, en;
int ret; int ret;
dev->fw_debug_wm = val ? MCU_FW_LOG_TO_HOST : 0; dev->fw.debug_wm = val ? MCU_FW_LOG_TO_HOST : 0;
if (dev->fw_debug_bin) if (dev->fw.debug_bin)
val = 16; val = 16;
else else
val = dev->fw_debug_wm; val = dev->fw.debug_wm;
tx = dev->fw_debug_wm || (dev->fw_debug_bin & BIT(1)); tx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(1));
rx = dev->fw_debug_wm || (dev->fw_debug_bin & BIT(2)); rx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(2));
en = dev->fw_debug_wm || (dev->fw_debug_bin & BIT(0)); en = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(0));
ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, val); ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, val);
if (ret) if (ret)
return ret; goto out;
for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) { for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) {
if (debug == DEBUG_RPT_RX) if (debug == DEBUG_RPT_RX)
...@@ -470,16 +470,20 @@ mt7915_fw_debug_wm_set(void *data, u64 val) ...@@ -470,16 +470,20 @@ mt7915_fw_debug_wm_set(void *data, u64 val)
ret = mt7915_mcu_fw_dbg_ctrl(dev, debug, val); ret = mt7915_mcu_fw_dbg_ctrl(dev, debug, val);
if (ret) if (ret)
return ret; goto out;
} }
/* WM CPU info record control */ /* WM CPU info record control */
mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0)); 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); mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) | !dev->fw.debug_wm);
mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5)); 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)); mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5));
return 0; out:
if (ret)
dev->fw.debug_wm = 0;
return ret;
} }
static int static int
...@@ -487,7 +491,7 @@ mt7915_fw_debug_wm_get(void *data, u64 *val) ...@@ -487,7 +491,7 @@ mt7915_fw_debug_wm_get(void *data, u64 *val)
{ {
struct mt7915_dev *dev = data; struct mt7915_dev *dev = data;
*val = dev->fw_debug_wm; *val = dev->fw.debug_wm;
return 0; return 0;
} }
...@@ -501,14 +505,19 @@ mt7915_fw_debug_wa_set(void *data, u64 val) ...@@ -501,14 +505,19 @@ mt7915_fw_debug_wa_set(void *data, u64 val)
struct mt7915_dev *dev = data; struct mt7915_dev *dev = data;
int ret; int ret;
dev->fw_debug_wa = val ? MCU_FW_LOG_TO_HOST : 0; 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); ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, dev->fw.debug_wa);
if (ret) if (ret)
return ret; goto out;
return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), MCU_WA_PARAM_PDMA_RX, ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
!!dev->fw_debug_wa, 0); MCU_WA_PARAM_PDMA_RX, !!dev->fw.debug_wa, 0);
out:
if (ret)
dev->fw.debug_wa = 0;
return ret;
} }
static int static int
...@@ -516,7 +525,7 @@ mt7915_fw_debug_wa_get(void *data, u64 *val) ...@@ -516,7 +525,7 @@ mt7915_fw_debug_wa_get(void *data, u64 *val)
{ {
struct mt7915_dev *dev = data; struct mt7915_dev *dev = data;
*val = dev->fw_debug_wa; *val = dev->fw.debug_wa;
return 0; return 0;
} }
...@@ -563,11 +572,11 @@ mt7915_fw_debug_bin_set(void *data, u64 val) ...@@ -563,11 +572,11 @@ mt7915_fw_debug_bin_set(void *data, u64 val)
if (!dev->relay_fwlog) if (!dev->relay_fwlog)
return -ENOMEM; return -ENOMEM;
dev->fw_debug_bin = val; dev->fw.debug_bin = val;
relay_reset(dev->relay_fwlog); relay_reset(dev->relay_fwlog);
return mt7915_fw_debug_wm_set(dev, dev->fw_debug_wm); return mt7915_fw_debug_wm_set(dev, dev->fw.debug_wm);
} }
static int static int
...@@ -575,7 +584,7 @@ mt7915_fw_debug_bin_get(void *data, u64 *val) ...@@ -575,7 +584,7 @@ mt7915_fw_debug_bin_get(void *data, u64 *val)
{ {
struct mt7915_dev *dev = data; struct mt7915_dev *dev = data;
*val = dev->fw_debug_bin; *val = dev->fw.debug_bin;
return 0; return 0;
} }
...@@ -588,7 +597,7 @@ mt7915_fw_util_wm_show(struct seq_file *file, void *data) ...@@ -588,7 +597,7 @@ mt7915_fw_util_wm_show(struct seq_file *file, void *data)
{ {
struct mt7915_dev *dev = file->private; struct mt7915_dev *dev = file->private;
if (dev->fw_debug_wm) { if (dev->fw.debug_wm) {
seq_printf(file, "Busy: %u%% Peak busy: %u%%\n", seq_printf(file, "Busy: %u%% Peak busy: %u%%\n",
mt76_rr(dev, MT_CPU_UTIL_BUSY_PCT), mt76_rr(dev, MT_CPU_UTIL_BUSY_PCT),
mt76_rr(dev, MT_CPU_UTIL_PEAK_BUSY_PCT)); mt76_rr(dev, MT_CPU_UTIL_PEAK_BUSY_PCT));
...@@ -607,7 +616,7 @@ mt7915_fw_util_wa_show(struct seq_file *file, void *data) ...@@ -607,7 +616,7 @@ mt7915_fw_util_wa_show(struct seq_file *file, void *data)
{ {
struct mt7915_dev *dev = file->private; struct mt7915_dev *dev = file->private;
if (dev->fw_debug_wa) if (dev->fw.debug_wa)
return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(QUERY), return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(QUERY),
MCU_WA_PARAM_CPU_UTIL, 0, 0); MCU_WA_PARAM_CPU_UTIL, 0, 0);
......
...@@ -312,15 +312,18 @@ struct mt7915_dev { ...@@ -312,15 +312,18 @@ struct mt7915_dev {
bool flash_mode; bool flash_mode;
bool muru_debug; bool muru_debug;
bool ibf; bool ibf;
u8 fw_debug_wm;
u8 fw_debug_wa;
u8 fw_debug_bin;
struct dentry *debugfs_dir; struct dentry *debugfs_dir;
struct rchan *relay_fwlog; struct rchan *relay_fwlog;
void *cal; void *cal;
struct {
u8 debug_wm;
u8 debug_wa;
u8 debug_bin;
} fw;
struct { struct {
u16 table_mask; u16 table_mask;
u8 n_agrt; u8 n_agrt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment