public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Dirk Behme <dirk.behme@googlemail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] FAT: Properly align buffers to allow cache operations
Date: Mon, 09 Apr 2012 10:20:24 +0200	[thread overview]
Message-ID: <4F829BC8.8090705@googlemail.com> (raw)
In-Reply-To: <1333953903-26335-1-git-send-email-marex@denx.de>

On 09.04.2012 08:45, Marek Vasut wrote:
> 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

> Signed-off-by: Marek Vasut<marex@denx.de>
> ---
>   fs/fat/fat.c |   12 ++++++------
>   1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> index 1f95eb4..d709e59 100644
> --- a/fs/fat/fat.c
> +++ b/fs/fat/fat.c
> @@ -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");

  reply	other threads:[~2012-04-09  8:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-09  6:45 [U-Boot] [PATCH] FAT: Properly align buffers to allow cache operations Marek Vasut
2012-04-09  8:20 ` Dirk Behme [this message]
2012-04-09  8:26   ` Marek Vasut
2012-04-09 10:28     ` Dirk Behme
2012-04-09 10:44       ` Marek Vasut
2012-04-09 13:35     ` Eric Nelson
2012-04-10  4:36 ` Mike Frysinger
2012-04-10  5:00   ` Marek Vasut
2012-04-10 15:07     ` Eric Nelson
2012-04-10 16:20       ` Dirk Behme
2012-04-10 20:34         ` Wolfgang Denk
2012-04-10 23:13           ` Eric Nelson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F829BC8.8090705@googlemail.com \
    --to=dirk.behme@googlemail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox