Re: [PATCH net v3] net: spacemit: Check for netif_carrier_ok() in emac_stats_update(): manual merge
From: Matthieu Baerts
Date: Tue Jan 27 2026 - 06:03:28 EST
Hi Vivian,
+cc Mark Brown
On 23/01/2026 04:52, Vivian Wang wrote:
> Some PHYs stop the refclk for power saving, usually while link down.
> This causes reading stats to time out.
>
> Therefore, in emac_stats_update(), also don't update and reschedule if
> !netif_carrier_ok(). But that means we could be missing later updates if
> the link comes back up, so also reschedule when link up is detected in
> emac_adjust_link().
>
> While we're at it, improve the comments and error message prints around
> this to reflect the better understanding of how this could happen.
> Hopefully if this happens again on new hardware, these comments will
> direct towards a solution.
(...)
> ---
> This has a conflict in context lines in emac_adjust_link() with current
> net-next, which will show up when pulling that for next rc1. Just remove
> "emac_set_fc_autoneg(priv);".
Thank you for this note, this was useful! Just in case it can be useful
for linux-next and Net maintainers, I confirm the conflict when merging
'net' in 'net-next' due to this patch applied in 'net':
2c84959167d6 ("net: spacemit: Check for netif_carrier_ok() in
emac_stats_update()")
and this one from 'net-next':
f66086798f91 ("net: spacemit: Remove broken flow control support")
The resolution is attached to this email, and rerere cache is available
there:
https://github.com/multipath-tcp/mptcp-upstream-rr-cache/commit/526c74b
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
diff --cc drivers/net/ethernet/spacemit/k1_emac.c
index c85dc742c404,88e9424d2d51..23b6f1531e0c
--- a/drivers/net/ethernet/spacemit/k1_emac.c
+++ b/drivers/net/ethernet/spacemit/k1_emac.c
@@@ -1531,6 -1648,14 +1545,12 @@@ static void emac_adjust_link(struct net
}
emac_wr(priv, MAC_GLOBAL_CONTROL, ctrl);
+
- emac_set_fc_autoneg(priv);
-
+ /*
+ * Reschedule stats updates now that link is up. See comments in
+ * emac_stats_update().
+ */
+ mod_timer(&priv->stats_timer, jiffies);
}
phy_print_status(phydev);