Skip to contentSkip to conversation

fs: fat: Fix cache align error message in fatwrite to use USB media

PATCH New Nobuhiro Iwamatsu 2 participants 3 messages Apr 3, 2014 – Apr 8, 2014 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: fat: Fix cache align error message in fatwrite to use USB media

Use of malloc of do_fat_write() from USB media causes cache error on ARM v7 platforms. Perhaps, the same problem will occur at any other CPUs. This replaces malloc with memalign to fix cache buffer alignment.

---
 fs/fat/fat_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/fat_write.c +1 -1
index 9f5e911..cef138e 100644
@@ -952,7 +952,7 @@ static int do_fat_write(const char *filename, void *buffer,
 	}
 
 	mydata->fatbufnum = -1;
-	mydata->fatbuf = malloc(FATBUFSIZE);
+	mydata->fatbuf = memalign(ARCH_DMA_MINALIGN, FATBUFSIZE);
 	if (mydata->fatbuf == NULL) {
 		debug("Error: allocating memory\n");
 		return -1;
Signature · 1 line
1.8.5
#1 lore raw

PATCH 1/1 fs: fat: Fix cache align error message in fatwrite to use USB media

Hello,

Quoted 1 line · Nobuhiro Iwamatsu

Use of malloc of do_fat_write() from USB media causes cache error on

I would remove 'from USB media' from the commit log as it doesn't really matter where you read from.

Quoted 15 lines

ARM v7 platforms. Perhaps, the same problem will occur at any other CPUs. This replaces malloc with memalign to fix cache buffer alignment.

---
  fs/fat/fat_write.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/fat_write.c +0 -0
index 9f5e911..cef138e 100644

fs/fat/fat_write.c static int do_fat_write(const char *filename, void *buffer, · line 958

Quoted 8 lines
fs/fat/fat_write.c +1 -1
@@ -952,7 +952,7 @@ static int do_fat_write(const char *filename, void *buffer,
  	}
 
  	mydata->fatbufnum = -1;
-	mydata->fatbuf = malloc(FATBUFSIZE);
+	mydata->fatbuf = memalign(ARCH_DMA_MINALIGN, FATBUFSIZE);
  	if (mydata->fatbuf == NULL) {
  		debug("Error: allocating memory\n");
  		return -1;

Tested on an i.MX6 custom platform.

Thanks,

Signature · 1 line
H?ctor Palacios
#2 lore raw

PATCH 1/1 fs: fat: Fix cache align error message in fatwrite to use USB media

Hi!

2014-04-07 23:19 GMT+09:00 Hector Palacios <[email protected]>:

Quoted 10 lines

Hello,

Quoted 2 lines · Nobuhiro Iwamatsu

Use of malloc of do_fat_write() from USB media causes cache error on

I would remove 'from USB media' from the commit log as it doesn't really matter where you read from.

I see. I will remove and re-send.

Quoted 29 lines
Quoted 24 lines

ARM v7 platforms. Perhaps, the same problem will occur at any other CPUs. This replaces malloc with memalign to fix cache buffer alignment.

---
  fs/fat/fat_write.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/fat_write.c +1 -1
index 9f5e911..cef138e 100644
@@ -952,7 +952,7 @@ static int do_fat_write(const char *filename, void
 *buffer,
        }
 
        mydata->fatbufnum = -1;
-       mydata->fatbuf = malloc(FATBUFSIZE);
+       mydata->fatbuf = memalign(ARCH_DMA_MINALIGN, FATBUFSIZE);
        if (mydata->fatbuf == NULL) {
                debug("Error: allocating memory\n");
Quoted 2 lines
                return -1;

Tested on an i.MX6 custom platform.

Quoted 2 lines

Thanks for your test!

Quoted 1 line

Thanks,

Best regards,
Nobuhiro

Signature · 1 line
Nobuhiro Iwamatsu