Commit 55b523b7d4ab885142f77d388007eb5490ba6bf4
Committed by
Tom Rini
1 parent
ed34f34dba
Exists in
master
and in
57 other branches
ext4: cache-align buffers so the invalidation works
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>
Showing 3 changed files with 9 additions and 4 deletions Side-by-side Diff
fs/ext4/dev.c
| ... | ... | @@ -62,7 +62,7 @@ |
| 62 | 62 | |
| 63 | 63 | int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf) |
| 64 | 64 | { |
| 65 | - char sec_buf[SECTOR_SIZE]; | |
| 65 | + ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, SECTOR_SIZE); | |
| 66 | 66 | unsigned block_len; |
| 67 | 67 | |
| 68 | 68 | /* Check partition boundaries */ |
| ... | ... | @@ -107,7 +107,7 @@ |
| 107 | 107 | block_len = byte_len & ~(SECTOR_SIZE - 1); |
| 108 | 108 | |
| 109 | 109 | if (block_len == 0) { |
| 110 | - u8 p[SECTOR_SIZE]; | |
| 110 | + ALLOC_CACHE_ALIGN_BUFFER(u8, p, SECTOR_SIZE); | |
| 111 | 111 | |
| 112 | 112 | block_len = SECTOR_SIZE; |
| 113 | 113 | ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev, |
fs/ext4/ext4_common.c
| ... | ... | @@ -71,7 +71,7 @@ |
| 71 | 71 | uint64_t startblock; |
| 72 | 72 | uint64_t remainder; |
| 73 | 73 | unsigned char *temp_ptr = NULL; |
| 74 | - unsigned char sec_buf[SECTOR_SIZE]; | |
| 74 | + ALLOC_CACHE_ALIGN_BUFFER(unsigned char, sec_buf, SECTOR_SIZE); | |
| 75 | 75 | struct ext_filesystem *fs = get_fs(); |
| 76 | 76 | |
| 77 | 77 | startblock = off / (uint64_t)SECTOR_SIZE; |
fs/ext4/ext4_common.h
| ... | ... | @@ -55,7 +55,12 @@ |
| 55 | 55 | #define SUPERBLOCK_SIZE 1024 |
| 56 | 56 | #define F_FILE 1 |
| 57 | 57 | |
| 58 | -#define zalloc(size) calloc(1, size) | |
| 58 | +static inline void *zalloc(size_t size) | |
| 59 | +{ | |
| 60 | + void *p = memalign(ARCH_DMA_MINALIGN, size); | |
| 61 | + memset(p, 0, size); | |
| 62 | + return p; | |
| 63 | +} | |
| 59 | 64 | |
| 60 | 65 | extern unsigned long part_offset; |
| 61 | 66 | int ext4fs_read_inode(struct ext2_data *data, int ino, |