spi_flash: fix stale data being read from mmaped region

The issue that cache entries are not invalidated correctly sometimes
can also be reproduced for non-encrypted flash as well.
This change updates the workaround to do Cache_Flush, enabling it for
non-encrypted flash, and adds a unit test.
This commit is contained in:
Ivan Grokhotkov
2017-03-04 17:48:44 +08:00
parent 4bf96e99b3
commit d790300215
2 changed files with 24 additions and 2 deletions

View File

@@ -187,12 +187,12 @@ esp_err_t IRAM_ATTR spi_flash_mmap(size_t src_addr, size_t size, spi_flash_mmap_
}
/* This is a temporary fix for an issue where some
encrypted cache reads may see stale data.
cache reads may see stale data.
Working on a long term fix that doesn't require invalidating
entire cache.
*/
if (esp_flash_encryption_enabled() && !did_flush && need_flush) {
if (!did_flush && need_flush) {
Cache_Flush(0);
Cache_Flush(1);
}