Skip to content

Conversation

@kasjer
Copy link
Contributor

@kasjer kasjer commented Oct 11, 2025

Code assume that node can be locked only once and
second lock is probably for another node.
Lock are internally use on each transaction.
Write, read, write then read transactions can be
used with just one lock.
spiflash driver locks node when it wants to write, however writing consist of two transactions fist
command is sent (4 bytes) then another write is
done with separate buffer. CS must be low during
those two writes. While write could be performed
successfully current implementation would require
SPI controller to be unlocked between writes.
This could potentially lead to SPI controller
being locked for another device while CS is still
down for spi flash.
In fact due to sanity check spi flash driver
did not work at all with any bus driver since
code tried to lock device before writes and
then both writes would fail due to nested lock
sanity check.

Now sanit check verifies that nested lock is
for same device.

Code assume that node can be locked only once and
second lock is probably for another node.
Lock are internally use on each transaction.
Write, read, write then read transactions can be
used with just one lock.
spiflash driver locks node when it wants to write,
however writing consist of two transactions fist
command is sent (4 bytes) then another write is
done with separate buffer. CS must be low during
those two writes. While write could be performed
successfully current implementation would require
SPI controller to be unlocked between writes.
This could potentially lead to SPI controller
being locked for another device while CS is still
down for spi flash.
In fact due to sanity check spi flash driver
did not work at all with any bus driver since
code tried to lock device before writes and
then both writes would fail due to nested lock
sanity check.

Now sanit check verifies that nested lock is
for same device.

Signed-off-by: Jerzy Kasenberg <[email protected]>
@kasjer kasjer merged commit 793e95c into apache:master Oct 24, 2025
23 checks passed
@kasjer kasjer deleted the kasjer/bus-lock-sanit-fix branch October 24, 2025 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants