FAT: Properly align buffers to allow cache operations
PATCH 1/1 FAT: Properly align buffers to allow cache operations
Align the FAT FS buffers so DMA on various systems can directly pick them.
--- fs/fat/fat.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
fs/fat/fat.c +6 -6
@@ -31,6 +31,7 @@#include <fat.h> #include <asm/byteorder.h> #include <part.h> +#include <malloc.h> /* * Convert a string to lowercase.
@@ -62,7 +63,7 @@ static int disk_read(__u32 block, __u32 nr_blocks, void *buf)int fat_register_device (block_dev_desc_t * dev_desc,int part_no) { -unsigned char buffer[dev_desc->blksz]; + ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);/* First close any currently found FAT filesystem */ cur_dev =NULL ;
@@ -293,9 +294,10 @@ get_cluster (fsdata *mydata, __u32 clustnum, __u8 *buffer,return -1 ; }if (size % mydata->sect_size) { -__u8 tmpbuf[mydata->sect_size]; + ALLOC_CACHE_ALIGN_BUFFER(unsigned char, tmpbuf, mydata->sect_size); idx = size / mydata->sect_size; + ret =disk_read (startsect + idx,1 , tmpbuf);if (ret !=1 ) {debug ("Error reading data (got %d)\n" , ret);
@@ -709,7 +711,7 @@ read_bootsectandvi (boot_sector *bs, volume_info *volinfo, int *fatsize)return -1 ; } - block =malloc (cur_dev->blksz); + block =memalign (ARCH_DMA_MINALIGN , cur_dev->blksz);if (block ==NULL ) {debug ("Error: allocating block\n" );return -1 ;
@@ -765,9 +767,6 @@ exit:return ret; } -__attribute__ ((__aligned__ (__alignof__ (dir_entry )))) -__u8 do_fat_read_block[MAX_CLUSTSIZE ]; -long do_fat_read (const char *filename,void *buffer,unsigned long maxsize,int dols)
@@ -788,6 +787,7 @@ do_fat_read (const char *filename, void *buffer, unsigned long maxsize,__u32 root_cluster =0 ;int rootdir_size =0 ;int j; + uint8_t do_fat_read_block[MAX_CLUSTSIZE] __attribute__((aligned(32)));if (read_bootsectandvi (&bs, &volinfo, &mydata->fatsize)) {debug ("Error: reading boot sector\n" );
Signature · 1 line
1.7.9.1
PATCH 1/1 FAT: Properly align buffers to allow cache operations
Quoted 1 line · Marek Vasut
Align the FAT FS buffers so DMA on various systems can directly pick them.
Just fyi:
http://lists.denx.de/pipermail/u-boot/2012-March/119311.html
http://lists.denx.de/pipermail/u-boot/2012-March/119309.html
Best regards
Dirk
Quoted 65 lines
Signed-off-by Marek Vasut<[email protected]>--- fs/fat/fat.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)fs/fat/fat.c +6
-6@@ -31,6 +31,7 @@#include <fat.h> #include <asm/byteorder.h> #include <part.h> +#include <malloc.h> /* * Convert a string to lowercase. @@ -62,7 +63,7 @@ static int disk_read(__u32 block, __u32 nr_blocks, void *buf)int fat_register_device (block_dev_desc_t * dev_desc,int part_no) { -unsigned char buffer[dev_desc->blksz]; + ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);/* First close any currently found FAT filesystem */ cur_dev =NULL ;@@ -293,9 +294,10 @@ get_cluster (fsdata *mydata, __u32 clustnum, __u8 *buffer,return -1 ; }if (size % mydata->sect_size) { -__u8 tmpbuf[mydata->sect_size]; + ALLOC_CACHE_ALIGN_BUFFER(unsigned char, tmpbuf, mydata->sect_size); idx = size / mydata->sect_size; + ret =disk_read (startsect + idx,1 , tmpbuf);if (ret !=1 ) {debug ("Error reading data (got %d)\n" , ret);@@ -709,7 +711,7 @@ read_bootsectandvi (boot_sector *bs, volume_info *volinfo, int *fatsize)return -1 ; } - block =malloc (cur_dev->blksz); + block =memalign (ARCH_DMA_MINALIGN , cur_dev->blksz);if (block ==NULL ) {debug ("Error: allocating block\n" );return -1 ;@@ -765,9 +767,6 @@ exit:return ret; } -__attribute__ ((__aligned__ (__alignof__ (dir_entry )))) -__u8 do_fat_read_block[MAX_CLUSTSIZE ]; -long do_fat_read (const char *filename,void *buffer,unsigned long maxsize,int dols)@@ -788,6 +787,7 @@ do_fat_read (const char *filename, void *buffer, unsigned long maxsize,__u32 root_cluster =0 ;int rootdir_size =0 ;int j; + uint8_t do_fat_read_block[MAX_CLUSTSIZE] __attribute__((aligned(32)));if (read_bootsectandvi (&bs,&volinfo,&mydata->fatsize)) {debug ("Error: reading boot sector\n" );
PATCH 1/1 FAT: Properly align buffers to allow cache operations
Dear Dirk Behme,
Quoted 9 lines · Marek Vasut
Quoted 2 lines
Align the FAT FS buffers so DMA on various systems can directly pick them.
Just fyi:
http://lists.denx.de/pipermail/u-boot/2012-March/119311.html
http://lists.denx.de/pipermail/u-boot/2012-March/119309.html
Heh, nice! :-)
I've been so dug up in debugging the USB cache issues I didn't bother to look around the list for previous efforts. So obviously, apply Eric's patch! :-)
Quoted 4 lines
Best regards
Dirk
Best regards,
Marek Vasut
PATCH 1/1 FAT: Properly align buffers to allow cache operations
Quoted 8 lines · Marek Vasut
Dear Dirk Behme,
Quoted 6 lines · Marek Vasut
Quoted 2 lines
Align the FAT FS buffers so DMA on various systems can directly pick them.
Just fyi:
Quoted 8 lines
Quoted 3 lines
http://lists.denx.de/pipermail/u-boot/2012-March/119311.html
http://lists.denx.de/pipermail/u-boot/2012-March/119309.html
Heh, nice! :-)
I've been so dug up in debugging the USB cache issues I didn't bother to look around the list for previous efforts. So obviously, apply Eric's patch! :-)
Do you need this for 2012.04? Or is the stuff which needs this scheduled for -next?
Best regards
Dirk
PATCH 1/1 FAT: Properly align buffers to allow cache operations
Dear Dirk Behme,
Quoted 13 lines · Marek Vasut
Quoted 12 lines
Dear Dirk Behme,
Quoted 9 lines · Marek Vasut
Quoted 2 lines
Align the FAT FS buffers so DMA on various systems can directly pick them.
Just fyi:
http://lists.denx.de/pipermail/u-boot/2012-March/119311.html
http://lists.denx.de/pipermail/u-boot/2012-March/119309.html
Quoted 8 lines
Quoted 5 lines
Heh, nice! :-)
I've been so dug up in debugging the USB cache issues I didn't bother to look around the list for previous efforts. So obviously, apply Eric's patch! :-)
Do you need this for 2012.04? Or is the stuff which needs this scheduled for -next?
Definitelly -next, we're on -RC1 now, close to RC2.
Quoted 4 lines
Best regards
Dirk
Best regards,
Marek Vasut
PATCH 1/1 FAT: Properly align buffers to allow cache operations
In reply to Marek VasutQuoted 8 lines · Marek Vasut
Dear Dirk Behme,
Quoted 6 lines · Marek Vasut
Quoted 2 lines
Align the FAT FS buffers so DMA on various systems can directly pick them.
Just fyi:
Quoted 9 lines
Quoted 3 lines
http://lists.denx.de/pipermail/u-boot/2012-March/119311.html
http://lists.denx.de/pipermail/u-boot/2012-March/119309.html
Heh, nice! :-)
I've been so dug up in debugging the USB cache issues I didn't bother to look around the list for previous efforts. So obviously, apply Eric's patch! :-)
Hi guys,
It looks like I missed this bit though:
fs/fat/fat.c +0 -0
@@ -709,7 +711,7 @@ read_bootsectandvi (boot_sector *bs, volume_info *volinfo,
int *fatsize)
return -1;
}
- block = malloc(cur_dev->blksz);
+ block = memalign(ARCH_DMA_MINALIGN, cur_dev->blksz);
if (block == NULL) {
debug("Error: allocating block\n"); return -1;
Perhaps I got lucky in my testing!
Regards,
Eric
PATCH 1/1 FAT: Properly align buffers to allow cache operations
In reply to Marek Vasutfs/fat/fat.c do_fat_read (const char *filename, void *buffer, · line 790
Quoted 11 lines · On Monday 09 April 2012 02:45:03 Marek Vasut wrote:
fs/fat/fat.c +1
-3@@ -765,9 +767,6 @@ -__attribute__ ((__aligned__ (__alignof__ (dir_entry )))) -__u8 do_fat_read_block[MAX_CLUSTSIZE ]; -@@ -788,6 +787,7 @@ do_fat_read (const char *filename, void *buffer,int rootdir_size =0 ;int j; + uint8_t do_fat_read_block[MAX_CLUSTSIZE] __attribute__((aligned(32)));
what's going on here exactly ? the old code had the advantage of being in the bss and the linker taking care of the alignment. this new code has an incorrectly hard-coded "32", and puts a 64KiB array onto the *stack*.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120410/dc01d27d/attachment.pgp>
PATCH 1/1 FAT: Properly align buffers to allow cache operations
Dear Mike Frysinger,
Quoted 9 lines · On Monday 09 April 2012 02:45:03 Marek Vasut wrote:
Quoted 8 lines
fs/fat/fat.c +0
-3@@ -765,9 +767,6 @@ -__attribute__ ((__aligned__ (__alignof__ (dir_entry )))) -__u8 do_fat_read_block[MAX_CLUSTSIZE ]; -@@ -788,6 +787,7 @@ do_fat_read (const char *filename, void *buffer,
Quoted 8 lines
fs/fat/fat.c do_fat_read (const char *filename, void *buffer, unsigned long maxsize,
Quoted 4 lines
fs/fat/fat.c +1
-0int rootdir_size =0 ;int j; + uint8_t do_fat_read_block[MAX_CLUSTSIZE] __attribute__((aligned(32)));what's going on here exactly ? the old code had the advantage of being in the bss and the linker taking care of the alignment. this new code has an incorrectly hard-coded "32", and puts a 64KiB array onto the *stack*.
This will be probably fixed in Eric's patch
Best regards,
Marek Vasut
PATCH 1/1 FAT: Properly align buffers to allow cache operations
Quoted 14 lines · Marek Vasut
Dear Mike Frysinger,
Quoted 12 lines · On Monday 09 April 2012 02:45:03 Marek Vasut wrote:
Quoted 11 lines
fs/fat/fat.c +0
-3@@ -765,9 +767,6 @@ -__attribute__ ((__aligned__ (__alignof__ (dir_entry )))) -__u8 do_fat_read_block[MAX_CLUSTSIZE ]; -@@ -788,6 +787,7 @@ do_fat_read (const char *filename, void *buffer,int rootdir_size =0 ;int j;
Quoted 8 lines
Quoted 5 lines
fs/fat/fat.c do_fat_read (const char *filename, void *buffer, unsigned long maxsize, · line 790
Quoted 1 line
fs/fat/fat.c +1
-0+ uint8_t do_fat_read_block[MAX_CLUSTSIZE] __attribute__((aligned(32)));what's going on here exactly ? the old code had the advantage of being in the bss and the linker taking care of the alignment. this new code has an incorrectly hard-coded "32", and puts a 64KiB array onto the *stack*.
This will be probably fixed in Eric's patch
Yep. I left it in bss space.
PATCH 1/1 FAT: Properly align buffers to allow cache operations
Quoted 24 lines · Eric Nelson
Quoted 23 lines · Marek Vasut
Dear Mike Frysinger,
Quoted 20 lines · On Monday 09 April 2012 02:45:03 Marek Vasut wrote:
fs/fat/fat.c do_fat_read (const char *filename, void *buffer, · line 792
Quoted 13 lines
fs/fat/fat.c +1
-3@@ -765,9 +767,6 @@ -__attribute__ ((__aligned__ (__alignof__ (dir_entry )))) -__u8 do_fat_read_block[MAX_CLUSTSIZE ]; -@@ -788,6 +787,7 @@ do_fat_read (const char *filename, void *buffer,int rootdir_size =0 ;int j; + uint8_t do_fat_read_block[MAX_CLUSTSIZE] __attribute__((aligned(32)));what's going on here exactly ? the old code had the advantage of being in
the bss and the linker taking care of the alignment. this new code has an
incorrectly hard-coded "32", and puts a 64KiB array onto the *stack*.
Quoted 3 lines
Quoted 2 lines
This will be probably fixed in Eric's patch
Yep. I left it in bss space.
Sorry guys, but I'm confused now.
We have two patches, Eric's [1] and Marek's [2]. Which one should we take? With the discussion here and [3] I'm somehow under the impression that both patches [1] [2] are not complete?
Do I miss anything? Or do we need a new version ("best of [1] & [2]")?
Best regards
Dirk
[1] http://lists.denx.de/pipermail/u-boot/2012-March/119311.html
[2] http://lists.denx.de/pipermail/u-boot/2012-April/122100.html
[3] http://lists.denx.de/pipermail/u-boot/2012-April/122126.html
PATCH 1/1 FAT: Properly align buffers to allow cache operations
Dear Dirk,
Quoted 2 lines · In message <[email protected]> you wrote:
Sorry guys, but I'm confused now.
Heh. Me too ;-)
Quoted 5 lines
We have two patches, Eric's [1] and Marek's [2]. Which one should we take? With the discussion here and [3] I'm somehow under the impression that both patches [1] [2] are not complete?
Do I miss anything? Or do we need a new version ("best of [1] & [2]")?
I'm waiting for Eric to post an updated patch that includes 1+2+3.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Any sufficiently advanced technology is indistinguishable from magic.
Clarke's Third Law - _Profiles of the Future_ (1962; rev. 1973)
``Hazards of Prophecy: The Failure of Imagination''PATCH 1/1 FAT: Properly align buffers to allow cache operations
Quoted 8 lines · Wolfgang Denk
Dear Dirk,
Quoted 2 lines · In message<[email protected]> you wrote:
Sorry guys, but I'm confused now.
Heh. Me too ;-)
Quoted 8 lines
Quoted 5 lines
We have two patches, Eric's [1] and Marek's [2]. Which one should we take? With the discussion here and [3] I'm somehow under the impression that both patches [1] [2] are not complete?
Do I miss anything? Or do we need a new version ("best of [1]& [2]")?
I'm waiting for Eric to post an updated patch that includes 1+2+3.
I guess I had better get busy ;)
I can probably handle 1 and 2 and my guess is that #3 will appear with a fresh re-read of the code.
I should be able to get this out in the A.M. (Arizona time).
Regards,
Eric