]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
sf: allocate cache aligned buffers to copy from flash
authorRavi Babu <ravibabu@ti.com>
Mon, 17 Aug 2015 07:59:48 +0000 (13:29 +0530)
committerLothar Waßmann <LW@KARO-electronics.de>
Thu, 10 Sep 2015 08:24:14 +0000 (10:24 +0200)
Use memalign() with ARCH_DMA_MINALIGN to allocate read buffers.
This is required because, flash drivers may use DMA for read operations
and may have to invalidate the buffer before read.

Signed-off-by: Ravi Babu <ravibabu@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>
Tested-by: Jagan Teki <jteki@openedev.com>
common/cmd_sf.c

index 3746e0d9644f08aca368e60cf153387a79dab187..ac7f5dfb8181c28147ed9b1ea83e62e59c8ef20a 100644 (file)
@@ -223,7 +223,7 @@ static int spi_flash_update(struct spi_flash *flash, u32 offset,
 
        if (end - buf >= 200)
                scale = (end - buf) / 100;
-       cmp_buf = malloc(flash->sector_size);
+       cmp_buf = memalign(ARCH_DMA_MINALIGN, flash->sector_size);
        if (cmp_buf) {
                ulong last_update = get_timer(0);
 
@@ -484,12 +484,12 @@ static int do_spi_flash_test(int argc, char * const argv[])
        if (*argv[2] == 0 || *endp != 0)
                return -1;
 
-       vbuf = malloc(len);
+       vbuf = memalign(ARCH_DMA_MINALIGN, len);
        if (!vbuf) {
                printf("Cannot allocate memory (%lu bytes)\n", len);
                return 1;
        }
-       buf = malloc(len);
+       buf = memalign(ARCH_DMA_MINALIGN, len);
        if (!buf) {
                free(vbuf);
                printf("Cannot allocate memory (%lu bytes)\n", len);