Skip to contentSkip to conversation

fs: ext4: Fix alignment of cache buffers

PATCH New Jan Kiszka 4 participants 5 messages Mar 25, 2020 – Mar 27, 2020 ext4 file system

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 fs: ext4: Fix alignment of cache buffers

From: Jan Kiszka <[email protected]>

We need to align the cache buffer to ARCH_DMA_MINALIGN in order to avoid access errors like

CACHE: Misaligned operation at range [be0231e0, be0235e0]

seen on the MCIMX7SABRE.

Fixes d5aee659f217 ("fs: ext4: cache extent data")
---
 fs/ext4/ext4fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4fs.c +1 -1
index 1c616a26a2..966b427a97 100644
@@ -288,7 +288,7 @@ int ext_cache_read(struct ext_block_cache *cache, lbaint_t block, int size)
 	if (cache->buf && cache->block == block && cache->size == size)
 		return 1;
 	ext_cache_fini(cache);
-	cache->buf = malloc(size);
+	cache->buf = memalign(ARCH_DMA_MINALIGN, size);
 	if (!cache->buf)
 		return 0;
 	if (!ext4fs_devread(block, 0, size, cache->buf)) {
Signature · 6 lines
2.16.4


-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#1 lore raw

PATCH 1/1 fs: ext4: Fix alignment of cache buffers

Quoted 20 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

We need to align the cache buffer to ARCH_DMA_MINALIGN in order to avoid access errors like

CACHE: Misaligned operation at range [be0231e0, be0235e0]

seen on the MCIMX7SABRE.

Fixes d5aee659f217 ("fs: ext4: cache extent data")
---
 fs/ext4/ext4fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4fs.c +0 -0
index 1c616a26a2..966b427a97 100644

fs/ext4/ext4fs.c int ext_cache_read(struct ext_block_cache *cache, lbaint_t block, int size) · line 294

Quoted 8 lines
fs/ext4/ext4fs.c +1 -1
@@ -288,7 +288,7 @@ int ext_cache_read(struct ext_block_cache *cache, lbaint_t block, int size)
 	if (cache->buf && cache->block == block && cache->size == size)
 		return 1;
 	ext_cache_fini(cache);
-	cache->buf = malloc(size);
+	cache->buf = memalign(ARCH_DMA_MINALIGN, size);
 	if (!cache->buf)
 		return 0;
 	if (!ext4fs_devread(block, 0, size, cache->buf)) {

Thanks for digging in to this.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200325/6892aa10/attachment.sig>
#2 lore raw

PATCH 1/1 fs: ext4: Fix alignment of cache buffers

In reply to Jan Kiszka
Quoted 11 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

We need to align the cache buffer to ARCH_DMA_MINALIGN in order to avoid access errors like

CACHE: Misaligned operation at range [be0231e0, be0235e0]

seen on the MCIMX7SABRE.

Fixes d5aee659f217 ("fs: ext4: cache extent data")

It's probably just a fluke that this happens to show up on some SoCs/boards/configurations but not others. Or perhaps the MINALIGN value differs?

#3 lore raw

PATCH 1/1 fs: ext4: Fix alignment of cache buffers

In reply to Jan Kiszka
Quoted 9 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

We need to align the cache buffer to ARCH_DMA_MINALIGN in order to avoid access errors like

CACHE: Misaligned operation at range [be0231e0, be0235e0]

seen on the MCIMX7SABRE.

I've also seen this on some i.MX6 devices such as Wandboard, Hummingboard Edge and the UDOO Neo. Tested on the later two, thanks for this fix.

Quoted 26 lines
Fixes d5aee659f217 ("fs: ext4: cache extent data")
---
 fs/ext4/ext4fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4fs.c +1 -2
index 1c616a26a2..966b427a97 100644
@@ -288,7 +288,7 @@ int ext_cache_read(struct ext_block_cache *cache, lbaint_t block, int size)
        if (cache->buf && cache->block == block && cache->size == size)
                return 1;
        ext_cache_fini(cache);
-       cache->buf = malloc(size);
+       cache->buf = memalign(ARCH_DMA_MINALIGN, size);
        if (!cache->buf)
                return 0;
        if (!ext4fs_devread(block, 0, size, cache->buf)) {
--

2.16.4

--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux

#4 lore raw

PATCH 1/1 fs: ext4: Fix alignment of cache buffers

In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

We need to align the cache buffer to ARCH_DMA_MINALIGN in order to avoid access errors like

CACHE: Misaligned operation at range [be0231e0, be0235e0]

Quoted 7 lines

seen on the MCIMX7SABRE.

Fixes d5aee659f217 ("fs: ext4: cache extent data")

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200327/211d77b4/attachment.sig>