diff options
author | Ye Li <ye.li@nxp.com> | 2017-04-06 00:54:58 +0800 |
---|---|---|
committer | Ye Li <ye.li@nxp.com> | 2017-04-06 00:57:32 +0800 |
commit | a99815b57dee42e5b4167174ff5904a1dd3c2d61 (patch) | |
tree | 75a4e50f082b254ee7423d6da0d978e650704aca | |
parent | d469f9fc3d48d606adb69ed9c7b201ec9c00ab19 (diff) | |
download | u-boot-imx-a99815b57dee42e5b4167174ff5904a1dd3c2d61.zip u-boot-imx-a99815b57dee42e5b4167174ff5904a1dd3c2d61.tar.gz u-boot-imx-a99815b57dee42e5b4167174ff5904a1dd3c2d61.tar.bz2 |
MLK-14627 android: Fix cache unaligned warning
The sparse image writing and boot image reading may have cache unaligned problem.
The u-boot v2017 will print warning at runtime. This patch fixes the
unaligned problem.
Signed-off-by: Ye Li <ye.li@nxp.com>
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 964448e..9f07940 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -877,9 +877,42 @@ static int is_sparse_partition(struct fastboot_ptentry *ptn) static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk, lbaint_t blkcnt, const void *buffer) { +#define SPARSE_FILL_BUF_SIZE (2 * 1024 * 1024) + struct blk_desc *dev_desc = (struct blk_desc *)info->priv; + ulong ret = 0; + void *data; + int fill_buf_num_blks, cnt; + + if ((unsigned long)buffer & (CONFIG_SYS_CACHELINE_SIZE - 1)) { + + fill_buf_num_blks = SPARSE_FILL_BUF_SIZE / info->blksz; + + data = memalign(CONFIG_SYS_CACHELINE_SIZE, fill_buf_num_blks * info->blksz); + + while (blkcnt) { + + if (blkcnt > fill_buf_num_blks) + cnt = fill_buf_num_blks; + else + cnt = blkcnt; + + memcpy(data, buffer, cnt * info->blksz); - return blk_dwrite(dev_desc, blk, blkcnt, buffer); + ret += blk_dwrite(dev_desc, blk, cnt, data); + + blk += cnt; + blkcnt -= cnt; + buffer = (void *)((unsigned long)buffer + cnt * info->blksz); + + } + + free(data); + } else { + ret = blk_dwrite(dev_desc, blk, blkcnt, buffer); + } + + return ret; } static lbaint_t mmc_sparse_reserve(struct sparse_storage *info, @@ -1758,7 +1791,7 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) goto fail; } /* flush cache after read */ - flush_cache((ulong)hdr->ramdisk_addr, hdr->ramdisk_size); /* FIXME */ + flush_cache((ulong)hdr->ramdisk_addr, ((hdr->ramdisk_size / 512) + 1) * 512); /* FIXME */ #ifdef CONFIG_OF_LIBFDT /* load the dtb file */ @@ -1771,7 +1804,7 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) goto fail; } /* flush cache after read */ - flush_cache((ulong)hdr->second_addr, hdr->second_size); /* FIXME */ + flush_cache((ulong)hdr->second_addr, ((hdr->second_size / 512) + 1) * 512); /* FIXME */ } #endif /*CONFIG_OF_LIBFDT*/ |