drivers/i2c/busses/i2c-qcom-geni.c | 37 +++++++++++++++++++++++++++++-------- drivers/i2c/i2c-core-base.c | 24 ++++++++++++++++++++++++ include/linux/i2c.h | 3 +++ 3 files changed, 56 insertions(+), 8 deletions(-)
The I2C core and most controller drivers use a static 1-second timeout
for all transfers regardless of message length or bus frequency. This
causes unnecessarily long delays on error paths for short transfers, and
may be tight for very long transfers at low bus frequencies.
This series introduces a generic helper in i2c-core that computes a
transfer-specific timeout and stores it in the standard adap->timeout
field, making the dynamic value visible to the core retry loop in
__i2c_transfer() as well as to the driver's own wait sites.
The helper accepts a safety coefficient and a minimum floor as parameters
so each driver retains control over its own timing policy without those
values becoming public API.
The second patch converts the Qualcomm GENI I2C controller to use this
helper. The 10x safety margin over the theoretical wire time and the
300ms minimum floor (to budget for clock stretching) remain private to
the qcom-geni driver.
Changes in v6:
- Split into two patches: core helper + driver consumer
- Moved timeout calculation to i2c-core as i2c_update_timeout(), which
writes directly into adap->timeout so all consumers of that field
(including the __i2c_transfer() retry loop) benefit automatically
- Driver supplies safety coefficient and minimum floor as parameters,
keeping I2C_TIMEOUT_SAFETY_COEFFICIENT and I2C_TIMEOUT_MIN_USEC
internal to i2c-qcom-geni.c
- Compute timeout once per batch in geni_i2c_xfer() using max message
length, all internal wait sites read adap->timeout directly
Link: https://lore.kernel.org/r/20260715101805.3615166-1-aniket.randive@oss.qualcomm.com
Signed-off-by: Aniket Randive <aniket.randive@oss.qualcomm.com>
---
Aniket Randive (2):
i2c: core: Add i2c_update_timeout() helper for dynamic transfer timeouts
i2c: qcom-geni: Add dynamic transfer timeout based on transfer length and frequency
drivers/i2c/busses/i2c-qcom-geni.c | 37 +++++++++++++++++++++++++++++--------
drivers/i2c/i2c-core-base.c | 24 ++++++++++++++++++++++++
include/linux/i2c.h | 3 +++
3 files changed, 56 insertions(+), 8 deletions(-)
---
base-commit: b8809969e1d7a591e0f49dd464a5d04b3cf02ab1
change-id: 20260716-master-f7da57c7529a
Best regards,
--
Aniket Randive <aniket.randive@oss.qualcomm.com>
On 7/20/2026 5:11 PM, Aniket Randive wrote: > The I2C core and most controller drivers use a static 1-second timeout > for all transfers regardless of message length or bus frequency. This > causes unnecessarily long delays on error paths for short transfers, and > may be tight for very long transfers at low bus frequencies. > OR can be more than 1 sec for big transfer at low frequency. Hence better to make it generic saying depends on data length and frequency which you have mentioned. So limit it that. > This series introduces a generic helper in i2c-core that computes a generic helper function > transfer-specific timeout and stores it in the standard adap->timeout > field, making the dynamic value visible to the core retry loop in > __i2c_transfer() as well as to the driver's own wait sites. > > The helper accepts a safety coefficient and a minimum floor as parameters what's the policy to accept ? i think should explain here. read from dtsi or hard coded ? > so each driver retains control over its own timing policy without those > values becoming public API. > > The second patch converts the Qualcomm GENI I2C controller to use this > helper. The 10x safety margin over the theoretical wire time and the > 300ms minimum floor (to budget for clock stretching) remain private to > the qcom-geni driver. geni i2c driver > > Changes in v6: > - Split into two patches: core helper + driver consumer > - Moved timeout calculation to i2c-core as i2c_update_timeout(), which > writes directly into adap->timeout so all consumers of that field > (including the __i2c_transfer() retry loop) benefit automatically please Add suggested-by: dmitry guzman < > Also add reviewer into to/cc list specifically. > - Driver supplies safety coefficient and minimum floor as parameters, > keeping I2C_TIMEOUT_SAFETY_COEFFICIENT and I2C_TIMEOUT_MIN_USEC > internal to i2c-qcom-geni.c > - Compute timeout once per batch in geni_i2c_xfer() using max message > length, all internal wait sites read adap->timeout directly > > Link: https://lore.kernel.org/r/20260715101805.3615166-1-aniket.randive@oss.qualcomm.com > > Signed-off-by: Aniket Randive <aniket.randive@oss.qualcomm.com> > --- [...] >
On 7/22/2026 10:55 AM, Mukesh Savaliya wrote: > > > On 7/20/2026 5:11 PM, Aniket Randive wrote: >> The I2C core and most controller drivers use a static 1-second timeout >> for all transfers regardless of message length or bus frequency. This >> causes unnecessarily long delays on error paths for short transfers, and >> may be tight for very long transfers at low bus frequencies. >> > OR can be more than 1 sec for big transfer at low frequency. Hence > better to make it generic saying depends on data length and frequency > which you have mentioned. So limit it that. >> This series introduces a generic helper in i2c-core that computes a > generic helper function I will update the comment. Thanks, Aniket >> transfer-specific timeout and stores it in the standard adap->timeout >> field, making the dynamic value visible to the core retry loop in >> __i2c_transfer() as well as to the driver's own wait sites. >> >> The helper accepts a safety coefficient and a minimum floor as parameters > what's the policy to accept ? i think should explain here. > read from dtsi or hard coded ? Agreed. The policy is still being discussed (hard-coded vs driver-supplied vs DT based values). Once we converge on an approach with the other reviewers and maintainers, I'll update the commit message to reflect the final decision and rationale. Thanks, Aniket >> so each driver retains control over its own timing policy without those >> values becoming public API. >> >> The second patch converts the Qualcomm GENI I2C controller to use this >> helper. The 10x safety margin over the theoretical wire time and the >> 300ms minimum floor (to budget for clock stretching) remain private to >> the qcom-geni driver. > geni i2c driver I will update the comment. Thanks, Aniket >> >> Changes in v6: >> - Split into two patches: core helper + driver consumer >> - Moved timeout calculation to i2c-core as i2c_update_timeout(), which >> writes directly into adap->timeout so all consumers of that field >> (including the __i2c_transfer() retry loop) benefit automatically > please Add suggested-by: dmitry guzman < > > Also add reviewer into to/cc list specifically. I will add the tag in next patch. Thanks, Aniket >> - Driver supplies safety coefficient and minimum floor as parameters, >> keeping I2C_TIMEOUT_SAFETY_COEFFICIENT and I2C_TIMEOUT_MIN_USEC >> internal to i2c-qcom-geni.c >> - Compute timeout once per batch in geni_i2c_xfer() using max message >> length, all internal wait sites read adap->timeout directly >> >> Link: https://lore.kernel.org/r/20260715101805.3615166-1- >> aniket.randive@oss.qualcomm.com >> >> Signed-off-by: Aniket Randive <aniket.randive@oss.qualcomm.com> >> --- > > [...] >> >
© 2016 - 2026 Red Hat, Inc.