public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] bootcount: flush after storing the bootcounter
@ 2018-02-22 11:30 Stefano Babic
  2018-02-22 11:52 ` Lukasz Majewski
  0 siblings, 1 reply; 6+ messages in thread
From: Stefano Babic @ 2018-02-22 11:30 UTC (permalink / raw)
  To: u-boot

If the bootcounter address is in a cached memory,
a flush of dcache must occur after updateing the bootcounter.

Issue found on i.MX6 where bootcounter is put into the internal
(cached) IRAM.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 drivers/bootcount/bootcount.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bootcount/bootcount.c b/drivers/bootcount/bootcount.c
index d5ce450..48594a6 100644
--- a/drivers/bootcount/bootcount.c
+++ b/drivers/bootcount/bootcount.c
@@ -59,6 +59,9 @@ __weak void bootcount_store(ulong a)
 	raw_bootcount_store(reg, a);
 	raw_bootcount_store(reg + 4, BOOTCOUNT_MAGIC);
 #endif /* defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD */
+	flush_dcache_range(CONFIG_SYS_BOOTCOUNT_ADDR,
+				CONFIG_SYS_BOOTCOUNT_ADDR +
+				CONFIG_SYS_CACHELINE_SIZE);
 }
 
 __weak ulong bootcount_load(void)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-23  9:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-22 11:30 [U-Boot] [PATCH] bootcount: flush after storing the bootcounter Stefano Babic
2018-02-22 11:52 ` Lukasz Majewski
2018-02-22 12:16   ` Stefano Babic
2018-02-22 13:03     ` Lukasz Majewski
2018-02-23  6:01       ` Heiko Schocher
2018-02-23  9:05         ` Lukasz Majewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox