Re: i2c: slave support framework improvements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2016-07-28 09:41, Wolfram Sang wrote:
> 
> I didn't read all, just found my name in this paragraph.
> 
>>> I'm also a bit surprised that you are allowed to create a new (dummy) device
>>> with an address that is already taken on a downstream mux client adapter.
>>> Is that a feature in the i2c core, or is it a bug? Wolfram?
>>
>> This is what I mean under the "populate all the slave devices beforehand".
>> From the i2c bus point of view, I just adding one device per bus. It's allowed.
>> From the adapter point of view, I duplicates clients with the same addr.
> 
> The slave device must be attached to the muxed adapter. There, the
> address should be free. The parent adapter should be reconfigured
> depending on the mux setting.
> 
> At least, that's the theory, dunno if this really works. I thought you
> would be doing this already?

Hi Wolfram,

Thinking about this a bit more, this is what happens.

In order to call i2c_slave_register, you need to have a slave device
on the adapter in question. So, Anton creates a proxy slave device on the
adapter the mux is connect to. This leads to an address conflict since
the proxy needs the same address that the real slave device has already
registered on the mux client adapter.

But that conflict does not happen! This is because the proxy slave device
is created using i2c_new_dummy, and the I2C_CLIENT_SLAVE flag is added
after the address conflict check in i2c_new_dummy.

The proxy slave device is created when the mux is first selected
on a channel that has a slave device on the client side of the mux, so
the whole scheme fails if there is a mux client side access before
the last real slave device has been registered. This access causes the
above address conflict to happen for subsequent additions of slave
devices on the client side, because then the proxy slave device now
has the I2C_CLIENT_FLAG, which the real slave devices also have. This
needs to be fixed somehow, but is not a bug in the i2c core. But the
i2c core might still need to be involved in fixing the problem of
course, for example by somehow not including the proxy slave device in
the normal list of client devices. Or something.

In proximity to this, I find it odd that you are allowed to register
a slave device with the same address as a client device on an adapter
(one has I2C_CLIENT_FLAG set, which sets I2C_ADDR_OFFSET_SLAVE before
the address comparisons). Why is that possible? Yes, the two devices
can probably talk each other, both being aware of who is master at
the moment, but what about other masters on the bus?

Cheers,
Peter

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux