[PATCH net v2 2/6] net: stmmac: selftests: Validate EEE based on the actual LPI timer value

Nicolai Buchwitz nb at tipi-net.de
Thu Sep 10 11:50:30 PDT 2026


Hi Maxime,

Sorry for the noise, but after having a second look, there is something
which I think should be discussed at least.

On 10.9.2026 17:13, Maxime Chevallier wrote:
> The EEE selftest is a 2-step test :
>  - It validates that we enter in LPI mode with the
>    irq_tx_path_in_lpi_mode_n counter
>  - It then validates that we exit LPI when sending a frame, with the
>    irq_tx_path_exit_lpi_mode_n counter.
> 
> The current state of the test lacks 2 main things :
> 
>  - We don't know exactly when was the previous frame sent (it's from 
> the
>    previous selftest)
> 
>  - The timeout is hardcoded, while the LPI is entered after a
>    user-configurable delay. On top of that, the timeout loop uses a
>    pre-decrement iterator (--retries) that actually only iterate nine
>    times, so 900ms while the default LPI value is 1 second.
> 
> Let's therefore make it more deterministic :
> 
>  - Send a frame at the beginning of the test
>  - Wait for more than the lpi timer value, we timeout after about twice
>    the value,
>  - Then send another frame, and verify that we do go out of LPI, also
>    with a timeout.
> 
> Note that the test's goal isn't to validate the LPI timer value itself,
> only that we enter/leave LPI mode.
> 
> Fixes: 091810dbded9 ("net: stmmac: Introduce selftests support")
> Signed-off-by: Maxime Chevallier <maxime.chevallier at bootlin.com>
> ---
> [...]

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c 
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
> [...]

> 
> +	max_duration = usecs_to_jiffies(2 * priv->tx_lpi_timer);

tx_lpi_timer comes direct from ethtool as an unvalidated u32. So if a 
(arguable privileged
user) does 'ethtool --set-eee eth0 tx-lpi-timer 1000000000', the code 
will sleep ~2000 seconds
under rtnl_lock. Tge old code capped it at 900 ms regardless of the 
timer.

Thus I think we should clamp it at some sane value. Feel free to keep my 
R-b with the clamp.

> [...]

Regards,
Nicolai



More information about the linux-arm-kernel mailing list