spi: SPI_LOCK_ON does not hold the lock for multiple spi_transceive until spi_release #29287
Labels
area: SPI
SPI bus
bug
The issue is a bug, or the PR is fixing a bug
priority: medium
Medium impact/importance bug
Problem
On our custom HW we have two spi devices on the same spi bus.
One device is a TPM2 with special requirements concerning holding the CS active during multiple
spi_transceive
.Setting the
SPI_HOLD_ON_CS
works fine, it holds the CS active untilspi_release
.But the second device access the bus in before the transfer is completed (with
spi_release
).Both CS are active at the same time and the access fails.
We are using the synchronous API. Both devices are served from different threads.
To Reproduce
Run 2 threads
access the TPM2
access the second device
Expected behavior
I expect that for the TPM2 the spi bus lock is kept from the first
spi_transceive
until thespi_release
.For the Switch device the lock is only kept within the
spi_transceive
. For the same time that also the CS is kept active.Do I have the correct understanding of the expected behavior defined in the documentation?
https://docs.zephyrproject.org/2.4.0/reference/peripherals/spi.html?highlight=spi#c.spi_release
Environment:
Code
In the code spi_context.h
https://github.com/zephyrproject-rtos/zephyr/blob/zephyr-v2.4.0/drivers/spi/spi_context.h#L95
we can see that the lock is given back unconditionally on the
SPI_LOCK_ON
for the synchronous API.The text was updated successfully, but these errors were encountered: