Re: [PATCH v6 1/2] i2c: core: Add i2c_update_timeout() helper for dynamic transfer timeouts
Wolfram Sang <[email protected]> Tue, 28 Jul 2026 11:42:47 +0200
| Newsgroups | org.kernel.vger.linux-i2c,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <amh5l4Yvwemws6Cx@shikoro> |
Hi, > My thinking was that we are trying to derive a timeout for transfer > completion, so the transfer length and bus frequency should already give > us the theoretical on-the-wire transfer time. With my experience in all these years with I2C, this is exactly true. It is a _theoretical_ value, and the practical value is at least board(!) dependant. It may also depend on the environment in other cases. So, the theoretical value may supply a minimum but IMO this doesn't help. Because we want a precise value, but we don't know it. > On top of that, we could add a fixed margin to account for interrupt and > system scheduling latency before converting the result to jiffies. > > The exact margin is open for discussion. I was considering something on > the order of a few hundred milliseconds (e.g. 500 ms), but perhaps that > is still too optimistic on some systems? See, you simply cannot know. So, why not leaving it to those who do know for their system? > Alternatively, the core could provide a calculated baseline timeout > (transfer time + fixed margin) and allow userspace to add an optional > extra offset when needed. That way the default behavior remains automatic > and works for most clients, while systems with unusual latency > requirements can still increase the timeout without every userspace client > having to determine an appropriate value itself. We already have a mechanism for userspace to set a timeout. > Do you see cases where a transfer-time-based timeout with a generous > system-latency margin would still be insufficient? Regressions. You could time out too early on boards which worked before. Happy hacking, Wolfram
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAmpoeZcACgkQFA3kzBSg KbZ3uA/+LLmsCG/OCnRbhf8qigFt+/wDB4BemNuEsK0QzvnM4ly5rlFwWjXKQ+in /KQ32mWqSoIMK17S25I3p9LqgG6TaJEmrYSWPzU1Echzqa0hmcZlDCcLzN7pUtSg J/b49cn/blp5OytnrK6nBK/QP7zhkSdPGsmQQxPvwKTSFmzMYSS1rf8ZcWz6Gqlz bN1OWKl15JpVmJ1aU4hkgIPKVHdtcTLFUIjBxLyRfQUD/nB5aRf//rO+CKKP5fnr wU2L7L8lwvZkismW1qy0PVhIj1SPLDWLr1moeeC6O0hPWjyG3GWUs+sKuJFmH1dn yV+PCkhNsUSil4fKxCuFjoQgqckG/JUwm5CmxgGioqDRiWGHWw9ynULcrj2ILZ4Y QtTW8frG4hdTvlK8Ybu+M7Ta9ZWnckiXztUV0wtW2SUWD2KxhwnhwXOJIYcLXOCL g2c4M5Jk5TSEdk5vOkRoSGl+zxRYS/wDbD5SMmOwDMZRrFer7Ab0/lcOTtKKlX6q gwZl6wZfR8OmL97or70Ztxk54gzq91usOelAcsNH5ZxZadp8w2pNKlJW0xgMf3LJ 0RIJ2KA4kb4hrMVix0Shhclt3Qmu25L3OP0r79nOoCY15/MJf1c2GcGaLOGWxbxz IESX/xcAzvLBrYrR4ZJepdiNwf0ozjBZTySCpu1i7Kw6uSmDSYs= =cJj3 -----END PGP SIGNATURE-----