Re: [PATCH net-next v4] net: stmmac: program the FSM timeout timer

From: zhu xin

Date: Wed Nov 25 2026 - 03:22:57 EST


Hi Maxime,

On Wed, Nov 25, 2026 at 12:13 AM Maxime Chevallier
<maxime.chevallier@xxxxxxxxxxx> wrote:
>
>
>
> On 11/20/26 22:17, netdev-bot+sashiko@xxxxxxxxxx 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_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.
> >
> >> 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@xxxxxxxxx>
>
> [...]
>
> > [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?
>
> 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.

>
> Maxime

> [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.

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