Skip to content

Commit db3cd1a

Browse files
karstenkoenigdkalowsk
authored andcommitted
drivers: cache: Add barriers to nrf driver
On Cortex-M33 the access to peripheral registers doesn't act as a data synchronization barrier for memory accesses to normal memory. So before triggering any TASKS for cache operations we need to make sure the core doesn't have any pending memory transactions. Signed-off-by: Karsten Koenig <[email protected]>
1 parent 94d355a commit db3cd1a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/cache/cache_nrf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include <zephyr/kernel.h>
77
#include <zephyr/drivers/cache.h>
8+
#include <zephyr/sys/barrier.h>
89
#include <hal/nrf_cache.h>
910
#include <zephyr/logging/log.h>
1011

@@ -67,6 +68,8 @@ static inline int _cache_all(NRF_CACHE_Type *cache, enum k_nrf_cache_op op)
6768

6869
wait_for_cache(cache);
6970

71+
barrier_dsync_fence_full();
72+
7073
switch (op) {
7174

7275
#if NRF_CACHE_HAS_TASK_CLEAN
@@ -101,6 +104,8 @@ static inline void _cache_line(NRF_CACHE_Type *cache, enum k_nrf_cache_op op, ui
101104

102105
nrf_cache_lineaddr_set(cache, line_addr);
103106

107+
barrier_dsync_fence_full();
108+
104109
switch (op) {
105110

106111
#if NRF_CACHE_HAS_TASK_CLEAN

0 commit comments

Comments
 (0)