mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] net: spacemit: Check netif_carrier_ok when reading stats
@ 2026-01-18 10:00 Chukun Pan
  2026-01-18 16:19 ` Andrew Lunn
  2026-01-19  3:54 ` Vivian Wang
  0 siblings, 2 replies; 6+ messages in thread
From: Chukun Pan @ 2026-01-18 10:00 UTC (permalink / raw)
  To: Vivian Wang
  Cc: Yixun Lan, Paolo Abeni, Jakub Kicinski, Eric Dumazet,
	Andrew Lunn, David S . Miller, linux-riscv, linux-kernel,
	spacemit, netdev, Chukun Pan

Currently, when the interface is not linked up, reading the interface
stats will print several timeout logs. Add a netif_carrier_ok check to
the emac_stats_update function to avoid this situation:

root@OpenWrt:~# ubus call network.device status
[  120.365060] k1_emac cac81000.ethernet eth1: Read stat timeout

Fixes: bfec6d7f2001 ("net: spacemit: Add K1 Ethernet MAC")
Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
---
 drivers/net/ethernet/spacemit/k1_emac.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/spacemit/k1_emac.c b/drivers/net/ethernet/spacemit/k1_emac.c
index c85dc742c404..d7972f247bcc 100644
--- a/drivers/net/ethernet/spacemit/k1_emac.c
+++ b/drivers/net/ethernet/spacemit/k1_emac.c
@@ -1080,8 +1080,10 @@ static void emac_stats_update(struct emac_priv *priv)
 
 	assert_spin_locked(&priv->stats_lock);
 
-	if (!netif_running(priv->ndev) || !netif_device_present(priv->ndev)) {
-		/* Not up, don't try to update */
+	if (!netif_running(priv->ndev) ||
+	    !netif_carrier_ok(priv->ndev) ||
+	    !netif_device_present(priv->ndev)) {
+		/* Not up or link, don't try to update */
 		return;
 	}
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-20  4:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-18 10:00 [PATCH 1/1] net: spacemit: Check netif_carrier_ok when reading stats Chukun Pan
2026-01-18 16:19 ` Andrew Lunn
2026-01-19  3:54 ` Vivian Wang
2026-01-19 14:16   ` Chukun Pan
2026-01-19 15:09     ` Andrew Lunn
2026-01-20  4:16       ` Vivian Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®