All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Retry count for i2c-mux
@ 2013-12-08 10:48 Elie De Brauwer
       [not found] ` <1386499701-5522-1-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Elie De Brauwer @ 2013-12-08 10:48 UTC (permalink / raw)
  To: wsa-z923LK4zBo2bacvFa/9K2g
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Elie De Brauwer

Wolfram,

I bumped into an issue where I needed to rely on the retry mechanism. I 
have a master controller and some muxed busses. However when testing
I observed that the retry worked when using the bus attached to the master
controller directly used the retry count set but the same behavior failed
on the muxed bus since the retry count there was zero. The root cause 
was in the creationg of the muxed busses which have their own 
struct i2c_adapter which gets kzalloc in i2c_add_mux_adapter(), my (trivial)
patch to this problem is to also copy the retries field of the parent to 
the i2c_adapter of the muxed bus.

(Obviously the retry count could be set by the I2C_RETRIES ioctl, but I'd
still think it's sensible to have a system initialized in a sane state).

my 2 cents
E. 


Elie De Brauwer (1):
  i2c-mux: Inherit retry count from parent controller for muxed bus.

 drivers/i2c/i2c-mux.c |    1 +
 1 file changed, 1 insertion(+)

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] i2c-mux: Inherit retry count from parent controller for muxed bus.
       [not found] ` <1386499701-5522-1-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-12-08 10:48   ` Elie De Brauwer
       [not found]     ` <1386499701-5522-2-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Elie De Brauwer @ 2013-12-08 10:48 UTC (permalink / raw)
  To: wsa-z923LK4zBo2bacvFa/9K2g
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Elie De Brauwer

Today if a mux i2c bus gets created the default retry count of the
muxed bus is zero. Hence it it possible that you end up with a
situation where the parent controller sets a default retry count
which gets applied and used while the muxed bus (using the same
controller) has a default retry count of zero. This can be solved
by initializing the retry count of the muxed bus by the retry count
of the parent at creation time.

Signed-off-by: Elie De Brauwer <eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/i2c-mux.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 797e311..1f879d8 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -139,6 +139,7 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
 	priv->adap.algo = &priv->algo;
 	priv->adap.algo_data = priv;
 	priv->adap.dev.parent = &parent->dev;
+	priv->adap.retries = parent->retries;
 
 	/* Sanity check on class */
 	if (i2c_mux_parent_classes(parent) & class)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c-mux: Inherit retry count from parent controller for muxed bus.
       [not found]     ` <1386499701-5522-2-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-12-09 11:08       ` Wolfram Sang
  2013-12-09 11:26         ` Elie De Brauwer
  2013-12-09 18:48       ` [PATCH v2] i2c-mux: Inherit retry count and timeout from parent " Elie De Brauwer
  1 sibling, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2013-12-09 11:08 UTC (permalink / raw)
  To: Elie De Brauwer; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 665 bytes --]

On Sun, Dec 08, 2013 at 11:48:20AM +0100, Elie De Brauwer wrote:
> Today if a mux i2c bus gets created the default retry count of the
> muxed bus is zero. Hence it it possible that you end up with a
> situation where the parent controller sets a default retry count
> which gets applied and used while the muxed bus (using the same
> controller) has a default retry count of zero. This can be solved
> by initializing the retry count of the muxed bus by the retry count
> of the parent at creation time.
> 
> Signed-off-by: Elie De Brauwer <eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Makes sense. Have you checked the timeout value, too?


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c-mux: Inherit retry count from parent controller for muxed bus.
  2013-12-09 11:08       ` Wolfram Sang
@ 2013-12-09 11:26         ` Elie De Brauwer
  0 siblings, 0 replies; 6+ messages in thread
From: Elie De Brauwer @ 2013-12-09 11:26 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA

On Mon, Dec 9, 2013 at 12:08 PM, Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> wrote:
> On Sun, Dec 08, 2013 at 11:48:20AM +0100, Elie De Brauwer wrote:
>> Today if a mux i2c bus gets created the default retry count of the
>> muxed bus is zero. Hence it it possible that you end up with a
>> situation where the parent controller sets a default retry count
>> which gets applied and used while the muxed bus (using the same
>> controller) has a default retry count of zero. This can be solved
>> by initializing the retry count of the muxed bus by the retry count
>> of the parent at creation time.
>>
>> Signed-off-by: Elie De Brauwer <eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> Makes sense. Have you checked the timeout value, too?
>

Point taken, I hadn't bumped into this since i2c_add_mux_adapter() calls
i2c_add_adapter() which essentially sets is to 1 second if it is zero. But
it makes sense indeed to also use this value from the parent. I'll post an
updated version later today.

Thanks
E.


-- 
Elie De Brauwer

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] i2c-mux: Inherit retry count and timeout from parent for muxed bus.
       [not found]     ` <1386499701-5522-2-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2013-12-09 11:08       ` Wolfram Sang
@ 2013-12-09 18:48       ` Elie De Brauwer
       [not found]         ` <1386614908-4872-1-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Elie De Brauwer @ 2013-12-09 18:48 UTC (permalink / raw)
  To: wsa-z923LK4zBo2bacvFa/9K2g
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Elie De Brauwer

If a muxed i2c bus gets created the default retry count and
timeout of the muxed bus is zero. Hence it it possible that you
end up with a situation where the parent controller sets a default
retry count and timeout which gets applied and used while the muxed
bus (using the same controller) has a default retry count of zero
and a default timeout of 1s (set in i2c_add_adapter()). This can be
solved by initializing the retry count and timeout of the muxed
bus with the values used by the the parent at creation time.

Signed-off-by: Elie De Brauwer <eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/i2c-mux.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 797e311..2d0847b 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -139,6 +139,8 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
 	priv->adap.algo = &priv->algo;
 	priv->adap.algo_data = priv;
 	priv->adap.dev.parent = &parent->dev;
+	priv->adap.retries = parent->retries;
+	priv->adap.timeout = parent->timeout;
 
 	/* Sanity check on class */
 	if (i2c_mux_parent_classes(parent) & class)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c-mux: Inherit retry count and timeout from parent for muxed bus.
       [not found]         ` <1386614908-4872-1-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-12-12 21:40           ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2013-12-12 21:40 UTC (permalink / raw)
  To: Elie De Brauwer; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

On Mon, Dec 09, 2013 at 07:48:28PM +0100, Elie De Brauwer wrote:
> If a muxed i2c bus gets created the default retry count and
> timeout of the muxed bus is zero. Hence it it possible that you
> end up with a situation where the parent controller sets a default
> retry count and timeout which gets applied and used while the muxed
> bus (using the same controller) has a default retry count of zero
> and a default timeout of 1s (set in i2c_add_adapter()). This can be
> solved by initializing the retry count and timeout of the muxed
> bus with the values used by the the parent at creation time.
> 
> Signed-off-by: Elie De Brauwer <eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Applied to for-current, thanks, good catch!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-12 21:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-08 10:48 [PATCH] Retry count for i2c-mux Elie De Brauwer
     [not found] ` <1386499701-5522-1-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-12-08 10:48   ` [PATCH] i2c-mux: Inherit retry count from parent controller for muxed bus Elie De Brauwer
     [not found]     ` <1386499701-5522-2-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-12-09 11:08       ` Wolfram Sang
2013-12-09 11:26         ` Elie De Brauwer
2013-12-09 18:48       ` [PATCH v2] i2c-mux: Inherit retry count and timeout from parent " Elie De Brauwer
     [not found]         ` <1386614908-4872-1-git-send-email-eliedebrauwer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-12-12 21:40           ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.