-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Reported by M R Rosen:
Specifically using the QMSI driver in multiple threads, the driver is not thread safe. Currently, the driver tries to protect the controller via semaphore but does so only around the calls to the QMSI HAL and NOT while a transaction is in progress, meaning that another thread can come in and mess with the controller (and thus a transactions) while the previous transaction is still in progress, leading to incorrect behavior in either the ongoing or next transaction. A quick survey of the other I2C drivers revealed that either they have no multithread protection at all (STM32, NRF5) or have the same issue (QMSI SS). My understanding was that Zephyr is attempting to make all drivers thread safe; so I just wanted to report that not all drivers are.
A simple example can be created where two threads attempt to use the I2C bus (I had them talking to the same device but it shouldnt matter) in quick succession (Such that thread 1 is waiting on the syncing semaphore when thread 2 calls i2c_transfer).
(Imported from Jira ZEP-2259)