mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <dev@lynxeye.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org,
	Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Subject: Re: [PATCH] ARM: invalidate data caches during early init
Date: Fri, 17 May 2013 21:06:45 +0200	[thread overview]
Message-ID: <1368817605.2463.1.camel@antimon> (raw)
In-Reply-To: <1368779715-3143-1-git-send-email-s.hauer@pengutronix.de>


[-- Attachment #1.1: Type: text/plain, Size: 3001 bytes --]

Am Freitag, den 17.05.2013, 10:35 +0200 schrieb Sascha Hauer:
> Some SoCs come up with invalid entries in the data cache. This can
> lead to memory corruption when we enable them later, so invalidate
> the caches early.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> CC: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>

Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Lucas Stach <l.stach@pengutronix.de>

> ---
> 
> This is based on the patches Enrico recently sent. Enrico, I hope
> this fixes your data cache issues in a way that you do not have
> to add this to your board code.
> 
>  arch/arm/cpu/cache.c         | 21 +++++++++++++++++++++
>  arch/arm/cpu/start-pbl.c     |  2 ++
>  arch/arm/cpu/start.c         |  2 ++
>  arch/arm/include/asm/cache.h |  5 +++++
>  4 files changed, 30 insertions(+)
> 
> diff --git a/arch/arm/cpu/cache.c b/arch/arm/cpu/cache.c
> index 95c8338..7aab55b 100644
> --- a/arch/arm/cpu/cache.c
> +++ b/arch/arm/cpu/cache.c
> @@ -134,3 +134,24 @@ void arm_early_mmu_cache_flush(void)
>  #endif
>  	}
>  }
> +
> +void v7_mmu_cache_invalidate(void);
> +
> +void arm_early_mmu_cache_invalidate(void)
> +{
> +	switch (arm_early_get_cpu_architecture()) {
> +	case CPU_ARCH_ARMv4T:
> +	case CPU_ARCH_ARMv5:
> +	case CPU_ARCH_ARMv5T:
> +	case CPU_ARCH_ARMv5TE:
> +	case CPU_ARCH_ARMv5TEJ:
> +	case CPU_ARCH_ARMv6:
> +		asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
> +		return;
> +#ifdef CONFIG_CPU_32v7
> +	case CPU_ARCH_ARMv7:
> +		v7_mmu_cache_invalidate();
> +		return;
> +#endif
> +	}
> +}
> diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
> index 6f03c4a..3ef0118 100644
> --- a/arch/arm/cpu/start-pbl.c
> +++ b/arch/arm/cpu/start-pbl.c
> @@ -59,6 +59,8 @@ static noinline __noreturn void __barebox_arm_entry(uint32_t membase,
>  
>  	endmem -= STACK_SIZE; /* stack */
>  
> +	arm_early_mmu_cache_invalidate();
> +
>  	if (IS_ENABLED(CONFIG_PBL_RELOCATABLE))
>  		relocate_to_current_adr();
>  
> diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
> index 580c1fe..5a3c629 100644
> --- a/arch/arm/cpu/start.c
> +++ b/arch/arm/cpu/start.c
> @@ -124,6 +124,8 @@ void __naked __noreturn barebox_arm_entry(uint32_t membase, uint32_t memsize,
>  {
>  	arm_setup_stack(membase + memsize - 16);
>  
> +	arm_early_mmu_cache_invalidate();
> +
>  	__start(membase, memsize, boarddata);
>  }
>  #else
> diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
> index e5621eb..f5f8bf3 100644
> --- a/arch/arm/include/asm/cache.h
> +++ b/arch/arm/include/asm/cache.h
> @@ -10,10 +10,15 @@ int arm_set_cache_functions(void);
>  
>  #ifdef CONFIG_MMU
>  void arm_early_mmu_cache_flush(void);
> +void arm_early_mmu_cache_invalidate(void);
>  #else
>  static inline void arm_early_mmu_cache_flush(void)
>  {
>  }
> +
> +static inline void arm_early_mmu_cache_invalidate(void)
> +{
> +}
>  #endif
>  
>  #endif


[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5715 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-05-17 19:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-17  8:35 Sascha Hauer
2013-05-17 19:06 ` Lucas Stach [this message]
2013-05-18  9:11   ` Sascha Hauer
2013-05-20 15:21     ` Lucas Stach

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=1368817605.2463.1.camel@antimon \
    --to=dev@lynxeye.de \
    --cc=barebox@lists.infradead.org \
    --cc=enrico.scholz@sigma-chemnitz.de \
    --cc=s.hauer@pengutronix.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