100, 10000);
if (ret) {
- netdev_err(priv->ndev, "Read stat timeout\n");
+ /*
+ * This could be caused by the PHY stopping its refclk even when
+ * the link is up, for power saving. See also comments in
+ * emac_stats_update().
+ */
+ dev_err_ratelimited(&priv->ndev->dev,
+ "Read stat timeout. PHY clock stopped?\n");
return ret;
}
assert_spin_locked(&priv->stats_lock);
- if (!netif_running(priv->ndev) || !netif_device_present(priv->ndev)) {
- /* Not up, don't try to update */
+ /*
+ * We can't read statistics if the interface is not up. Also, some PHYs
+ * stop their reference clocks for link down power saving, which also
+ * causes reading statistics to time out. Don't update and don't
+ * reschedule in these cases.
+ */
+ if (!netif_running(priv->ndev) ||
+ !netif_carrier_ok(priv->ndev) ||
+ !netif_device_present(priv->ndev)) {
return;
}
for (i = 0; i < sizeof(priv->tx_stats) / sizeof(*tx_stats); i++) {
/*
- * If reading stats times out, everything is broken and there's
- * nothing we can do. Reading statistics also can't return an
- * error, so just return without updating and without
- * rescheduling.
+ * If reading stats times out anyway, the stat registers will be
+ * stuck, and we can't really recover from that.
+ *
+ * Reading statistics also can't return an error, so just return
+ * without updating and without rescheduling.
*/
if (emac_tx_read_stat_cnt(priv, i, &res))
return;
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);