-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i2c: mcux driver does not prevent simultaneous transactions #29239
Comments
There is currently no global solution for exclusive access to devices, though there is a proposal in #24511 (which needs to be discussed since some drivers shouldn't use blocking locks). Many (most?) drivers take a semaphore on entry to i2c_transfer() and hold it until done. The MCUX I2C implementation needs to do this. @drandreas Would you mind if I converted this from an RFC to a bug against MCUX and any other I2C drivers that seem to lack a mutex? |
For the time being - until we agree on a generic solutions - I'd go for the same solution as in SPI: see drivers/spi/spi_context.h |
Sure, feel free to convert this ticket For MCUX I2C I've already created a patch: |
@drandreas Done, please submit your PR. |
Introduction
Several peripherals might be attached to one i2c bus. Some of those peripherals might therefore, access the same i2c bus simultaneously. I am expecting the i2c bus to have locking mechanism in place to prevent race conditions if an i2c transfer consists of multiple
i2c_msg
.Problem description
Neither
i2c_transfer
ini2c.h
nori2c_mcux_transfer
ini2c_mcux.c
have any sort of locking. If e.g. an i2c eprom is updated using a shell and simultaneously the system work queue accesses an i2c-port-expander then one of the two transfers will fail or produce a random result. I suspect several of the i2c drivers are affected but haven't checked them all.Proposed change
Add a semaphore to
i2c_transfer
ini2c.h
or every i2c bus driver.Alternatives
The text was updated successfully, but these errors were encountered: