diff mbox

[U-Boot] bootcounter_ram: Flush dcache after data is written into SDRAM

Message ID 1459933342-18264-1-git-send-email-sr@denx.de
State Accepted
Commit 20adda4cf8980a9df1d966bd7bec918ac3e4e5d6
Delegated to: Tom Rini
Headers show

Commit Message

Stefan Roese April 6, 2016, 9:02 a.m. UTC
This patch adds a call to flush_dcache_range() to bootcount_store() to
make sure, that the bootcounter data (including the patterns) is
written to memory. Without this, platforms with dcache enabled may not
have the bootcounter updated upon reset.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Valentin Longchamp <valentin.longchamp@keymile.com>
---
 drivers/bootcount/bootcount_ram.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Tom Rini April 12, 2016, 2:30 a.m. UTC | #1
On Wed, Apr 06, 2016 at 11:02:22AM +0200, Stefan Roese wrote:

> This patch adds a call to flush_dcache_range() to bootcount_store() to
> make sure, that the bootcounter data (including the patterns) is
> written to memory. Without this, platforms with dcache enabled may not
> have the bootcounter updated upon reset.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Valentin Longchamp <valentin.longchamp@keymile.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/bootcount/bootcount_ram.c b/drivers/bootcount/bootcount_ram.c
index 5bdabcd..e0d2669 100644
--- a/drivers/bootcount/bootcount_ram.c
+++ b/drivers/bootcount/bootcount_ram.c
@@ -35,6 +35,9 @@  void bootcount_store(ulong a)
 		writel(patterns[i % NBR_OF_PATTERNS],
 			&save_addr[i + OFFS_PATTERN]);
 
+	/* Make sure the data is written to RAM */
+	flush_dcache_range((ulong)&save_addr[0],
+			   (ulong)&save_addr[REPEAT_PATTERN + OFFS_PATTERN]);
 }
 
 ulong bootcount_load(void)