* [PATCH net-next v2] net: stmmac: program the FSM timeout timer
@ 2026-11-12 5:33 Zxyan Zhu
2026-11-16 5:35 ` netdev-bot+sashiko
0 siblings, 1 reply; 2+ messages in thread
From: Zxyan Zhu @ 2026-11-12 5:33 UTC (permalink / raw)
To: maxime.chevallier, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, mcoquelin.stm32, alexandre.torgue, linux-stm32,
linux-arm-kernel, linux-kernel, rmk+kernel, Zxyan Zhu
stmmac enables the FSM timeout checker (TMOUTEN) but never programs the
MAC_FSM_ACT_Timer register. Per the databook the checker only fires once
NTMRMD is programmed with a non-zero duration; NTMRMD == 0 disables the
timer, so with TMOUTEN set but the timer left at reset a stuck FSM is
never reported and the advertised timeout protection is ineffective.
Program MAC_FSM_ACT_Timer right after TMOUTEN is enabled, deriving the
TMR field (CSR clocks per 1us tic) from the CSR clock rate and defaulting
to a 1s timeout. A platform can override the default through the new
ntmrmd field in stmmac_safety_feature_cfg.
The issue was hit in testing on dwmac4 and dwxgmac, where a stuck FSM was
not reported through the safety interrupt despite TMOUTEN being set.
Signed-off-by: Zxyan Zhu <zxyan0222@gmail.com>
---
v1: https://lore.kernel.org/netdev/20261111143322.2234321-1-zxyan0222@gmail.com/
v2:
- Rebased onto net-next.
- Dropped the Fixes: tags (this never worked, so it's feature completion,
not a regression fix).
- Specified the tested hardware (dwmac4 and dwxgmac).
drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 20 ++++++++++++++++++-
drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 6 +++++-
.../net/ethernet/stmicro/stmmac/dwxgmac2.h | 3 +++
.../ethernet/stmicro/stmmac/dwxgmac2_core.c | 20 ++++++++++++++++++-
drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 ++-
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +++++++-
include/linux/stmmac.h | 17 ++++++++++++++++
7 files changed, 72 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c
index f1bb981cab7c..4ab7a3df98c6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c
@@ -2,6 +2,7 @@
// Copyright (c) 2017 Synopsys, Inc. and/or its affiliates.
// stmmac Support for 5.xx Ethernet QoS cores
+#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/iopoll.h>
#include "common.h"
@@ -184,7 +185,8 @@ static void dwmac5_handle_dma_err(struct net_device *ndev,
}
int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
- struct stmmac_safety_feature_cfg *safety_feat_cfg)
+ struct stmmac_safety_feature_cfg *safety_feat_cfg,
+ unsigned int csr_clk_mhz)
{
struct stmmac_safety_feature_cfg all_safety_feats = {
.tsoee = 1,
@@ -245,6 +247,22 @@ int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
value |= TMOUTEN; /* FSM Timeout Feature */
writel(value, ioaddr + MAC_FSM_CONTROL);
+ /* Program the FSM active timer so the timeout checker actually fires.
+ * TMR is the number of CSR clocks per 1us tic, i.e. csr_clk in MHz.
+ * Default to a 1s timeout when the platform did not select one.
+ */
+ if (safety_feat_cfg->tmouten && csr_clk_mhz) {
+ u32 ntmrmd = safety_feat_cfg->ntmrmd;
+
+ ntmrmd = (ntmrmd >= STMMAC_NTMRMD_1US &&
+ ntmrmd <= STMMAC_NTMRMD_64SEC) ?
+ ntmrmd : STMMAC_NTMRMD_1SEC;
+
+ writel(FIELD_PREP(MAC_FSM_ACT_TIMER_NTMRMD, ntmrmd) |
+ FIELD_PREP(MAC_FSM_ACT_TIMER_TMR, csr_clk_mhz),
+ ioaddr + MAC_FSM_ACT_TIMER);
+ }
+
/* 4. Enable Data Parity Protection */
value = readl(ioaddr + MTL_DPP_CONTROL);
if (safety_feat_cfg->edpp)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h
index 00b151b3b688..734e7630f28d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h
@@ -8,8 +8,11 @@
#define MAC_DPP_FSM_INT_STATUS 0x00000140
#define MAC_AXI_SLV_DPE_ADDR_STATUS 0x00000144
#define MAC_FSM_CONTROL 0x00000148
+#define MAC_FSM_ACT_TIMER 0x0000014C
#define PRTYEN BIT(1)
#define TMOUTEN BIT(0)
+#define MAC_FSM_ACT_TIMER_TMR GENMASK(9, 0)
+#define MAC_FSM_ACT_TIMER_NTMRMD GENMASK(19, 16)
#define MAC_PPS_CONTROL 0x00000b70
#define PPS_MAXIDX(x) ((((x) + 1) * 8) - 1)
@@ -82,7 +85,8 @@
#define GMAC_INT_FPE_EN BIT(17)
int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
- struct stmmac_safety_feature_cfg *safety_cfg);
+ struct stmmac_safety_feature_cfg *safety_cfg,
+ unsigned int csr_clk_mhz);
int dwmac5_safety_feat_irq_status(struct net_device *ndev,
void __iomem *ioaddr, unsigned int asp,
struct stmmac_safety_stats *stats);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
index f8ab347f7b5b..1fd501728b18 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
@@ -169,8 +169,11 @@
#define XGMAC_HWFEAT_PCSEL GENMASK(1, 0)
#define XGMAC_MAC_DPP_FSM_INT_STATUS 0x00000150
#define XGMAC_MAC_FSM_CONTROL 0x00000158
+#define XGMAC_MAC_FSM_ACT_TIMER 0x0000015C
#define XGMAC_PRTYEN BIT(1)
#define XGMAC_TMOUTEN BIT(0)
+#define XGMAC_MAC_FSM_ACT_TIMER_TMR GENMASK(9, 0)
+#define XGMAC_MAC_FSM_ACT_TIMER_NTMRMD GENMASK(19, 16)
#define XGMAC_MDIO_ADDR 0x00000200
#define XGMAC_MDIO_DATA 0x00000204
#define XGMAC_MDIO_C22P 0x00000220
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
index 7ad08651675e..dac85431e740 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
@@ -4,6 +4,7 @@
* stmmac XGMAC support.
*/
+#include <linux/bitfield.h>
#include <linux/bitrev.h>
#include <linux/crc32.h>
#include <linux/iopoll.h>
@@ -837,7 +838,8 @@ static void dwxgmac3_handle_dma_err(struct net_device *ndev,
static int
dwxgmac3_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
- struct stmmac_safety_feature_cfg *safety_cfg)
+ struct stmmac_safety_feature_cfg *safety_cfg,
+ unsigned int csr_clk_mhz)
{
u32 value;
@@ -873,6 +875,22 @@ dwxgmac3_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
value |= XGMAC_TMOUTEN; /* FSM Timeout Feature */
writel(value, ioaddr + XGMAC_MAC_FSM_CONTROL);
+ /* Program the FSM active timer so the timeout checker actually fires.
+ * TMR is the number of CSR clocks per 1us tic, i.e. csr_clk in MHz.
+ * Default to a 1s timeout when the platform did not select one.
+ */
+ if (safety_cfg && safety_cfg->tmouten && csr_clk_mhz) {
+ u32 ntmrmd = safety_cfg->ntmrmd;
+
+ ntmrmd = (ntmrmd >= STMMAC_NTMRMD_1US &&
+ ntmrmd <= STMMAC_NTMRMD_64SEC) ?
+ ntmrmd : STMMAC_NTMRMD_1SEC;
+
+ writel(FIELD_PREP(XGMAC_MAC_FSM_ACT_TIMER_NTMRMD, ntmrmd) |
+ FIELD_PREP(XGMAC_MAC_FSM_ACT_TIMER_TMR, csr_clk_mhz),
+ ioaddr + XGMAC_MAC_FSM_ACT_TIMER);
+ }
+
/* 5. Enable Data Path Parity Protection */
value = readl(ioaddr + XGMAC_MTL_DPP_CONTROL);
/* already enabled by default, explicit enable it again */
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 8ae95e91a36a..395655b01ea8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -378,7 +378,8 @@ struct stmmac_ops {
bool srgmi_ral);
/* Safety Features */
int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp,
- struct stmmac_safety_feature_cfg *safety_cfg);
+ struct stmmac_safety_feature_cfg *safety_cfg,
+ unsigned int csr_clk_mhz);
int (*safety_feat_irq_status)(struct net_device *ndev,
void __iomem *ioaddr, unsigned int asp,
struct stmmac_safety_stats *stats);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 552840d29668..1b3dd30db6dc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3691,10 +3691,16 @@ static void stmmac_mtl_configuration(struct stmmac_priv *priv)
static void stmmac_safety_feat_configuration(struct stmmac_priv *priv)
{
+ unsigned int csr_clk_mhz = 0;
+
if (priv->dma_cap.asp) {
netdev_info(priv->dev, "Enabling Safety Features\n");
+ if (priv->plat->stmmac_clk)
+ csr_clk_mhz = clk_get_rate(priv->plat->stmmac_clk) /
+ 1000000;
stmmac_safety_feat_config(priv, priv->ioaddr, priv->dma_cap.asp,
- priv->plat->safety_feat_cfg);
+ priv->plat->safety_feat_cfg,
+ csr_clk_mhz);
} else {
netdev_info(priv->dev, "No Safety Features support found\n");
}
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 00be2df63d22..cb470a153bf8 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -168,8 +168,25 @@ struct stmmac_safety_feature_cfg {
u32 edpp;
u32 prtyen;
u32 tmouten;
+ /* FSM normal-mode timeout value (MAC_FSM_ACT_Timer.NTMRMD). The TMR
+ * field (CSR clocks per 1us) is derived from the CSR clock by stmmac.
+ * 0 selects the default 1s timeout.
+ */
+ u32 ntmrmd;
};
+/* MAC_FSM_ACT_Timer.NTMRMD timeout durations */
+#define STMMAC_NTMRMD_1US 0x1
+#define STMMAC_NTMRMD_4MS 0x2
+#define STMMAC_NTMRMD_16MS 0x3
+#define STMMAC_NTMRMD_64MS 0x4
+#define STMMAC_NTMRMD_256MS 0x5
+#define STMMAC_NTMRMD_1SEC 0x6
+#define STMMAC_NTMRMD_4SEC 0x7
+#define STMMAC_NTMRMD_16SEC 0x8
+#define STMMAC_NTMRMD_32SEC 0x9
+#define STMMAC_NTMRMD_64SEC 0xa
+
/* Addresses that may be customized by a platform */
struct dwmac4_addrs {
u32 dma_chan;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] net: stmmac: program the FSM timeout timer
2026-11-12 5:33 [PATCH net-next v2] net: stmmac: program the FSM timeout timer Zxyan Zhu
@ 2026-11-16 5:35 ` netdev-bot+sashiko
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-11-16 5:35 UTC (permalink / raw)
To: zxyan0222
Cc: maxime.chevallier, andrew+netdev, davem, edumazet, kuba, pabeni,
netdev, mcoquelin.stm32, alexandre.torgue, linux-stm32,
linux-arm-kernel, linux-kernel, rmk+kernel
Thank you for your contribution! Sashiko AI review found 7 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 3 · Low: 3
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The XGMAC half of the fix never runs on any in-tree platform.
- [Medium] csr_clk_mhz, which feeds the TMR field ('CSR clocks per 1us
tic'), comes only from clk_get_rate(priv->plat->stmmac_clk) in…
- [Medium] MAC_FSM_ACT_Timer and XGMAC_MAC_FSM_ACT_TIMER are written with
a plain writel() that contains only FIELD_PREP(NTMRMD) |…
- [Medium] The new STMMAC_NTMRMD_* encodings (0x1=1us, 0x2=4ms, 0x3=16ms,
0x4=64ms, 0x5=256ms, 0x6=1s, 0x7=4s, 0x8=16s, 0x9=32s, 0xa=64s) and…
- [Low] The patch turns on a live FSM timeout with a 1s default on every
dwmac4/5 platform with ASP >= 2 that passes no safety config.
- [Low] The patch adds a platform-facing knob, struct
stmmac_safety_feature_cfg.ntmrmd, plus ten STMMAC_NTMRMD_* constants…
- [Low] The commit message describes a functional defect: TMOUTEN is
enabled but the timer is never programmed, so 'the advertised timeout…
--
net: stmmac: program the FSM timeout timer
This patch programs MAC_FSM_ACT_Timer right after TMOUTEN is enabled in
dwmac5_safety_feat_config() and dwxgmac3_safety_feat_config(). The TMR
field comes from the stmmac_clk rate, and NTMRMD defaults to a 1s
timeout. It also adds a csr_clk_mhz argument to the safety_feat_config
callback, a new ntmrmd field and STMMAC_NTMRMD_* constants in
include/linux/stmmac.h.
> v2:
> - Rebased onto net-next.
> - Dropped the Fixes: tags (this never worked, so it's feature completion,
> not a regression fix).
[Severity: Low]
The commit message describes a functional defect. TMOUTEN is enabled but
the timer is never programmed, so "the advertised timeout protection is
ineffective".
Documentation/process/submitting-patches.rst says "A Fixes: tag indicates
that the patch fixes a bug in a previous commit."
Would it be worth keeping the Fixes: tags, so that stable and downstream
safety users can tell which kernels lack working FSM timeout detection?
Given the net-next target, this may be the maintainers' call.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c
> index f1bb981cab7cd..4ab7a3df98c6d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c
[ ... ]
> @@ -245,6 +247,22 @@ int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
> value |= TMOUTEN; /* FSM Timeout Feature */
> writel(value, ioaddr + MAC_FSM_CONTROL);
>
> + /* Program the FSM active timer so the timeout checker actually fires.
> + * TMR is the number of CSR clocks per 1us tic, i.e. csr_clk in MHz.
> + * Default to a 1s timeout when the platform did not select one.
> + */
> + if (safety_feat_cfg->tmouten && csr_clk_mhz) {
[Severity: Low]
This turns on a live 1s FSM timeout on every dwmac4/5 platform with
ASP >= 2 that passes no safety config. A NULL safety_feat_cfg selects
all_safety_feats with tmouten = 1. That covers all the OF glue drivers,
plus mediatek and stmmac_pci.
When the timer fires, the timeout is reported as MCSIS and handled as
uncorrectable:
dwmac5_safety_feat_irq_status() {
...
err = (mtl & MCSIS) || (dma & MCSIS);
corr = false;
if (err) {
dwmac5_handle_mac_err(ndev, ioaddr, corr, stats);
ret |= !corr;
}
...
}
stmmac_safety_feat_interrupt() {
...
if (ret && (ret != -EINVAL)) {
stmmac_global_err(priv);
...
}
The result is carrier off and a full adapter reset, which these boards
never got before this patch.
The commit message only says a stuck FSM will now be "reported". Could
it mention the reset, and explain why 1s is safe on platforms other than
the two IPs that were tested?
> + u32 ntmrmd = safety_feat_cfg->ntmrmd;
> +
> + ntmrmd = (ntmrmd >= STMMAC_NTMRMD_1US &&
> + ntmrmd <= STMMAC_NTMRMD_64SEC) ?
> + ntmrmd : STMMAC_NTMRMD_1SEC;
> +
> + writel(FIELD_PREP(MAC_FSM_ACT_TIMER_NTMRMD, ntmrmd) |
> + FIELD_PREP(MAC_FSM_ACT_TIMER_TMR, csr_clk_mhz),
> + ioaddr + MAC_FSM_ACT_TIMER);
[Severity: Medium]
This is a plain writel() of only NTMRMD and TMR, so every other bit in
MAC_FSM_ACT_Timer is set to 0. dwxgmac3_safety_feat_config() does the
same for XGMAC_MAC_FSM_ACT_TIMER. The MAC_FSM_CONTROL update just above
uses read/modify/write instead.
The patch defines only TMR as GENMASK(9, 0) and NTMRMD as
GENMASK(19, 16). Doesn't the Synopsys EQoS/XGMAC safety register layout
also have a large-mode timeout field (LTMRMD, bits [23:20])?
If LTMRMD exists and 0 also means disabled there, would FSMs checked
against the large-mode timer stay unprotected after this patch? Any
non-zero reset value in those bits would also be cleared.
I couldn't confirm the register layout from in-tree code, so this may
need checking against the databook.
> + }
> +
[ ... ]
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> index 7ad08651675e8..dac85431e7401 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
[ ... ]
> @@ -873,6 +875,22 @@ dwxgmac3_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
> value |= XGMAC_TMOUTEN; /* FSM Timeout Feature */
> writel(value, ioaddr + XGMAC_MAC_FSM_CONTROL);
>
> + /* Program the FSM active timer so the timeout checker actually fires.
> + * TMR is the number of CSR clocks per 1us tic, i.e. csr_clk in MHz.
> + * Default to a 1s timeout when the platform did not select one.
> + */
> + if (safety_cfg && safety_cfg->tmouten && csr_clk_mhz) {
[Severity: High]
Can this block ever run on an in-tree XGMAC platform?
XGMAC_TMOUTEN is set unconditionally just above, but the timer is only
written when safety_cfg is non-NULL. dwmac5_safety_feat_config() falls
back to all features when the cfg is NULL, and this function doesn't:
dwmac5_safety_feat_config() {
...
if (!safety_feat_cfg)
safety_feat_cfg = &all_safety_feats;
...
}
Only three drivers set plat->safety_feat_cfg: dwmac-intel,
dwmac-mediatek and stmmac_pci. None of them is XGMAC. dwmac-socfpga,
dwmac-tegra (MGBE) and generic "snps,dwxgmac" via
stmmac_probe_config_dt() all leave it NULL:
stmmac_hw_setup()
stmmac_safety_feat_configuration()
stmmac_safety_feat_config() /* safety_cfg == NULL */
dwxgmac3_safety_feat_config()
Doesn't that leave every in-tree dwxgmac with TMOUTEN = 1 and NTMRMD at
its reset value of 0? That is the state the commit message calls broken,
and the message says the fix was tested on dwxgmac.
There is also a second mismatch. A platform that supplies a cfg with
tmouten = 0 still gets XGMAC_TMOUTEN armed, but the timer is left
unprogrammed. Should the timer write follow the same condition as the
XGMAC_MAC_FSM_CONTROL write?
[ ... ]
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 552840d29668e..1b3dd30db6dce 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3691,10 +3691,16 @@ static void stmmac_mtl_configuration(struct stmmac_priv *priv)
>
> static void stmmac_safety_feat_configuration(struct stmmac_priv *priv)
> {
> + unsigned int csr_clk_mhz = 0;
> +
> if (priv->dma_cap.asp) {
> netdev_info(priv->dev, "Enabling Safety Features\n");
> + if (priv->plat->stmmac_clk)
> + csr_clk_mhz = clk_get_rate(priv->plat->stmmac_clk) /
> + 1000000;
[Severity: Medium]
What happens when stmmac_clk is NULL or reports a rate of 0?
csr_clk_mhz then stays 0. Both dwmac5_safety_feat_config() and
dwxgmac3_safety_feat_config() skip the MAC_FSM_ACT_TIMER write without
any message, even though TMOUTEN has already been written to
MAC_FSM_CONTROL.
stmmac_clk can be NULL in a few cases:
- An OF platform has no "stmmaceth" clock. stmmac_probe_config_dt() only
warns "Cannot get CSR clock" and sets the clock to NULL.
- clk_register_fixed_rate() fails in dwmac-intel.
The rate is also 0 with the !CONFIG_COMMON_CLK clk_get_rate() stub.
One in-tree case is the Synopsys GMAC5 PCI board. It never sets
stmmac_clk, only clk_csr, yet it explicitly asks for the timeout:
snps_gmac5_default_data() {
...
plat->clk_csr = STMMAC_CSR_250_300M;
...
}
stmmac_pci_probe() {
...
plat->safety_feat_cfg->tmouten = 1;
...
}
On that board the timer is still not programmed after this patch. Could
this fall back to plat->clk_csr or clk_ref_rate? Failing that, could it
at least warn or clear TMOUTEN when the rate is unknown?
This also ignores plat->clk_csr, which stmmac_mdio.c prefers over the
stmmac_clk rate when the platform supplies it. Is stmmac_clk always
clk_csr_i? If it runs slower, the computed tic would be short and the
timeout would fire early.
> stmmac_safety_feat_config(priv, priv->ioaddr, priv->dma_cap.asp,
> - priv->plat->safety_feat_cfg);
> + priv->plat->safety_feat_cfg,
> + csr_clk_mhz);
> } else {
> netdev_info(priv->dev, "No Safety Features support found\n");
> }
> diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
> index 00be2df63d220..cb470a153bf81 100644
> --- a/include/linux/stmmac.h
> +++ b/include/linux/stmmac.h
> @@ -168,8 +168,25 @@ struct stmmac_safety_feature_cfg {
> u32 edpp;
> u32 prtyen;
> u32 tmouten;
> + /* FSM normal-mode timeout value (MAC_FSM_ACT_Timer.NTMRMD). The TMR
> + * field (CSR clocks per 1us) is derived from the CSR clock by stmmac.
> + * 0 selects the default 1s timeout.
> + */
> + u32 ntmrmd;
[Severity: Low]
Is an in-tree user planned for ntmrmd and the STMMAC_NTMRMD_* constants?
Nothing in drivers/net/ethernet/stmicro/stmmac/ sets the field.
dwmac-intel, dwmac-mediatek and stmmac_pci all leave it at 0, and only
the two new consumer blocks read it.
Also, dwmac5_safety_feat_config() and dwxgmac3_safety_feat_config() both
replace an out-of-range value (0xb-0xf) with STMMAC_NTMRMD_1SEC without a
warning. Should that be reported?
> };
>
> +/* MAC_FSM_ACT_Timer.NTMRMD timeout durations */
> +#define STMMAC_NTMRMD_1US 0x1
> +#define STMMAC_NTMRMD_4MS 0x2
> +#define STMMAC_NTMRMD_16MS 0x3
> +#define STMMAC_NTMRMD_64MS 0x4
> +#define STMMAC_NTMRMD_256MS 0x5
> +#define STMMAC_NTMRMD_1SEC 0x6
> +#define STMMAC_NTMRMD_4SEC 0x7
> +#define STMMAC_NTMRMD_16SEC 0x8
> +#define STMMAC_NTMRMD_32SEC 0x9
> +#define STMMAC_NTMRMD_64SEC 0xa
[Severity: Medium]
Where do these encodings come from? There is no in-tree reference for
them. There is also none for TMR being the CSR clock in MHz rather than
MHz - 1. The same table is used for both EQoS 5.x and XGMAC 3.x.
The steps are also irregular: 1us jumps straight to 4ms, then the values
go up in x4 steps, then x2 steps.
Suppose the hardware encodes NTMRMD differently, for example with a
microsecond-scale normal-mode range. The default of 0x6 would then select
a much shorter timeout.
dwmac5_mac_errors treats every FSM timeout (TTES, RTES, CTES, ATES,
PTES, ...) as uncorrectable, and stmmac_safety_feat_interrupt() handles
that with stmmac_global_err().
Could a wrong encoding cause repeated full MAC resets by default on OF
dwmac4/5 boards with ASP >= 2 and a stmmaceth clock? A pointer to the
databook table these values come from would help.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112053321.1103678-1-zxyan0222%40gmail.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-16 5:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 5:33 [PATCH net-next v2] net: stmmac: program the FSM timeout timer Zxyan Zhu
2026-11-16 5:35 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox