netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] increase MDIO i2c poll timeout gradually (including patch)
@ 2025-09-19 13:52 Janpieter Sollie
  2025-09-19 17:04 ` Andrew Lunn
  0 siblings, 1 reply; 15+ messages in thread
From: Janpieter Sollie @ 2025-09-19 13:52 UTC (permalink / raw)
  To: netdev

Hello everyone,

I tested a SFP module where the i2c bus is "unstable" at best.
different i2c timeouts occured, resulting in a "phy not detected" error message.
A simple (but not revealing a lot) stack dump during probe::

 > mdio_i2c_alloc (drivers/net/mdio/mdio-i2c.c:268) mdio_i2c
 > mdio_i2c_alloc (drivers/net/mdio/mdio-i2c.c:316) mdio_i2c
 > __mdiobus_c45_read (drivers/net/phy/mdio_bus.c:992)
 > mdiobus_c45_read (drivers/net/phy/mdio_bus.c:1133)
 > get_phy_c45_ids (drivers/net/phy/phy_device.c:947)
 > get_phy_device (drivers/net/phy/phy_device.c:1054)
 > init_module (drivers/net/phy/sfp.c:1820) sfp
 > cleanup_module (drivers/net/phy/sfp.c:1956 drivers/net/phy/sfp.c:2667 
drivers/net/phy/sfp.c:2748) sfp
 > cleanup_module (drivers/net/phy/sfp.c:2760 drivers/net/phy/sfp.c:2892) sfp
 > process_one_work (./arch/arm64/include/asm/jump_label.h:32 ./include/linux/jump_label.h:207)
 > worker_thread (kernel/workqueue.c:3304 (discriminator 2) kernel/workqueue.c:3391 
(discriminator 2))
 > kthread (kernel/kthread.c:389)
 > ret_from_fork (arch/arm64/kernel/entry.S:863)

I noticed a few hard-coded numbers in i2c_rollball_mii_pol(), which is always suspicious.
In order to lower the stress on the i2c bus, I made the following patch.
is it the best way to "not-stress-sensitive-devices"?
Will it cause a performance regression on some other SFP cages?

Eric Woudstra told me another option was to add a few tries, increasing i = 10,
If the issue isn't the device itself, but the stress on the i2c bus is too high, it may not be a 
real solution.

A good question may be: is this approach sufficient to close the gap between
"high performance" equipment having a stable i2c bus and they do not want to wait,
and embedded equipment (the device I tested on was a BPI-R4) where every milliwatt counts?
Should this be fixed at another point in the initialization process (eg: not probing 
ridiculously all phy ids)?

Thanks,

Janpieter Sollie

--- a/drivers/net/mdio/mdio-i2c.c       2025-09-19 14:08:41.285357818 +0200
+++ b/drivers/net/mdio/mdio-i2c.c       2025-09-19 14:10:24.962796149 +0200
@@ -253,7 +253,7 @@ static int i2c_rollball_mii_poll(struct mii_bus *bus, int bus_addr, u8 *buf,
          */
         i = 10;
         do {
-               msleep(20);
+               msleep(20+(10*(10-i)));

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

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

end of thread, other threads:[~2025-09-23  7:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-19 13:52 [RFC] increase MDIO i2c poll timeout gradually (including patch) Janpieter Sollie
2025-09-19 17:04 ` Andrew Lunn
2025-09-20 10:00   ` Janpieter Sollie
2025-09-20 11:18     ` Russell King (Oracle)
2025-09-20 12:34       ` Janpieter Sollie
     [not found]       ` <6d444507-1c97-4904-8edb-e8cc1aa4399e@kabelmail.de>
2025-09-20 13:53         ` Russell King (Oracle)
2025-09-22  8:04           ` Janpieter Sollie
2025-09-22 10:54             ` Janpieter Sollie
2025-09-22 12:38               ` Russell King (Oracle)
2025-09-22 13:16                 ` Russell King (Oracle)
2025-09-22 13:50                   ` Russell King (Oracle)
2025-09-22 14:30                 ` Janpieter Sollie
2025-09-22 15:25                   ` Russell King (Oracle)
2025-09-23  7:02                     ` Janpieter Sollie
2025-09-22 14:46                 ` 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).