netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] increase i2c_mii_poll timeout for very slow SFP modules
@ 2025-09-29 11:44 Janpieter Sollie
  2025-09-29 13:27 ` Russell King (Oracle)
  0 siblings, 1 reply; 3+ messages in thread
From: Janpieter Sollie @ 2025-09-29 11:44 UTC (permalink / raw)
  To: Russell King (Oracle), Andrew Lunn, Heiner Kallweit,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, Marek Behún

originally developed by Marek,
commit 09bbedac72d5a9267088c15d1a71c8c3a8fb47e7

while most SFP cages do function properly in i2c_rollball_mii_poll(),
SFP+ modules from no-name vendors  seem to behave slowly.
This gets even worse on embedded devices,
where power constraints are in place.
i2c_rollball_mii_poll() could timeout here.

dynamically increase waiting time, so the phy gets more time to finish the job.
It it beyond my knowledge how much the target gets interrupted by a poll() call.

A better method might be to add a kconfig option "allow very slow SFP MDIO",
so strict timeout errors can be detected where useful,
and be avoided when the kernel is built to work on embedded devices.

Janpieter Sollie

--- a/drivers/net/mdio/mdio-i2c.c       2025-09-19 16:35:52.000000000 +0200
+++ b/drivers/net/mdio/mdio-i2c.c       2025-09-27 14:11:59.406323627 +0200
@@ -248,12 +248,15 @@ static int i2c_rollball_mii_poll(struct mii_bus *bus, int bus_addr, u8 *buf,
         msgs[1].len = len;
         msgs[1].buf = res;

-       /* By experiment it takes up to 70 ms to access a register for these
-        * SFPs. Sleep 20ms between iterations and try 10 times.
+       /* By experiment it takes  up to 70 ms
+        * to access a register for normal SFPs.
+        * Sleep at least 20ms between iterations and try 10 times.
+        * Slower modules on embedded devices may need more.
+        * Dynamically increase sleep to avoid wasted i2c_transfer_rollball() calls
          */
         i = 10;
         do {
-               msleep(20);
+               msleep(20+2*(10-i));

                 ret = i2c_transfer_rollball(i2c, msgs, ARRAY_SIZE(msgs));
                 if (ret)


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

end of thread, other threads:[~2025-09-30 12:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 11:44 [PATCH RFC] increase i2c_mii_poll timeout for very slow SFP modules Janpieter Sollie
2025-09-29 13:27 ` Russell King (Oracle)
2025-09-30 12:41   ` Janpieter Sollie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).