* [PATCH V2] PCA9541: Use I2C adapter timeout value for arbitration timeout
@ 2025-07-31 12:55 Manikanta Guntupalli
2025-09-01 5:48 ` Guntupalli, Manikanta
2025-09-12 22:19 ` Wolfram Sang
0 siblings, 2 replies; 4+ messages in thread
From: Manikanta Guntupalli @ 2025-07-31 12:55 UTC (permalink / raw)
To: git, michal.simek, peda, linux-i2c, linux-kernel, wsa+renesas
Cc: radhey.shyam.pandey, srinivas.goud, shubhrajyoti.datta,
manion05gk, Manikanta Guntupalli
Remove existing arbitration timeout macros and use I2C adapter timeout
value for arbitration timeout and forceful bus ownership.
I2C adapter timeout can be configurable from user space, so using it
for arbitration timeout helps in configuring the arbitration timeout
from user space depending on the use case.
Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
---
Changes for V2:
Remove existing arbitration timeout macros and use i2c adapter timeout
value.
Change logging and commit details.
Link for V1: https://lore.kernel.org/all/20250711124503.3390451-1-manikanta.guntupalli@amd.com/
---
drivers/i2c/muxes/i2c-mux-pca9541.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c
index 8663c8a7c269..3d8002caf703 100644
--- a/drivers/i2c/muxes/i2c-mux-pca9541.c
+++ b/drivers/i2c/muxes/i2c-mux-pca9541.c
@@ -63,10 +63,6 @@
#define mybus(x) (!((x) & MYBUS) || ((x) & MYBUS) == MYBUS)
#define busoff(x) (!((x) & BUSON) || ((x) & BUSON) == BUSON)
-/* arbitration timeouts, in jiffies */
-#define ARB_TIMEOUT (HZ / 8) /* 125 ms until forcing bus ownership */
-#define ARB2_TIMEOUT (HZ / 4) /* 250 ms until acquisition failure */
-
/* arbitration retry delays, in us */
#define SELECT_DELAY_SHORT 50
#define SELECT_DELAY_LONG 1000
@@ -229,6 +225,9 @@ static int pca9541_arbitrate(struct i2c_client *client)
*/
data->select_timeout = SELECT_DELAY_LONG;
if (time_is_before_eq_jiffies(data->arb_timeout)) {
+ dev_warn(&client->dev,
+ "Arbitration timeout on I2C bus, forcing bus ownership\n");
+
/* Time is up, take the bus and reset it. */
pca9541_reg_write(client,
PCA9541_CONTROL,
@@ -251,10 +250,10 @@ static int pca9541_select_chan(struct i2c_mux_core *muxc, u32 chan)
struct pca9541 *data = i2c_mux_priv(muxc);
struct i2c_client *client = data->client;
int ret;
- unsigned long timeout = jiffies + ARB2_TIMEOUT;
+ unsigned long timeout = jiffies + (2 * client->adapter->timeout);
/* give up after this time */
- data->arb_timeout = jiffies + ARB_TIMEOUT;
+ data->arb_timeout = jiffies + client->adapter->timeout;
/* force bus ownership after this time */
do {
@@ -267,6 +266,7 @@ static int pca9541_select_chan(struct i2c_mux_core *muxc, u32 chan)
else
msleep(data->select_timeout / 1000);
} while (time_is_after_eq_jiffies(timeout));
+ dev_warn(&client->dev, "Failed to acquire I2C bus, timed out\n");
return -ETIMEDOUT;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH V2] PCA9541: Use I2C adapter timeout value for arbitration timeout
2025-07-31 12:55 [PATCH V2] PCA9541: Use I2C adapter timeout value for arbitration timeout Manikanta Guntupalli
@ 2025-09-01 5:48 ` Guntupalli, Manikanta
2025-09-12 6:55 ` Guntupalli, Manikanta
2025-09-12 22:19 ` Wolfram Sang
1 sibling, 1 reply; 4+ messages in thread
From: Guntupalli, Manikanta @ 2025-09-01 5:48 UTC (permalink / raw)
To: Guntupalli, Manikanta, git (AMD-Xilinx), Simek, Michal,
peda@axentia.se, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org, wsa+renesas@sang-engineering.com
Cc: Pandey, Radhey Shyam, Goud, Srinivas, Datta, Shubhrajyoti,
manion05gk@gmail.com
[Public]
Ping!
> -----Original Message-----
> From: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> Sent: Thursday, July 31, 2025 6:26 PM
> To: git (AMD-Xilinx) <git@amd.com>; Simek, Michal <michal.simek@amd.com>;
> peda@axentia.se; linux-i2c@vger.kernel.org; linux-kernel@vger.kernel.org;
> wsa+renesas@sang-engineering.com
> Cc: Pandey, Radhey Shyam <radhey.shyam.pandey@amd.com>; Goud, Srinivas
> <srinivas.goud@amd.com>; Datta, Shubhrajyoti <shubhrajyoti.datta@amd.com>;
> manion05gk@gmail.com; Guntupalli, Manikanta <manikanta.guntupalli@amd.com>
> Subject: [PATCH V2] PCA9541: Use I2C adapter timeout value for arbitration
> timeout
>
> Remove existing arbitration timeout macros and use I2C adapter timeout
> value for arbitration timeout and forceful bus ownership.
>
> I2C adapter timeout can be configurable from user space, so using it
> for arbitration timeout helps in configuring the arbitration timeout
> from user space depending on the use case.
>
> Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> ---
> Changes for V2:
> Remove existing arbitration timeout macros and use i2c adapter timeout
> value.
> Change logging and commit details.
> Link for V1: https://lore.kernel.org/all/20250711124503.3390451-1-
> manikanta.guntupalli@amd.com/
> ---
> drivers/i2c/muxes/i2c-mux-pca9541.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-
> pca9541.c
> index 8663c8a7c269..3d8002caf703 100644
> --- a/drivers/i2c/muxes/i2c-mux-pca9541.c
> +++ b/drivers/i2c/muxes/i2c-mux-pca9541.c
> @@ -63,10 +63,6 @@
> #define mybus(x) (!((x) & MYBUS) || ((x) & MYBUS) == MYBUS)
> #define busoff(x) (!((x) & BUSON) || ((x) & BUSON) == BUSON)
>
> -/* arbitration timeouts, in jiffies */
> -#define ARB_TIMEOUT (HZ / 8) /* 125 ms until forcing bus ownership */
> -#define ARB2_TIMEOUT (HZ / 4) /* 250 ms until acquisition failure */
> -
> /* arbitration retry delays, in us */
> #define SELECT_DELAY_SHORT 50
> #define SELECT_DELAY_LONG 1000
> @@ -229,6 +225,9 @@ static int pca9541_arbitrate(struct i2c_client *client)
> */
> data->select_timeout = SELECT_DELAY_LONG;
> if (time_is_before_eq_jiffies(data->arb_timeout)) {
> + dev_warn(&client->dev,
> + "Arbitration timeout on I2C bus, forcing bus
> ownership\n");
> +
> /* Time is up, take the bus and reset it. */
> pca9541_reg_write(client,
> PCA9541_CONTROL,
> @@ -251,10 +250,10 @@ static int pca9541_select_chan(struct i2c_mux_core
> *muxc, u32 chan)
> struct pca9541 *data = i2c_mux_priv(muxc);
> struct i2c_client *client = data->client;
> int ret;
> - unsigned long timeout = jiffies + ARB2_TIMEOUT;
> + unsigned long timeout = jiffies + (2 * client->adapter->timeout);
> /* give up after this time */
>
> - data->arb_timeout = jiffies + ARB_TIMEOUT;
> + data->arb_timeout = jiffies + client->adapter->timeout;
> /* force bus ownership after this time */
>
> do {
> @@ -267,6 +266,7 @@ static int pca9541_select_chan(struct i2c_mux_core *muxc,
> u32 chan)
> else
> msleep(data->select_timeout / 1000);
> } while (time_is_after_eq_jiffies(timeout));
> + dev_warn(&client->dev, "Failed to acquire I2C bus, timed out\n");
>
> return -ETIMEDOUT;
> }
> --
> 2.34.1
Thanks,
Manikanta.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH V2] PCA9541: Use I2C adapter timeout value for arbitration timeout
2025-09-01 5:48 ` Guntupalli, Manikanta
@ 2025-09-12 6:55 ` Guntupalli, Manikanta
0 siblings, 0 replies; 4+ messages in thread
From: Guntupalli, Manikanta @ 2025-09-12 6:55 UTC (permalink / raw)
To: git (AMD-Xilinx), Simek, Michal, peda@axentia.se,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
wsa+renesas@sang-engineering.com
Cc: Pandey, Radhey Shyam, Goud, Srinivas, Datta, Shubhrajyoti,
manion05gk@gmail.com
[Public]
Ping!
> -----Original Message-----
> From: Guntupalli, Manikanta
> Sent: Monday, September 1, 2025 11:18 AM
> To: Manikanta Guntupalli <manikanta.guntupalli@amd.com>; git (AMD-Xilinx)
> <git@amd.com>; Simek, Michal <michal.simek@amd.com>; peda@axentia.se;
> linux-i2c@vger.kernel.org; linux-kernel@vger.kernel.org; wsa+renesas@sang-
> engineering.com
> Cc: Pandey, Radhey Shyam <radhey.shyam.pandey@amd.com>; Goud, Srinivas
> <srinivas.goud@amd.com>; Datta, Shubhrajyoti <shubhrajyoti.datta@amd.com>;
> manion05gk@gmail.com
> Subject: RE: [PATCH V2] PCA9541: Use I2C adapter timeout value for arbitration
> timeout
>
> Ping!
>
> > -----Original Message-----
> > From: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> > Sent: Thursday, July 31, 2025 6:26 PM
> > To: git (AMD-Xilinx) <git@amd.com>; Simek, Michal
> > <michal.simek@amd.com>; peda@axentia.se; linux-i2c@vger.kernel.org;
> > linux-kernel@vger.kernel.org;
> > wsa+renesas@sang-engineering.com
> > Cc: Pandey, Radhey Shyam <radhey.shyam.pandey@amd.com>; Goud, Srinivas
> > <srinivas.goud@amd.com>; Datta, Shubhrajyoti
> > <shubhrajyoti.datta@amd.com>; manion05gk@gmail.com; Guntupalli,
> > Manikanta <manikanta.guntupalli@amd.com>
> > Subject: [PATCH V2] PCA9541: Use I2C adapter timeout value for
> > arbitration timeout
> >
> > Remove existing arbitration timeout macros and use I2C adapter timeout
> > value for arbitration timeout and forceful bus ownership.
> >
> > I2C adapter timeout can be configurable from user space, so using it
> > for arbitration timeout helps in configuring the arbitration timeout
> > from user space depending on the use case.
> >
> > Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> > ---
> > Changes for V2:
> > Remove existing arbitration timeout macros and use i2c adapter timeout
> > value.
> > Change logging and commit details.
> > Link for V1: https://lore.kernel.org/all/20250711124503.3390451-1-
> > manikanta.guntupalli@amd.com/
> > ---
> > drivers/i2c/muxes/i2c-mux-pca9541.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c
> > b/drivers/i2c/muxes/i2c-mux- pca9541.c index
> > 8663c8a7c269..3d8002caf703 100644
> > --- a/drivers/i2c/muxes/i2c-mux-pca9541.c
> > +++ b/drivers/i2c/muxes/i2c-mux-pca9541.c
> > @@ -63,10 +63,6 @@
> > #define mybus(x) (!((x) & MYBUS) || ((x) & MYBUS) == MYBUS)
> > #define busoff(x) (!((x) & BUSON) || ((x) & BUSON) == BUSON)
> >
> > -/* arbitration timeouts, in jiffies */
> > -#define ARB_TIMEOUT (HZ / 8) /* 125 ms until forcing bus ownership */
> > -#define ARB2_TIMEOUT (HZ / 4) /* 250 ms until acquisition failure */
> > -
> > /* arbitration retry delays, in us */
> > #define SELECT_DELAY_SHORT 50
> > #define SELECT_DELAY_LONG 1000
> > @@ -229,6 +225,9 @@ static int pca9541_arbitrate(struct i2c_client *client)
> > */
> > data->select_timeout = SELECT_DELAY_LONG;
> > if (time_is_before_eq_jiffies(data->arb_timeout)) {
> > + dev_warn(&client->dev,
> > + "Arbitration timeout on I2C bus, forcing bus
> > ownership\n");
> > +
> > /* Time is up, take the bus and reset it. */
> > pca9541_reg_write(client,
> > PCA9541_CONTROL,
> > @@ -251,10 +250,10 @@ static int pca9541_select_chan(struct
> > i2c_mux_core *muxc, u32 chan)
> > struct pca9541 *data = i2c_mux_priv(muxc);
> > struct i2c_client *client = data->client;
> > int ret;
> > - unsigned long timeout = jiffies + ARB2_TIMEOUT;
> > + unsigned long timeout = jiffies + (2 * client->adapter->timeout);
> > /* give up after this time */
> >
> > - data->arb_timeout = jiffies + ARB_TIMEOUT;
> > + data->arb_timeout = jiffies + client->adapter->timeout;
> > /* force bus ownership after this time */
> >
> > do {
> > @@ -267,6 +266,7 @@ static int pca9541_select_chan(struct i2c_mux_core
> > *muxc,
> > u32 chan)
> > else
> > msleep(data->select_timeout / 1000);
> > } while (time_is_after_eq_jiffies(timeout));
> > + dev_warn(&client->dev, "Failed to acquire I2C bus, timed out\n");
> >
> > return -ETIMEDOUT;
> > }
> > --
> > 2.34.1
>
Thanks,
Manikanta.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] PCA9541: Use I2C adapter timeout value for arbitration timeout
2025-07-31 12:55 [PATCH V2] PCA9541: Use I2C adapter timeout value for arbitration timeout Manikanta Guntupalli
2025-09-01 5:48 ` Guntupalli, Manikanta
@ 2025-09-12 22:19 ` Wolfram Sang
1 sibling, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2025-09-12 22:19 UTC (permalink / raw)
To: Manikanta Guntupalli
Cc: git, michal.simek, peda, linux-i2c, linux-kernel,
radhey.shyam.pandey, srinivas.goud, shubhrajyoti.datta,
manion05gk
[-- Attachment #1: Type: text/plain, Size: 622 bytes --]
On Thu, Jul 31, 2025 at 06:25:35PM +0530, Manikanta Guntupalli wrote:
> Remove existing arbitration timeout macros and use I2C adapter timeout
> value for arbitration timeout and forceful bus ownership.
>
> I2C adapter timeout can be configurable from user space, so using it
> for arbitration timeout helps in configuring the arbitration timeout
> from user space depending on the use case.
>
> Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
Please use 'git log' to check proper prefix for subject like "i2c: mux:
pca9541". Fixed it for you this time.
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-12 22:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-31 12:55 [PATCH V2] PCA9541: Use I2C adapter timeout value for arbitration timeout Manikanta Guntupalli
2025-09-01 5:48 ` Guntupalli, Manikanta
2025-09-12 6:55 ` Guntupalli, Manikanta
2025-09-12 22:19 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox