]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
stm32: stm32_flash: add memory barrier during flash write
authorVikas Manocha <vikas.manocha@st.com>
Mon, 4 Apr 2016 23:49:02 +0000 (16:49 -0700)
committerTom Rini <trini@konsulko.com>
Tue, 12 Apr 2016 00:48:23 +0000 (20:48 -0400)
After writing data to flash space, next instruction is checking if flash
controller is busy writing to the flash memory. Memory barrier is required here
to avoid transaction re-ordering for data write and busy status check.

Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
drivers/mtd/stm32_flash.c

index 71f48543a3959dd49e5a36c3bf872210169bf8a9..e16b6cd674fc9684e989f07f50082a83f52ed8b2 100644 (file)
@@ -137,6 +137,10 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
        /* To make things simple use byte writes only */
        for (i = 0; i < cnt; i++) {
                *(uchar *)(addr + i) = src[i];
+               /*  avoid re-ordering flash data write and busy status
+                *  check as flash memory space attributes are generally Normal
+                */
+               mb();
                while (readl(&STM32_FLASH->sr) & STM32_FLASH_SR_BSY)
                        ;
        }