Skip to content

i2c: Add dynamic transfer timeout based on message length and frequency

Aniket Randive linux-arm-msm linux-i2c lkml 10 versions – Applied

Status from this message: Pushed to i2c/i2c.

Get series with b4
b4 am [email protected] change-id 20260716-master-f7da57c7529a

Versions newest first

  1. v9 Latest2 patches 1 replyApplied
  2. v82 patches 3 repliesSuperseded
  3. v72 patches 6 repliesSuperseded
Earlier versions · 7
VersionPostedPatchesRepliesStatus
v62 patches18 repliesSuperseded inferred link
v51 patch2 repliesSuperseded inferred link
v41 patch3 repliesSuperseded inferred link
v31 patch0 repliesSuperseded inferred link
v2 posting 2/21 patch0 repliesSuperseded inferred link
v2 posting 1/21 patch6 repliesSuperseded inferred link
v11 patch2 repliesSuperseded

Changes in v9 from the cover letter

- Add '---' demarcation before revision history in the cover letter
- Link to v8: https://patch.msgid.link/[email protected]

Patches in v9 Applied

#Subject and filesSizeRepliesApplied
1/2i2c: core: Add i2c_update_timeout() helper for dynamic transfer timeoutsdrivers/i2c/Kconfig drivers/i2c/i2c-core-base.c drivers/i2c/i2c-dev.c +1 more+72 -00 replies
2/2i2c: qcom-geni: Add dynamic transfer timeout based on transfer length and frequencydrivers/i2c/busses/i2c-qcom-geni.c+39 -90 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMukesh Kumar Savaliya
SeriesR-b
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v9 thread

Cover letter [PATCH v9 0/2] i2c: Add dynamic transfer timeout based on message length and frequency

The I2C core and many controller drivers currently rely on a fixed timeout value that does not account for transfer characteristics such as message length or bus frequency. This can make the timeout unnecessarily large for short transfers, while longer transfers at lower bus frequencies may require a timeout that better matches the expected transfer duration.

Introduce a generic helper API in the I2C core to calculate a transfer-specific timeout from the expected wire time of a transaction. Store the computed value in adap->timeout so that both the I2C core retry logic and controller drivers use a timeout value that reflects the current transfer.

Keep timeout policy decisions within individual controller drivers. Let drivers provide their own safety margins and minimum timeout floors, and avoid exposing those driver-specific policy values as part of the generic API.

Convert the Qualcomm GENI I2C driver to use the helper while preserving its existing timeout policy. Preserve the static timeout behaviour when CONFIG_I2C_DYNAMIC_TIMEOUT is disabled, and let a userspace-configured I2C_TIMEOUT value take precedence over the computed timeout.

---
Changes in v9:
- Add '---' demarcation before revision history in the cover letter
- Link to v8: https://patch.msgid.link/[email protected]

Changes in v8:
- Compute GPI multi-descriptor timeout using the total length of all messages in the batch, since completion is reported only after the
entire batch finishes.
- Guard against zero bus frequency in i2c_update_timeout() with WARN_ON_ONCE() and retain the existing timeout as a safe fallback.
- Link to v7: https://patch.msgid.link/[email protected]

Changes in v7:
- Add CONFIG_I2C_DYNAMIC_TIMEOUT to gate i2c_update_timeout(); no-op stub when config is disabled preserving existing static behaviour
- Store userspace I2C_TIMEOUT ioctl value in a new adap->user_timeout field; userspace-configured timeout always takes precedence over the kernel-computed value
- Fix geni_i2c_gpi_multi_xfer_timeout_handler() parameter type u32 -> unsigned long to match wait_for_completion_timeout() expectation

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

To: Andi Shyti <[email protected]>
To: Viken Dadhaniya <[email protected]>

---
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/Kconfig                | 13 +++++++++++
 drivers/i2c/busses/i2c-qcom-geni.c | 48 +++++++++++++++++++++++++++++++-------
 drivers/i2c/i2c-core-base.c        | 43 ++++++++++++++++++++++++++++++++++
 drivers/i2c/i2c-dev.c              |  3 +++
 include/linux/i2c.h                | 13 +++++++++++
 5 files changed, 111 insertions(+), 9 deletions(-)

---
base-commit: f82a5da2f04960df9fb57489992d03dd5e64ec6f
change-id: 20260716-master-f7da57c7529a

Best regards,

Signature · 1 line
Aniket Randive <[email protected]>