Patchwork [U-Boot,v3,4/6] ext2: Cache line aligned partial sector bounce buffer

login
register
mail settings
Submitter Anton staaf
Date Oct. 12, 2011, 11:56 p.m.
Message ID <1318463764-28244-5-git-send-email-robotboy@chromium.org>
Download mbox | patch
Permalink /patch/119334/
State Accepted
Headers show

Comments

Anton staaf - Oct. 12, 2011, 11:56 p.m.
Currently, if a device read request is done that does not begin or end
on a sector boundary a stack allocated bounce buffer is used to perform
the read, and then just the part of the sector that is needed is copied
into the users buffer.  This stack allocation can mean that the bounce
buffer will not be aligned to the dcache line size.  This is a problem
when caches are enabled because unaligned cache invalidates are not
safe.

This patch uses ALLOC_CACHE_ALIGN_BUFFER to create a stack allocated
cache line size aligned bounce buffer.

Signed-off-by: Anton Staaf <robotboy@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Dave Liu <r63238@freescale.com>
Cc: Andy Fleming <afleming@gmail.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
---
 fs/ext2/dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Wolfgang Denk - Oct. 25, 2011, 7:25 a.m.
Dear Anton Staaf,

In message <1318463764-28244-5-git-send-email-robotboy@chromium.org> you wrote:
> Currently, if a device read request is done that does not begin or end
> on a sector boundary a stack allocated bounce buffer is used to perform
> the read, and then just the part of the sector that is needed is copied
> into the users buffer.  This stack allocation can mean that the bounce
> buffer will not be aligned to the dcache line size.  This is a problem
> when caches are enabled because unaligned cache invalidates are not
> safe.
> 
> This patch uses ALLOC_CACHE_ALIGN_BUFFER to create a stack allocated
> cache line size aligned bounce buffer.
> 
> Signed-off-by: Anton Staaf <robotboy@chromium.org>
> Acked-by: Mike Frysinger <vapier@gentoo.org>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
> Cc: Dave Liu <r63238@freescale.com>
> Cc: Andy Fleming <afleming@gmail.com>
> Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
> ---
>  fs/ext2/dev.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Patch

diff --git a/fs/ext2/dev.c b/fs/ext2/dev.c
index 78851d0..874e211 100644
--- a/fs/ext2/dev.c
+++ b/fs/ext2/dev.c
@@ -52,7 +52,7 @@  int ext2fs_set_blk_dev(block_dev_desc_t *rbdd, int part)
 
 int ext2fs_devread(int sector, int byte_offset, int byte_len, char *buf)
 {
-	char sec_buf[SECTOR_SIZE];
+	ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, SECTOR_SIZE);
 	unsigned sectors;
 
 	/*