Commit 55b523b7d4ab885142f77d388007eb5490ba6bf4

Authored by Stephen Warren
Committed by Tom Rini
1 parent ed34f34dba
Exists in master and in 57 other branches 8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf-6.6.52-2.2.0, emb_lf_v2022.04, emb_lf_v2023.04, emb_lf_v2024.04, imx_v2015.04_4.1.15_1.0.0_ga, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-emmc-imx_v2014.04_3.10.53_1.1.0_ga, smarc-emmc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx-l5.0.0_1.0.0-ga, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2017.03_4.9.11_1.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx_v2015.04_4.1.15_1.0.0_ga, smarc-imx_v2017.03_4.9.11_1.0.0_ga, smarc-imx_v2017.03_4.9.88_2.0.0_ga, smarc-imx_v2017.03_o8.1.0_1.3.0_8m, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc-m6.0.1_2.1.0-ga, smarc-n7.1.2_2.0.0-ga, smarc-rel_imx_4.1.15_2.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0, smarc_8mq_lf_v2020.04, ti-u-boot-2015.07, u-boot-2013.01.y, v2013.10, v2013.10-smarct33, v2013.10-smartmen, v2014.01, v2014.04, v2014.04-smarct33, v2014.04-smarct33-emmc, v2014.04-smartmen, v2014.07, v2014.07-smarct33, v2014.07-smartmen, v2015.07-smarct33, v2015.07-smarct33-emmc, v2015.07-smarct4x, v2016.05-dlt, v2016.05-smarct3x, v2016.05-smarct3x-emmc, v2016.05-smarct4x, v2017.01-smarct3x, v2017.01-smarct3x-emmc, v2017.01-smarct4x

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

... ... @@ -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,