bootcount: flush after storing the bootcounter
authorStefano Babic <sbabic@denx.de>
Thu, 22 Feb 2018 11:30:41 +0000 (12:30 +0100)
committerStefano Babic <sbabic@denx.de>
Mon, 23 Jul 2018 07:55:20 +0000 (09:55 +0200)
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

index e00d81c93402e5d43b00248f703f7c96d9f36e3b..a3162c97edd3d9a01a64645e91a1ba662c6bc537 100644 (file)
@@ -18,6 +18,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)