drivers: stm32: SPI: SPI nocache buffers can be in CONFIG_NOCACHE_MEMORY #61265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The STM32 SPI driver checks buffers are within bounds of nocache memory regions, in case DMA is enabled, so that trying to use a buffer which is not in a nocache region returns an error. The only buffers that are considered nocache at the moment are those that are declared as so in devicetree.
As detected in the issue #60977, there is a problem with this: Zephyr has two different ways of declaring a new cache region. One is declaring such region in devicetree, and the other is using CONFIG_NOCACHE_REGION. Because of this, buffers that are located within these regions must be checked inside the STM32 SPI driver and considered valid.
This PR aims to solve the issue explained above.
Notice that #60977 also remarks another problem: the SPI API states that NULL buffers will be used to send/ignore dummy bytes. In order to pass the
spi_loopback
tests, this needs to be fixed as well.Fixes the two problems mentioned in #60977 that make the SPI loopback tests to fail, that is, send zeroes if a tx null buffer is provided and consider buffers associated to
CONFIG_NOCACHE_REGION
as valid. However, it would be desirable to have loopback tests for buffers in nocache regions declared in devicetree, as mentioned in the above issue's comments. #61021 achieves this, but it would need to be rebased on top of this PR.Note: I believe #52965 has the same problem in
address_in_non_cacheable_sram
Test plan
Connect an STM32H7 board to the PC with pins D11 and D12 connected.
Open a minicom or equivalent terminal to read the test report.
Execute the following commands:
And verify all tests pass. Then, do:
And verify all pass again.