[U-Boot] [PATCH 1/2] part_dos: allocate cacheline aligned buffers

2012-04-24 Thread Thierry Reding
Some hardware requires the data buffers to be cacheline-aligned to make
sure DMA operations can be properly executed.

This patch uses the ALLOC_CACHE_ALIGN_BUFFER macro to allocate buffers
with proper alignment. The same was already done for EFI partitions in
commit f75dd58 "part_efi: dcache: allocate cacheline aligned buffers".

Signed-off-by: Thierry Reding 
---
This fixes boot failures on Avionic Design Plutux and Medcom boards.

 disk/part_dos.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/disk/part_dos.c b/disk/part_dos.c
index b5bcb37..c028aaf 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -87,7 +87,7 @@ static int test_block_type(unsigned char *buffer)
 
 int test_part_dos (block_dev_desc_t *dev_desc)
 {
-   unsigned char buffer[dev_desc->blksz];
+   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
 
if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1) 
||
(buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
@@ -102,7 +102,7 @@ int test_part_dos (block_dev_desc_t *dev_desc)
 static void print_partition_extended (block_dev_desc_t *dev_desc, int 
ext_part_sector, int relative,
   int part_num)
 {
-   unsigned char buffer[dev_desc->blksz];
+   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
dos_partition_t *pt;
int i;
 
@@ -166,7 +166,7 @@ static int get_partition_info_extended (block_dev_desc_t 
*dev_desc, int ext_part
 int relative, int part_num,
 int which_part, disk_partition_t *info)
 {
-   unsigned char buffer[dev_desc->blksz];
+   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
dos_partition_t *pt;
int i;
 
-- 
1.7.10

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] part_dos: allocate cacheline aligned buffers

2012-04-24 Thread Simon Glass
On Tue, Apr 24, 2012 at 7:53 PM, Thierry Reding
 wrote:
> Some hardware requires the data buffers to be cacheline-aligned to make
> sure DMA operations can be properly executed.
>
> This patch uses the ALLOC_CACHE_ALIGN_BUFFER macro to allocate buffers
> with proper alignment. The same was already done for EFI partitions in
> commit f75dd58 "part_efi: dcache: allocate cacheline aligned buffers".
>
> Signed-off-by: Thierry Reding 

Acked-by: Simon Glass 

> ---
> This fixes boot failures on Avionic Design Plutux and Medcom boards.
>
>  disk/part_dos.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/disk/part_dos.c b/disk/part_dos.c
> index b5bcb37..c028aaf 100644
> --- a/disk/part_dos.c
> +++ b/disk/part_dos.c
> @@ -87,7 +87,7 @@ static int test_block_type(unsigned char *buffer)
>
>  int test_part_dos (block_dev_desc_t *dev_desc)
>  {
> -       unsigned char buffer[dev_desc->blksz];
> +       ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
>
>        if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1) 
> ||
>            (buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
> @@ -102,7 +102,7 @@ int test_part_dos (block_dev_desc_t *dev_desc)
>  static void print_partition_extended (block_dev_desc_t *dev_desc, int 
> ext_part_sector, int relative,
>                                                           int part_num)
>  {
> -       unsigned char buffer[dev_desc->blksz];
> +       ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
>        dos_partition_t *pt;
>        int i;
>
> @@ -166,7 +166,7 @@ static int get_partition_info_extended (block_dev_desc_t 
> *dev_desc, int ext_part
>                                 int relative, int part_num,
>                                 int which_part, disk_partition_t *info)
>  {
> -       unsigned char buffer[dev_desc->blksz];
> +       ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
>        dos_partition_t *pt;
>        int i;
>
> --
> 1.7.10
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] part_dos: allocate cacheline aligned buffers

2012-04-24 Thread Thierry Reding
* Simon Glass wrote:
> On Tue, Apr 24, 2012 at 7:53 PM, Thierry Reding
>  wrote:
> > Some hardware requires the data buffers to be cacheline-aligned to make
> > sure DMA operations can be properly executed.
> >
> > This patch uses the ALLOC_CACHE_ALIGN_BUFFER macro to allocate buffers
> > with proper alignment. The same was already done for EFI partitions in
> > commit f75dd58 "part_efi: dcache: allocate cacheline aligned buffers".
> >
> > Signed-off-by: Thierry Reding 
> 
> Acked-by: Simon Glass 

I just noticed that the same patch was already posted by Eric Nelson back in
March. Anatolij Gustschin just applied it to u-boot-staging/ag...@denx.de.

Thierry


pgpe8SwBfk95x.pgp
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot