All of lore.kernel.org
 help / color / mirror / Atom feed
* i2c-mux adapter names not unique
@ 2017-03-13 13:14 MikeB
  2017-03-13 13:34 ` Peter Rosin
  0 siblings, 1 reply; 7+ messages in thread
From: MikeB @ 2017-03-13 13:14 UTC (permalink / raw)
  To: linux-i2c

The current naming scheme for i2c-mux adapters "i2c-<parent adapter
id>-mux (chan_id <id>)" results in duplicate names if there is more
than one mux device on an i2c adapter since each device will have the
same <parent adapter id>.

For example:

                  +--------+
                  |PCA9548 |
                  |  0x70  |
                  |01234567|
                  +--------+
                   |
        +-----------------------------+
        |             |               |
    +--------+    +--------+     +--------+
    |PCA9548 |    |PCA9548 |     |PCA9548 |
    |  0x73  |    |  0x74  |     |  0x75  |
    |01234567|    |01234567|     |01234567|
    +--------+    +--------+     +--------+


will result in eight sets of duplicate names for the channels coming
off the lower three muxes.

Any suggestions on how to modify i2c-mux.c to make these names unique?

Thanks, Mike

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

* Re: i2c-mux adapter names not unique
  2017-03-13 13:14 i2c-mux adapter names not unique MikeB
@ 2017-03-13 13:34 ` Peter Rosin
  2017-03-13 14:00   ` MikeB
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Rosin @ 2017-03-13 13:34 UTC (permalink / raw)
  To: MikeB, linux-i2c

On 2017-03-13 14:14, MikeB wrote:
> The current naming scheme for i2c-mux adapters "i2c-<parent adapter
> id>-mux (chan_id <id>)" results in duplicate names if there is more
> than one mux device on an i2c adapter since each device will have the
> same <parent adapter id>.
> 
> For example:
> 
>                   +--------+
>                   |PCA9548 |
>                   |  0x70  |
>                   |01234567|
>                   +--------+
>                    |
>         +-----------------------------+
>         |             |               |
>     +--------+    +--------+     +--------+
>     |PCA9548 |    |PCA9548 |     |PCA9548 |
>     |  0x73  |    |  0x74  |     |  0x75  |
>     |01234567|    |01234567|     |01234567|
>     +--------+    +--------+     +--------+
> 
> 
> will result in eight sets of duplicate names for the channels coming
> off the lower three muxes.

I think it's fairly common for adapters from the same driver to have
the same 'name'. E.g. the .../busses/i2c-at91.c driver uses "AT91" for
all adapters it instantiates.

> Any suggestions on how to modify i2c-mux.c to make these names unique?

Why do they have to be unique?

Cheers,
peda

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

* Re: i2c-mux adapter names not unique
  2017-03-13 13:34 ` Peter Rosin
@ 2017-03-13 14:00   ` MikeB
  2017-03-13 14:48     ` Peter Rosin
  0 siblings, 1 reply; 7+ messages in thread
From: MikeB @ 2017-03-13 14:00 UTC (permalink / raw)
  To: Peter Rosin; +Cc: linux-i2c

On Mon, Mar 13, 2017 at 9:34 AM, Peter Rosin <peda@axentia.se> wrote:
>> Any suggestions on how to modify i2c-mux.c to make these names unique?
>
> Why do they have to be unique?
>
I am porting OpenSwitch (www.openswitch.net) to a new platform that
has a topology as above.  OpenSwitch uses i2c adapter names to bind
i2c adapter devices to internal i2c adapters.  It assumes that
adapters are given unique names.

The presumption based on current i2c-mux behavior was that i2c adapter
names would be unique.  I knew this would cause problems for
OpenSwitch sooner or later.  It's sooner for me.

I've patched my local kernel to add the mux address to the name -
"i2c-<parent adapter id>-mux-<mux addr> (chan_id <id>)" which does
result in unique names.  However, my patch only works on topologies
that use only pca954x muxes.  I'd prefer a patch that could work for
all topologies.

Regards, Mike

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

* Re: i2c-mux adapter names not unique
  2017-03-13 14:00   ` MikeB
@ 2017-03-13 14:48     ` Peter Rosin
  2017-03-13 15:05       ` MikeB
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Rosin @ 2017-03-13 14:48 UTC (permalink / raw)
  To: MikeB; +Cc: linux-i2c

On 2017-03-13 15:00, MikeB wrote:
> On Mon, Mar 13, 2017 at 9:34 AM, Peter Rosin <peda@axentia.se> wrote:
>>> Any suggestions on how to modify i2c-mux.c to make these names unique?
>>
>> Why do they have to be unique?
>>
> I am porting OpenSwitch (www.openswitch.net) to a new platform that
> has a topology as above.  OpenSwitch uses i2c adapter names to bind
> i2c adapter devices to internal i2c adapters.  It assumes that
> adapters are given unique names.

As indicated by the part you elided, that appears to be a bad assumption.

> The presumption based on current i2c-mux behavior was that i2c adapter
> names would be unique.  I knew this would cause problems for
> OpenSwitch sooner or later.  It's sooner for me.
> 
> I've patched my local kernel to add the mux address to the name -
> "i2c-<parent adapter id>-mux-<mux addr> (chan_id <id>)" which does
> result in unique names.  However, my patch only works on topologies
> that use only pca954x muxes.  I'd prefer a patch that could work for
> all topologies.

And why not fix the bad assumption in OpenSwitch instead and kill the
generic problem for every kind of adapter? Limiting yourself to a
band-aid for i2c-mux adapters seems short-sighted and not very helpful
for the next victim of this OpenSwitch problem...

Note that you do not need two muxing levels to get duplicate names like
this, it's enough with two parallel multiplexers on the root adapter. Or,
of course, two AT91 adapters (or similar, i.e. with a fixed name).

Cheers,
peda

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

* Re: i2c-mux adapter names not unique
  2017-03-13 14:48     ` Peter Rosin
@ 2017-03-13 15:05       ` MikeB
  2017-03-13 21:01         ` Peter Rosin
  0 siblings, 1 reply; 7+ messages in thread
From: MikeB @ 2017-03-13 15:05 UTC (permalink / raw)
  To: Peter Rosin; +Cc: linux-i2c

On Mon, Mar 13, 2017 at 10:48 AM, Peter Rosin <peda@axentia.se> wrote:
>
> And why not fix the bad assumption in OpenSwitch instead and kill the
> generic problem for every kind of adapter? Limiting yourself to a
> band-aid for i2c-mux adapters seems short-sighted and not very helpful
> for the next victim of this OpenSwitch problem...
>
> Note that you do not need two muxing levels to get duplicate names like
> this, it's enough with two parallel multiplexers on the root adapter. Or,
> of course, two AT91 adapters (or similar, i.e. with a fixed name).

If I thought that OpenSwitch's expectation of Linux to name unique
adapters uniquely, I would push for a change in OpenSwitch.

I personally think Linux's naming convention is a short-sighted and
insufficient which is why I came to Linux first.

I don't want a short-sighted band-aid which is why I asked the
original question.

I'll try elsewhere for a solution...

Regards, Mike

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

* Re: i2c-mux adapter names not unique
  2017-03-13 15:05       ` MikeB
@ 2017-03-13 21:01         ` Peter Rosin
  2017-03-14  6:46           ` Danielle Costantino
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Rosin @ 2017-03-13 21:01 UTC (permalink / raw)
  To: MikeB; +Cc: linux-i2c

On 2017-03-13 16:05, MikeB wrote:
> On Mon, Mar 13, 2017 at 10:48 AM, Peter Rosin <peda@axentia.se> wrote:
>>
>> And why not fix the bad assumption in OpenSwitch instead and kill the
>> generic problem for every kind of adapter? Limiting yourself to a
>> band-aid for i2c-mux adapters seems short-sighted and not very helpful
>> for the next victim of this OpenSwitch problem...
>>
>> Note that you do not need two muxing levels to get duplicate names like
>> this, it's enough with two parallel multiplexers on the root adapter. Or,
>> of course, two AT91 adapters (or similar, i.e. with a fixed name).
> 
> If I thought that OpenSwitch's expectation of Linux to name unique
> adapters uniquely, I would push for a change in OpenSwitch.
> 
> I personally think Linux's naming convention is a short-sighted and
> insufficient which is why I came to Linux first.
> 
> I don't want a short-sighted band-aid which is why I asked the
> original question.
> 
> I'll try elsewhere for a solution...

That's probably best, since if we do change the adapter naming convention
to something that is unique and stable across reboots (which presumably is
what is sought, and BTW probably not a trivial problem) some other person
is going to suffer a regression when OpenSwitch fails to associate with
the intended adapter after a kernel update. I.e. the very fact that
OpenSwitch is already using this interface makes it harder to change. And
who knows, maybe there are other users that will suffer if naming is
changed?

[Note that I know nothing about OpenSwitch, I'm just deducing the above
from what you have stated previously]

I'm sorry, but there's not always a simple and convenient answer...

Cheers,
peda

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

* Re: i2c-mux adapter names not unique
  2017-03-13 21:01         ` Peter Rosin
@ 2017-03-14  6:46           ` Danielle Costantino
  0 siblings, 0 replies; 7+ messages in thread
From: Danielle Costantino @ 2017-03-14  6:46 UTC (permalink / raw)
  To: Peter Rosin, MikeB; +Cc: linux-i2c


[-- Attachment #1.1: Type: text/plain, Size: 2578 bytes --]

Using an adapter id is not a valid and deterministic method for
identifying a i2c bus. The way you can identify what adapter you need to
bind to is by identifying the unique parent device that hosts the
adapter (pci, platform, usb, ....) and identifying a constant parameter
like bus id/ SN/ bus address, using this as your adapter base and
traversing the bus tree based on the channel you need to connect to your
mux. Take a look at the work done with lsi2c and i2cdev.
https://github.com/costad2/i2cdev

Good luck,

Danielle


On 03/13/2017 02:01 PM, Peter Rosin wrote:
> On 2017-03-13 16:05, MikeB wrote:
>> On Mon, Mar 13, 2017 at 10:48 AM, Peter Rosin <peda@axentia.se> wrote:
>>> And why not fix the bad assumption in OpenSwitch instead and kill the
>>> generic problem for every kind of adapter? Limiting yourself to a
>>> band-aid for i2c-mux adapters seems short-sighted and not very helpful
>>> for the next victim of this OpenSwitch problem...
>>>
>>> Note that you do not need two muxing levels to get duplicate names like
>>> this, it's enough with two parallel multiplexers on the root adapter. Or,
>>> of course, two AT91 adapters (or similar, i.e. with a fixed name).
>> If I thought that OpenSwitch's expectation of Linux to name unique
>> adapters uniquely, I would push for a change in OpenSwitch.
>>
>> I personally think Linux's naming convention is a short-sighted and
>> insufficient which is why I came to Linux first.
>>
>> I don't want a short-sighted band-aid which is why I asked the
>> original question.
>>
>> I'll try elsewhere for a solution...
> That's probably best, since if we do change the adapter naming convention
> to something that is unique and stable across reboots (which presumably is
> what is sought, and BTW probably not a trivial problem) some other person
> is going to suffer a regression when OpenSwitch fails to associate with
> the intended adapter after a kernel update. I.e. the very fact that
> OpenSwitch is already using this interface makes it harder to change. And
> who knows, maybe there are other users that will suffer if naming is
> changed?
>
> [Note that I know nothing about OpenSwitch, I'm just deducing the above
> from what you have stated previously]
>
> I'm sorry, but there's not always a simple and convenient answer...
>
> Cheers,
> peda
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

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

end of thread, other threads:[~2017-03-14  6:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13 13:14 i2c-mux adapter names not unique MikeB
2017-03-13 13:34 ` Peter Rosin
2017-03-13 14:00   ` MikeB
2017-03-13 14:48     ` Peter Rosin
2017-03-13 15:05       ` MikeB
2017-03-13 21:01         ` Peter Rosin
2017-03-14  6:46           ` Danielle Costantino

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.