[U-Boot] [PATCH] gunzip: cache-align write buffer memory

Stefan Agner stefan at agner.ch
Mon Aug 29 22:43:20 CEST 2016


On 2016-08-29 08:10, Clemens Gruber wrote:
> When using gzwrite to eMMC on an i.MX6Q board, the following warning
> occurs repeatedly:
> CACHE: Misaligned operation at range [4fd63318, 4fe63318]
> 
> This patch cache-aligns the memory allocation for the gzwrite writebuf,
> therefore avoiding the misaligned dcache flush and the warning from
> check_cache_range.
> 
> Signed-off-by: Clemens Gruber <clemens.gruber at pqgruber.com>
> ---
>  lib/gunzip.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/gunzip.c b/lib/gunzip.c
> index bc746d6..832b306 100644
> --- a/lib/gunzip.c
> +++ b/lib/gunzip.c
> @@ -11,6 +11,7 @@
>  #include <console.h>
>  #include <image.h>
>  #include <malloc.h>
> +#include <memalign.h>
>  #include <u-boot/zlib.h>
>  #include <div64.h>
>  
> @@ -193,7 +194,7 @@ int gzwrite(unsigned char *src, int len,
>  
>  	s.next_in = src + i;
>  	s.avail_in = payload_size+8;
> -	writebuf = (unsigned char *)malloc(szwritebuf);
> +	writebuf = (unsigned char *)malloc_cache_aligned(szwritebuf);
>  
>  	/* decompress until deflate stream ends or end of file */
>  	do {

I wondered about the length of the buffer, but szwritebuf is forced to
be a multiple of the device block size, which is typically quite a bit
bigger than a cache line, so I think we are fine there.

Reviewed-by: Stefan Agner <stefan.agner at toradex.com>

--
Stefan


More information about the U-Boot mailing list