All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V3]fs/fat: align disk buffers on cache line to enable DMA and cache
       [not found] <http://lists.denx.de/pipermail/u-boot/2012-April/#122100>
@ 2012-04-11 14:08 ` Eric Nelson
  2012-04-11 17:50   ` Mike Frysinger
  2012-04-24  9:12   ` Anatolij Gustschin
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Nelson @ 2012-04-11 14:08 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com>
---

V3 increases alignment of globals:
     get_dentfromdir_block
     do_fat_read_block

 fs/fat/fat.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 1f95eb4..a3085b5 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -31,6 +31,8 @@
 #include <fat.h>
 #include <asm/byteorder.h>
 #include <part.h>
+#include <malloc.h>
+#include <linux/compiler.h>
 
 /*
  * Convert a string to lowercase.
@@ -62,7 +64,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,7 +295,7 @@ get_cluster (fsdata *mydata, __u32 clustnum, __u8 *buffer,
 		return -1;
 	}
 	if (size % mydata->sect_size) {
-		__u8 tmpbuf[mydata->sect_size];
+		ALLOC_CACHE_ALIGN_BUFFER(__u8, tmpbuf, mydata->sect_size);
 
 		idx = size / mydata->sect_size;
 		ret = disk_read(startsect + idx, 1, tmpbuf);
@@ -428,8 +430,8 @@ static int slot2str (dir_slot *slotptr, char *l_name, int *idx)
  * into 'retdent'
  * Return 0 on success, -1 otherwise.
  */
-__attribute__ ((__aligned__ (__alignof__ (dir_entry))))
-__u8 get_vfatname_block[MAX_CLUSTSIZE];
+__u8 get_vfatname_block[MAX_CLUSTSIZE]
+	__aligned(ARCH_DMA_MINALIGN);
 
 static int
 get_vfatname (fsdata *mydata, int curclust, __u8 *cluster,
@@ -533,8 +535,8 @@ static __u8 mkcksum (const char *str)
  * Get the directory entry associated with 'filename' from the directory
  * starting at 'startsect'
  */
-__attribute__ ((__aligned__ (__alignof__ (dir_entry))))
-__u8 get_dentfromdir_block[MAX_CLUSTSIZE];
+__u8 get_dentfromdir_block[MAX_CLUSTSIZE]
+	__aligned(ARCH_DMA_MINALIGN);
 
 static dir_entry *get_dentfromdir (fsdata *mydata, int startsect,
 				   char *filename, dir_entry *retdent,
@@ -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,8 +767,8 @@ exit:
 	return ret;
 }
 
-__attribute__ ((__aligned__ (__alignof__ (dir_entry))))
-__u8 do_fat_read_block[MAX_CLUSTSIZE];
+__u8 do_fat_read_block[MAX_CLUSTSIZE]
+	__aligned(ARCH_DMA_MINALIGN);
 
 long
 do_fat_read (const char *filename, void *buffer, unsigned long maxsize,
@@ -828,7 +830,7 @@ do_fat_read (const char *filename, void *buffer, unsigned long maxsize,
 	}
 
 	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;
-- 
1.7.9

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH V3]fs/fat: align disk buffers on cache line to enable DMA and cache
  2012-04-11 14:08 ` [U-Boot] [PATCH V3]fs/fat: align disk buffers on cache line to enable DMA and cache Eric Nelson
@ 2012-04-11 17:50   ` Mike Frysinger
  2012-04-24  9:12   ` Anatolij Gustschin
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2012-04-11 17:50 UTC (permalink / raw)
  To: u-boot

Acked-by: Mike Frysinger <vapier@gentoo.org>
-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/20120411/1929cf33/attachment.pgp>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH V3]fs/fat: align disk buffers on cache line to enable DMA and cache
  2012-04-11 14:08 ` [U-Boot] [PATCH V3]fs/fat: align disk buffers on cache line to enable DMA and cache Eric Nelson
  2012-04-11 17:50   ` Mike Frysinger
@ 2012-04-24  9:12   ` Anatolij Gustschin
  1 sibling, 0 replies; 3+ messages in thread
From: Anatolij Gustschin @ 2012-04-24  9:12 UTC (permalink / raw)
  To: u-boot

On Wed, 11 Apr 2012 07:08:53 -0700
Eric Nelson <eric.nelson@boundarydevices.com> wrote:

> Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com>
> ---
> 
> V3 increases alignment of globals:
>      get_dentfromdir_block
>      do_fat_read_block
> 
>  fs/fat/fat.c |   22 ++++++++++++----------
>  1 files changed, 12 insertions(+), 10 deletions(-)

Applied to u-boot-staging/agust at denx.de, thanks!

Anatolij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-24  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <http://lists.denx.de/pipermail/u-boot/2012-April/#122100>
2012-04-11 14:08 ` [U-Boot] [PATCH V3]fs/fat: align disk buffers on cache line to enable DMA and cache Eric Nelson
2012-04-11 17:50   ` Mike Frysinger
2012-04-24  9:12   ` Anatolij Gustschin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.