DMA buffer cache invalidation requires that buffers have cache-aligned
buffer locations and sizes. Use memalign() and ALLOC_CACHE_ALIGN_BUFFER()
to ensure this.
On Tegra at least, without this fix, the following fail commands fail in
u-boot-master/ext4, but succeeded at the branch's branch point in
u-boot/master. With this fix, the commands work again:
ext2ls mmc 0:1 /
ext2load mmc 0:1 /boot/zImage
Cc: Uma Shankar <uma.shankar@samsung.com>
Cc: Manjunatha C Achar <a.manjunatha@samsung.com>
Cc: Iqbal Shareef <iqbal.ams@samsung.com>
Cc: Hakgoo Lee <goodguy.lee@samsung.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Tom Rini <trini@ti.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)
{
- char sec_buf[SECTOR_SIZE];
+ ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, SECTOR_SIZE);
unsigned block_len;
/* Check partition boundaries */
block_len = byte_len & ~(SECTOR_SIZE - 1);
if (block_len == 0) {
- u8 p[SECTOR_SIZE];
+ ALLOC_CACHE_ALIGN_BUFFER(u8, p, SECTOR_SIZE);
block_len = SECTOR_SIZE;
ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev,
uint64_t startblock;
uint64_t remainder;
unsigned char *temp_ptr = NULL;
- unsigned char sec_buf[SECTOR_SIZE];
+ ALLOC_CACHE_ALIGN_BUFFER(unsigned char, sec_buf, SECTOR_SIZE);
struct ext_filesystem *fs = get_fs();
startblock = off / (uint64_t)SECTOR_SIZE;
#define SUPERBLOCK_SIZE 1024
#define F_FILE 1
-#define zalloc(size) calloc(1, size)
+static inline void *zalloc(size_t size)
+{
+ void *p = memalign(ARCH_DMA_MINALIGN, size);
+ memset(p, 0, size);
+ return p;
+}
extern unsigned long part_offset;
int ext4fs_read_inode(struct ext2_data *data, int ino,