[PATCH net v2 1/3] net: phy: enable polling when driver implements get_next_update_time

Oleksij Rempel posted 3 patches 3 months ago
There is a newer version of this series
[PATCH net v2 1/3] net: phy: enable polling when driver implements get_next_update_time
Posted by Oleksij Rempel 3 months ago
Currently, phy_polling_mode() enables polling only if:
- the PHY is in interrupt-less mode, or
- the driver provides an update_stats() callback.

This excludes drivers that implement get_next_update_time()
to support adaptive polling but do not provide update_stats().
As a result, the state machine timer will not run, and the
get_next_update_time() callback is never used.

This patch extends the polling condition to include drivers that
implement get_next_update_time(). This change is required to support
adaptive polling in the SMSC LAN9512/LAN8700 PHY family, which cannot
reliably use interrupts.

No in-tree drivers rely on this mechanism yet, so existing behavior is
unchanged. If any out-of-tree driver incorrectly implements
get_next_update_time(), enabling polling is still the correct behavior.

Fixes: 8bf47e4d7b87 ("net: phy: Add support for driver-specific next update time")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
changes v2:
- update commit message
---
 include/linux/phy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 543a94751a6b..3d4e5c41235e 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1632,7 +1632,7 @@ static inline bool phy_polling_mode(struct phy_device *phydev)
 		if (phydev->drv->flags & PHY_POLL_CABLE_TEST)
 			return true;
 
-	if (phydev->drv->update_stats)
+	if (phydev->drv->update_stats || phydev->drv->get_next_update_time)
 		return true;
 
 	return phydev->irq == PHY_POLL;
-- 
2.39.5
Re: [PATCH net v2 1/3] net: phy: enable polling when driver implements get_next_update_time
Posted by Andrew Lunn 2 months, 4 weeks ago
On Wed, Jul 09, 2025 at 12:42:08PM +0200, Oleksij Rempel wrote:
> Currently, phy_polling_mode() enables polling only if:
> - the PHY is in interrupt-less mode, or
> - the driver provides an update_stats() callback.
> 
> This excludes drivers that implement get_next_update_time()
> to support adaptive polling but do not provide update_stats().
> As a result, the state machine timer will not run, and the
> get_next_update_time() callback is never used.
> 
> This patch extends the polling condition to include drivers that
> implement get_next_update_time(). This change is required to support
> adaptive polling in the SMSC LAN9512/LAN8700 PHY family, which cannot
> reliably use interrupts.
> 
> No in-tree drivers rely on this mechanism yet, so existing behavior is
> unchanged. If any out-of-tree driver incorrectly implements
> get_next_update_time(), enabling polling is still the correct behavior.
> 
> Fixes: 8bf47e4d7b87 ("net: phy: Add support for driver-specific next update time")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew