Patchwork [U-Boot,v2] dcache: Dcache line size aligned stack buffer allocation

login
register
mail settings
Submitter Łukasz Majewski
Date Aug. 30, 2011, 11:45 a.m.
Message ID <1314704718-26385-1-git-send-email-l.majewski@samsung.com>
Download mbox | patch
Permalink /patch/112262/
State Superseded
Headers show

Comments

Łukasz Majewski - Aug. 30, 2011, 11:45 a.m.
ALLOC_CACHE_ALIGN_BUFFER shall be used in functions, which are using
stack allocated buffers for DMA transfers.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Albert ARIBAUD <albert.u.boot@aribaud.net>
---
Changes for v2:
	- ./include/cache.h has been removed and replaced with
	simpler macro added to ./include/common.h
---
 include/common.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
Anton Staaf - Aug. 30, 2011, 5:15 p.m.
On Tue, Aug 30, 2011 at 4:45 AM, Lukasz Majewski <l.majewski@samsung.com> wrote:
> ALLOC_CACHE_ALIGN_BUFFER shall be used in functions, which are using
> stack allocated buffers for DMA transfers.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Albert ARIBAUD <albert.u.boot@aribaud.net>
> ---
> Changes for v2:
>        - ./include/cache.h has been removed and replaced with
>        simpler macro added to ./include/common.h
> ---
>  include/common.h |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/include/common.h b/include/common.h
> index 12a1074..5bc3af8 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -767,6 +767,11 @@ int cpu_release(int nr, int argc, char * const argv[]);
>  #define ALIGN(x,a)             __ALIGN_MASK((x),(typeof(x))(a)-1)
>  #define __ALIGN_MASK(x,mask)   (((x)+(mask))&~(mask))
>
> +#define ALLOC_CACHE_ALIGN_BUFFER(type, name, size) \
> +       char *__##name[size + CONFIG_SYS_CACHELINE_SIZE]; \

This should be a "char" array, not a "char *" array.  And the size
should be "size + CONFIG_SYS_CACHELINE_SIZE - 1".

Thanks,
    Anton

> +       type *name = ALIGN(((typeof(CONFIG_SYS_CACHELINE_SIZE))(__##name)),\
> +                          (CONFIG_SYS_CACHELINE_SIZE));
> +
>  /* Pull in stuff for the build system */
>  #ifdef DO_DEPS_ONLY
>  # include <environment.h>
> --
> 1.7.2.3
>
>

Patch

diff --git a/include/common.h b/include/common.h
index 12a1074..5bc3af8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -767,6 +767,11 @@  int cpu_release(int nr, int argc, char * const argv[]);
 #define ALIGN(x,a)		__ALIGN_MASK((x),(typeof(x))(a)-1)
 #define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
 
+#define ALLOC_CACHE_ALIGN_BUFFER(type, name, size) \
+	char *__##name[size + CONFIG_SYS_CACHELINE_SIZE]; \
+	type *name = ALIGN(((typeof(CONFIG_SYS_CACHELINE_SIZE))(__##name)),\
+			   (CONFIG_SYS_CACHELINE_SIZE));
+
 /* Pull in stuff for the build system */
 #ifdef DO_DEPS_ONLY
 # include <environment.h>