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

* Re: [PATCH RFC] increase i2c_mii_poll timeout for very slow SFP modules
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Russell King (Oracle) @ 2025-09-29 13:27 UTC (permalink / raw)
  To: Janpieter Sollie
  Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, Marek Behún

On Mon, Sep 29, 2025 at 01:44:24PM +0200, Janpieter Sollie wrote:
> 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.

Your persistent attempts to differentiate between the platforms that
this code was developed on (allegedly, according to you, "high
performance") and your "embedded devices" is becoming very very
wearing.

Please come back when you've changed your attitude.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH RFC] increase i2c_mii_poll timeout for very slow SFP modules
  2025-09-29 13:27 ` Russell King (Oracle)
@ 2025-09-30 12:41   ` Janpieter Sollie
  0 siblings, 0 replies; 3+ messages in thread
From: Janpieter Sollie @ 2025-09-30 12:41 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, Marek Behún

Op 29/09/2025 om 15:27 schreef Russell King (Oracle):
> Your persistent attempts to differentiate between the platforms that
> this code was developed on (allegedly, according to you, "high
> performance") and your "embedded devices" is becoming very very
> wearing.
I was surprised reading this.
The code of Marek seems to work since 2023, very few modifications have been made.
I assume it has been tested + used many many times, and nobody ever had problems.

Why target embedded devices?
I also assumed the major use of this code are corporations using enterprise setups.
Whatever device Marek his code was developed for,
It seems to be stable with a total wait of +- 200ms targeting 70ms, for every user using it.
Me using rare setups -> me trying to fix a almost nonexistent situation.
The BPI people suggested it *might* be a power problem.

The phy is known to work correctly, AQR113C has been supported for quite some time now.
I can't imagine the SFP module vendor sells a not-linux-compatible EEPROM which needs > 200 ms.
There must be something inside the module that's slowing down for whatever reason.

So is it wearing?  Yes.

Using your hints, I saw the i2c_transfer_rollball() call takes 10ms to execute,
with a 20ms sleep this is 33% of one loop querying the endpoint for an answer.
If it would have been 10% or even less, I'd simply say:
"increase i to 20, query a few more times".
But in this case I'd rather not.

> Please come back when you've changed your attitude.
>
> Thanks.
>

No worries, you gave me the knowledge I needed to fix it.
If it's that rare, it should not be implemented at all.
I hope my clarification explains.  I've overthought things more-than-once.

Thanks

^ 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).