]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ext4: cache-align buffers so the invalidation works
authorStephen Warren <swarren@nvidia.com>
Tue, 18 Sep 2012 08:05:28 +0000 (08:05 +0000)
committerTom Rini <trini@ti.com>
Thu, 20 Sep 2012 18:07:26 +0000 (11:07 -0700)
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>
fs/ext4/dev.c
fs/ext4/ext4_common.c
fs/ext4/ext4_common.h

index fb62f241e44c7130bda8f8ecc70aaff5844cbf1b..9e85228edacf8b5c5ae72dec57008d53ad9e09b4 100644 (file)
@@ -62,7 +62,7 @@ int ext4fs_set_blk_dev(block_dev_desc_t *rbdd, int part)
 
 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 */
@@ -107,7 +107,7 @@ int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)
        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,
index 083e45eed5996ec996ece02a9371f34ee7e31ddc..3deffd523e01254e3f9078f4eb17d0d98d47cb90 100644 (file)
@@ -71,7 +71,7 @@ void put_ext4(uint64_t off, void *buf, uint32_t size)
        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;
index 801b8b848ad3caf908a3351a1c19e9bb226daf6f..0af625db2babfe6cde046717d2689a2257a105f0 100644 (file)
 #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,