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

Maxime Chevallier maxime.chevallier at bootlin.com
Thu Nov 26 00:06:54 PST 2026


Hi,

On 11/25/26 12:19, Zxyan Zhu wrote:
> 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
> 4s timeout.  4s is chosen because a PAUSE frame with the maximum 0xffff
> quanta stalls the transmitter for about 3.36s at 10 Mb/s, and a shorter
> timeout could wrongly report a flow-control stall as a stuck FSM.
> 
> 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.
> 
> Signed-off-by: Zxyan Zhu <zxyan0222 at gmail.com>

[...]

> diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
> index 00be2df63d22..659f5db528d3 100644
> --- a/include/linux/stmmac.h
> +++ b/include/linux/stmmac.h
> @@ -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

This whole patch starts to look good, one last comment, sorry I
didn't spot this before. Can you put all these definitions
in the "common.h" file in the driver folder ? These are some
register values (same on dwmac5 and xgmac, but still), so they
should go there.

With that changed, you can send a new iteration with

  Reviewed-by: Maxime Chevallier <maxime.chevallier at bootlin.com>

Thanks,

Maxime

pw-bot: cr





More information about the linux-arm-kernel mailing list