net: stmmac: program the FSM timeout timer
Subsystems (4)
PATCH v4 1/1 net: stmmac: program the FSM timeout timer
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 using a 1s timeout.
The NTMRMD field holds a power-of-two microsecond timeout per the
databook: 0x0 disables it, and 0x1..0xa encode 1us, 1.024ms (~1ms), 16.384ms (~16ms), 65.536ms (~64ms), 262.144ms (~256ms), 1.048s (~1s), 4.194s (~4s), 16.777s (~16s), 33.554s (~32s), 67.108s (~64s).
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.
---
v4:
- Drop the warning on a missing CSR clock.
- Drop the ntmrmd field and hardcode the 1s timeout (NTMRMD = 0x6).
v3: https://lore.kernel.org/netdev/[email protected]/
v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/
drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 17 ++++++++++++++++- drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 6 +++++- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 3 +++ .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 18 +++++++++++++++++- drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 ++- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +++++++- include/linux/stmmac.h | 12 ++++++++++++ 7 files changed, 62 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +16 -1
@@ -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,19 @@ 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. +* Use a 1s timeout. +*/ +if (safety_feat_cfg->tmouten && csr_clk_mhz) { + value =readl (ioaddr +MAC_FSM_ACT_TIMER ); + value &= ~(MAC_FSM_ACT_TIMER_NTMRMD |MAC_FSM_ACT_TIMER_TMR ); + value |=FIELD_PREP (MAC_FSM_ACT_TIMER_NTMRMD , +STMMAC_NTMRMD_1SEC ) | +FIELD_PREP (MAC_FSM_ACT_TIMER_TMR , csr_clk_mhz); +writel (value, ioaddr +MAC_FSM_ACT_TIMER ); + } +/* 4. Enable Data Parity Protection */ value =readl (ioaddr +MTL_DPP_CONTROL );if (safety_feat_cfg->edpp)
drivers/net/ethernet/stmicro/stmmac/dwmac5.h +5 -1
@@ -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);
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +3 -0
@@ -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
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +17 -1
@@ -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,20 @@ 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. +* Use a 1s timeout. +*/ +if (safety_cfg && safety_cfg->tmouten && csr_clk_mhz) { + value =readl (ioaddr +XGMAC_MAC_FSM_ACT_TIMER ); + value &= ~(XGMAC_MAC_FSM_ACT_TIMER_NTMRMD | +XGMAC_MAC_FSM_ACT_TIMER_TMR ); + value |=FIELD_PREP (XGMAC_MAC_FSM_ACT_TIMER_NTMRMD , +STMMAC_NTMRMD_1SEC ) | +FIELD_PREP (XGMAC_MAC_FSM_ACT_TIMER_TMR , csr_clk_mhz); +writel (value, 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 */
drivers/net/ethernet/stmicro/stmmac/hwif.h +2 -1
@@ -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);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7 -1
@@ -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" ); }
include/linux/stmmac.h +12 -0
@@ -170,6 +170,18 @@ struct stmmac_safety_feature_cfg {u32 tmouten; }; +/* MAC_FSM_ACT_Timer.NTMRMD timeout durations */ +#define STMMAC_NTMRMD_1US 0x1 +#define STMMAC_NTMRMD_1MS 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;
Signature · 1 line
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · 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] On every in-tree XGMAC platform, the XGMAC half of the fix never runs.
- [Medium] csr_clk_mhz is only computed when priv->plat->stmmac_clk is non-NULL.
- [Medium] The patch turns on an FSM timeout check that resets the interface, with a hardcoded NTMRMD = 0x6 (about 1 s) for every…
- [Low] The commit is written as a bug fix: the protection is 'ineffective' and a stuck FSM 'was not reported through the safety…
- [Low] The patch adds ten STMMAC_NTMRMD_* register-encoding macros (1US .. 64SEC) to include/linux/stmmac.h, the platform-data header shared…
- [Low] The same clock (stmmac_clk) is converted into a 'CSR clocks per 1us tic' register value in two places that use different conventions.
--
net: stmmac: program the FSM timeout timer
This patch programs MAC_FSM_ACT_Timer on dwmac5 and dwxgmac3 cores after TMOUTEN is enabled. TMR is set from the CSR clock rate in MHz, and NTMRMD is set to a fixed 1s timeout. A csr_clk_mhz argument is added to the safety_feat_config callback, and NTMRMD encoding macros are added to include/linux/stmmac.h.
Quoted 4 lines
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 <[email protected]>
[Severity: Low]
This describes a user-visible functional failure, but there is no Fixes:
tag. Should this carry Fixes: tags for the commits that added TMOUTEN to dwmac5_safety_feat_config() and dwxgmac3_safety_feat_config() without programming the timer, so stable has a reference for backporting?
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +0
-0
[ ... ]
drivers/net/ethernet/stmicro/stmmac/dwmac5.c int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp, · line 258
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +9
-0@@ -245,6 +247,19 @@ 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. +* Use a 1s timeout. +*/ +if (safety_feat_cfg->tmouten && csr_clk_mhz) { + value =readl (ioaddr +MAC_FSM_ACT_TIMER ); + value &= ~(MAC_FSM_ACT_TIMER_NTMRMD |MAC_FSM_ACT_TIMER_TMR ); + value |=FIELD_PREP (MAC_FSM_ACT_TIMER_NTMRMD , + STMMAC_NTMRMD_1SEC) |
[Severity: Medium]
Is a fixed 1s timeout long enough at every link speed? A link partner can send PAUSE frames with a quanta of 0xffff. At 10Mb/s that holds off the transmitter for:
65535 * 512 / 10e6 ~= 3.36s
That is longer than the ~1.048s selected here. At 100Mb/s it is around 335ms.
If the TX FSM timeout is measured against NTMRMD during a flow-control stall, could a legitimate PAUSE stall at 10Mb/s raise a timeout error?
FSM timeout errors arrive through MCSIS, and dwmac5_safety_feat_irq_status() always treats them as uncorrectable:
err = (mtl & MCSIS) || (dma & MCSIS);
corr = false;That would go through stmmac_safety_feat_interrupt()->stmmac_global_err() and reset the interface. Before this patch the timer was disabled, so this path could not trigger. dwxgmac3_safety_feat_config() uses the same fixed value.
Only NTMRMD and TMR are written here. The other fields of MAC_FSM_ACT_Timer stay at their read-back values. Can the databook confirm whether pause-stalled TX FSMs are covered by NTMRMD rather than by a separate large-mode timeout?
drivers/net/ethernet/stmicro/stmmac/dwmac5.c int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp, · line 259
Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +1
-0+FIELD_PREP (MAC_FSM_ACT_TIMER_TMR , csr_clk_mhz);
[Severity: Low]
The comment says TMR is csr_clk in MHz. However, dwmac4_core_init() programs the existing 1us tic counter from the same clock with a minus one:
writel((clk_rate / 1000000) - 1,
ioaddr + GMAC4_MAC_ONEUS_TIC_COUNTER);Does TMR use the same minus-one encoding? If it does, each tic would be one CSR clock too long. If it doesn't, could the comment say why it differs from GMAC4_MAC_ONEUS_TIC_COUNTER? The same question applies to the XGMAC_MAC_FSM_ACT_TIMER_TMR write in dwxgmac3_safety_feat_config().
Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +3
-0+writel (value, ioaddr +MAC_FSM_ACT_TIMER ); + } +
[ ... ]
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +0
-0
[ ... ]
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c dwxgmac3_safety_feat_config(void __iomem *ioaddr, unsigned int asp, · line 882
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +5
-0@@ -873,6 +875,20 @@ 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. +* Use a 1s timeout. +*/ +if (safety_cfg && safety_cfg->tmouten && csr_clk_mhz) {
[Severity: High]XGMAC_TMOUTEN is set just above without looking at safety_cfg, but the timer is only programmed when safety_cfg is non-NULL. Does any XGMAC platform set plat->safety_feat_cfg?
The generic snps,dwxgmac path in stmmac_probe_config_dt(), dwmac-socfpga.c and dwmac-tegra.c all appear to leave it NULL. Only dwmac-intel.c, dwmac-mediatek.c and stmmac_pci.c allocate it, and all three are GMAC4 cores.
In that case stmmac_safety_feat_configuration() passes NULL and this check short-circuits. NTMRMD stays at 0 with TMOUTEN set, which is the dwxgmac state the commit message says it fixes.
dwmac5_safety_feat_config() handles a NULL cfg by substituting all_safety_feats:
if (!safety_feat_cfg)
safety_feat_cfg = &all_safety_feats;Should the XGMAC check match how TMOUTEN is enabled? For example, (!safety_cfg || safety_cfg->tmouten) && csr_clk_mhz, or just csr_clk_mhz, since TMOUTEN is set unconditionally.
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +9
-0+ value =readl (ioaddr +XGMAC_MAC_FSM_ACT_TIMER ); + value &= ~(XGMAC_MAC_FSM_ACT_TIMER_NTMRMD | +XGMAC_MAC_FSM_ACT_TIMER_TMR ); + value |=FIELD_PREP (XGMAC_MAC_FSM_ACT_TIMER_NTMRMD , +STMMAC_NTMRMD_1SEC ) | +FIELD_PREP (XGMAC_MAC_FSM_ACT_TIMER_TMR , csr_clk_mhz); +writel (value, ioaddr +XGMAC_MAC_FSM_ACT_TIMER ); + } +
[ ... ]
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_mtl_configuration(struct stmmac_priv *priv) · line 3700
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5
-0@@ -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]
When priv->plat->stmmac_clk is NULL, csr_clk_mhz stays 0. dwmac5_safety_feat_config() then still sets TMOUTEN but silently skips the MAC_FSM_ACT_Timer write. Doesn't that leave the timer disabled on the in-tree platforms that explicitly request tmouten?
stmmac_pci_probe() sets plat->safety_feat_cfg->tmouten = 1 for the snps gmac5 device but never sets plat->stmmac_clk. snps_gmac5_default_data only sets clk_csr = STMMAC_CSR_250_300M.
mediatek_dwmac_common_data() also sets tmouten = 1, but stmmac_probe_config_dt() only looks up the "stmmaceth" clock:
plat->stmmac_clk = devm_clk_get(&pdev->dev,
STMMAC_RESOURCE_NAME);
if (IS_ERR(plat->stmmac_clk)) {
dev_warn(&pdev->dev, "Cannot get CSR clock\n");
plat->stmmac_clk = NULL;The mt2712e/mt8188/mt8195 DTs don't provide a clock with that name.
On both platforms TMOUTEN ends up set with NTMRMD == 0, and nothing is logged. Could this fall back to plat->clk_csr, or at least report that the timer could not be programmed?
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-1stmmac_safety_feat_config (priv, priv->ioaddr, priv->dma_cap.asp, - priv->plat->safety_feat_cfg); + priv->plat->safety_feat_cfg, + csr_clk_mhz);
[ ... ]
Quoted 9 lines
include/linux/stmmac.h +1
-0@@ -170,6 +170,18 @@ struct stmmac_safety_feature_cfg {u32 tmouten; }; +/* MAC_FSM_ACT_Timer.NTMRMD timeout durations */
include/linux/stmmac.h struct stmmac_safety_feature_cfg { · line 183
Quoted 10 lines
include/linux/stmmac.h +10
-0+#define STMMAC_NTMRMD_1US 0x1 +#define STMMAC_NTMRMD_1MS 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: Low]
This isn't a bug, but only STMMAC_NTMRMD_1SEC is used, and only from dwmac5.c and dwxgmac2_core.c. Since v4 dropped the ntmrmd field, platforms can't select any of the other values.
Would it be better to define just the one value next to the MAC_FSM_ACT_TIMER field definitions in dwmac5.h and dwxgmac2.h, rather than adding the full table to the shared platform header?
Quoted 4 lines
include/linux/stmmac.h +1
-0+/* Addresses that may be customized by a platform */ struct dwmac4_addrs {u32 dma_chan;
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118025528.2703790-1-zxyan0222%40gmail.com
Maxime Chevallier
maintainerQuoted 38 lines · On 11/20/26 22:17, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · 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] On every in-tree XGMAC platform, the XGMAC half of the fix never runs.
- [Medium]csr_clk_mhzis only computed whenpriv->plat->stmmac_clkis non-NULL.
- [Medium] The patch turns on an FSM timeout check that resets the interface, with a hardcoded NTMRMD =0x6(about 1 s) for every…
- [Low] The commit is written as a bug fix: the protection is 'ineffective' and a stuck FSM 'was not reported through the safety…
- [Low] The patch adds ten STMMAC_NTMRMD_* register-encoding macros (1US .. 64SEC) toinclude/linux/stmmac.h, the platform-data header shared…
- [Low] The same clock (stmmac_clk) is converted into a 'CSR clocks per 1us tic' register value in two places that use different conventions.--
net: stmmac: program the FSM timeout timer
This patch programs
MAC_FSM_ACT_Timeron dwmac5 and dwxgmac3 cores after TMOUTEN is enabled. TMR is set from the CSR clock rate in MHz, and NTMRMD is set to a fixed 1s timeout. Acsr_clk_mhzargument is added to thesafety_feat_configcallback, and NTMRMD encoding macros are added toinclude/linux/stmmac.h.Quoted 4 lines
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 <[email protected]>
[...]
Quoted 4 lines
[Severity: High]
XGMAC_TMOUTENis set just above without looking atsafety_cfg, but the timer is only programmed whensafety_cfgis non-NULL. Does any XGMAC platform setplat->safety_feat_cfg?
This looks valid, on what xgmac platform did you test that ?
Maxime
Hi Maxime,
Quoted 43 lines · Maxime Chevallier
Quoted 26 lines · On 11/20/26 22:17, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · 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] On every in-tree XGMAC platform, the XGMAC half of the fix never runs.
- [Medium]csr_clk_mhzis only computed whenpriv->plat->stmmac_clkis non-NULL.
- [Medium] The patch turns on an FSM timeout check that resets the interface, with a hardcoded NTMRMD =0x6(about 1 s) for every…
- [Low] The commit is written as a bug fix: the protection is 'ineffective' and a stuck FSM 'was not reported through the safety…
- [Low] The patch adds ten STMMAC_NTMRMD_* register-encoding macros (1US .. 64SEC) toinclude/linux/stmmac.h, the platform-data header shared…
- [Low] The same clock (stmmac_clk) is converted into a 'CSR clocks per 1us tic' register value in two places that use different conventions.--
Quoted 12 lines
net: stmmac: program the FSM timeout timer
This patch programs
MAC_FSM_ACT_Timeron dwmac5 and dwxgmac3 cores after TMOUTEN is enabled. TMR is set from the CSR clock rate in MHz, and NTMRMD is set to a fixed 1s timeout. Acsr_clk_mhzargument is added to thesafety_feat_configcallback, and NTMRMD encoding macros are added toinclude/linux/stmmac.h.Quoted 4 lines
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 <[email protected]>
Quoted 8 lines
[...]
Quoted 4 lines
[Severity: High]
XGMAC_TMOUTENis set just above without looking atsafety_cfg, but the timer is only programmed whensafety_cfgis non-NULL. Does any XGMAC platform setplat->safety_feat_cfg?This looks valid, on what xgmac platform did you test that ?
Agreed, it's a real gap. The dwxgmac path was tested on a downstream platform whose glue does allocate safety_feat_cfg; none of the in-tree XGMAC platforms (dwmac-tegra, dwmac-socfpga) set it, so the timer write never runs there.
In the next revision I'll make the timer write unconditional, matching the unconditional XGMAC_TMOUTEN set just above, so NULL-config platforms program it too. Adding an all_safety_feats fallback (like dwmac5 has) and gating PRTYEN/TMOUTEN on the config is better done as a separate patch.
Quoted 8 lines
Maxime
[Severity: Medium]
Is a fixed 1s timeout long enough at every link speed? A link partner can send PAUSE frames with a quanta of0xffff. At 10Mb/s that holds off the transmitter for:
Quoted 4 lines
65535 * 512 / 10e6 ~= 3.36sThat is longer than the ~1.048s selected here. At 100Mb/s it is around 335ms.
Separately, I'd like your take on the hardcoded 1s timeout. At 10 Mb/s a PAUSE frame with the maximum 0xffff quanta stalls the transmitter for about 3.36s, longer than the ~1.048s NTMRMD programmed here. If the Tx FSM is still timed during a flow-control stall, that would raise a spurious FSM timeout and reset the interface. I don't have a 10 Mb/s link locally to verify it, and the databook only hints at a large-mode (LTMRMD) without being explicit. Would you prefer bumping the default to 4s to be safe, or is 1s acceptable?
Best regards,
Zxyan Zhu
Maxime Chevallier
maintainerQuoted 11 lines · zhu xin
Hi Maxime,
Separately, I'd like your take on the hardcoded 1s timeout. At 10 Mb/s a PAUSE frame with the maximum
0xffffquanta stalls the transmitter for about 3.36s, longer than the ~1.048s NTMRMD programmed here. If the Tx FSM is still timed during a flow-control stall, that would raise a spurious FSM timeout and reset the interface. I don't have a 10 Mb/s link locally to verify it, and the databook only hints at a large-mode (LTMRMD) without being explicit. Would you prefer bumping the default to 4s to be safe, or is 1s acceptable?
Yup, this should do the trick. If I'm not mistaken, you'll add some better controls once you start upstreaming the glue for your XGMAC device, right ?
Maxime
Hi Maxime,
Quoted 16 lines · Maxime Chevallier
Quoted 11 lines · zhu xin
Hi Maxime,
Separately, I'd like your take on the hardcoded 1s timeout. At 10 Mb/s a PAUSE frame with the maximum
0xffffquanta stalls the transmitter for about 3.36s, longer than the ~1.048s NTMRMD programmed here. If the Tx FSM is still timed during a flow-control stall, that would raise a spurious FSM timeout and reset the interface. I don't have a 10 Mb/s link locally to verify it, and the databook only hints at a large-mode (LTMRMD) without being explicit. Would you prefer bumping the default to 4s to be safe, or is 1s acceptable?
Quoted 3 lines
Yup, this should do the trick. If I'm not mistaken, you'll add some better controls once you start upstreaming the glue for your XGMAC device, right ?
Right, I'll use a 4s timeout for now, and add a per-platform timeout config along with the glue once that goes upstream.
Thanks,
Zxyan
Quoted 3 lines
Maxime