Skip to content

Commit b94ab6e

Browse files
arbraunscarlescufi
authored andcommitted
lib: os: disable caches before reboot
This ensures that all pending writes are committed. This is relevant for flags in .noinit SRAM that are read back after reset. Signed-off-by: Armin Brauns <[email protected]>
1 parent a5f9fc2 commit b94ab6e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/os/reboot.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ extern void sys_arch_reboot(int type);
1414
FUNC_NORETURN void sys_reboot(int type)
1515
{
1616
(void)irq_lock();
17+
18+
/* Disable caches to ensure all data is flushed */
19+
#if defined(CONFIG_ARCH_CACHE)
20+
#if defined(CONFIG_DCACHE)
21+
sys_cache_data_disable();
22+
#endif /* CONFIG_DCACHE */
23+
24+
#if defined(CONFIG_ICACHE)
25+
sys_cache_instr_disable();
26+
#endif /* CONFIG_ICACHE */
27+
#endif /* CONFIG_ARCH_CACHE */
28+
1729
sys_clock_disable();
1830

1931
sys_arch_reboot(type);

0 commit comments

Comments
 (0)