mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mukesh Savaliya <mukesh.savaliya@oss.qualcomm.com>
To: Aniket Randive <aniket.randive@oss.qualcomm.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Andi Shyti <andi.shyti@kernel.org>,
	Dmitry Guzman <Dmitry.Guzman@mobileye.com>
Cc: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>,
	linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 1/2] i2c: core: Add i2c_update_timeout() helper for dynamic transfer timeouts
Date: Mon, 7 Sep 2026 12:52:48 +0530	[thread overview]
Message-ID: <69e25f54-80a9-4f17-8453-c74b2e346585@oss.qualcomm.com> (raw)
In-Reply-To: <20260827-master-v8-1-596bc81c5cf9@oss.qualcomm.com>



On 8/27/2026 5:57 PM, Aniket Randive wrote:
> The transfer timeout for an I2C controller should reflect the actual
> message length and bus frequency rather than a static 1-second value.
> A static timeout causes unnecessary delays on error paths for short
> messages, and may be insufficient for very long transfers.
> 
> Add i2c_update_timeout() to i2c-core which computes a transfer-specific
> timeout and stores it directly in the standard adap->timeout field.  The
> formula accounts for 9 bits per byte (8 data + 1 ACK) at the configured
> bus frequency.  The caller supplies a safety multiplier and a minimum
> floor so that each driver retains full control over its timing policy
> without those values becoming public API.
> 
> Storing the result in adap->timeout makes it visible to all consumers of
> that field, including the arbitration-loss retry loop in __i2c_transfer().
> 
> The function is gated by CONFIG_I2C_DYNAMIC_TIMEOUT.  When the config is
> disabled, i2c_update_timeout() compiles to a no-op inline stub so drivers
> that call it build cleanly and the existing static 1-second default is
> preserved unchanged.
> 
> A timeout explicitly configured by userspace via the I2C_TIMEOUT ioctl is
> stored in a new adap->user_timeout field and always takes precedence over
> the kernel-computed value.  When userspace has not configured a timeout,
> the computed value is used.  The ioctl keeps writing adap->timeout as well,
> so adapters that never call i2c_update_timeout() continue to honour it
> exactly as before.
> 
> As i2c_update_timeout() is an exported helper, guard against a zero bus
> frequency from a misbehaving caller with WARN_ON_ONCE() and return early,
> leaving the existing timeout untouched as a safe fallback rather than
> dividing by zero.
> 
> Signed-off-by: Aniket Randive <aniket.randive@oss.qualcomm.com>
> ---
Reviewed-by: Mukesh Kumar Savaliya <mukesh.savaliya@oss.qualcomm.com>

  reply	other threads:[~2026-09-07  7:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 12:27 [PATCH v8 0/2] i2c: Add dynamic transfer timeout based on message length and frequency Aniket Randive
2026-08-27 12:27 ` [PATCH v8 1/2] i2c: core: Add i2c_update_timeout() helper for dynamic transfer timeouts Aniket Randive
2026-09-07  7:22   ` Mukesh Savaliya [this message]
2026-08-27 12:27 ` [PATCH v8 2/2] i2c: qcom-geni: Add dynamic transfer timeout based on transfer length and frequency Aniket Randive
2026-09-07  7:24   ` Mukesh Savaliya
2026-09-07  7:12 ` [PATCH v8 0/2] i2c: Add dynamic transfer timeout based on message " Mukesh Savaliya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69e25f54-80a9-4f17-8453-c74b2e346585@oss.qualcomm.com \
    --to=mukesh.savaliya@oss.qualcomm.com \
    --cc=Dmitry.Guzman@mobileye.com \
    --cc=andi.shyti@kernel.org \
    --cc=aniket.randive@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viken.dadhaniya@oss.qualcomm.com \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®