* [PATCH] Arm: i.MX5: Do not disable L2 cache
@ 2020-06-18 12:12 Sascha Hauer
2020-06-18 12:21 ` Lucas Stach
0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2020-06-18 12:12 UTC (permalink / raw)
To: Barebox List
Disabling the L2 cache is not working in imx5_init_lowlevel() because
the necessary cache maintenance operations are missing. This often
results in cache corruption in a chainloaded barebox.
Disabling the cache is unnecessary: when we come from the ROM the L2
cache is disabled anyway, so disabling it is a no-op. When we get here
in a chainloaded barebox the L2 cache is already enabled and correctly
configured. So instead of initializing it again we can take an enabled
L2 cache as a sign to skip initialization and just return from the
function.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/imx5.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-imx/imx5.c b/arch/arm/mach-imx/imx5.c
index 96288f99e0..dd6c079fe3 100644
--- a/arch/arm/mach-imx/imx5.c
+++ b/arch/arm/mach-imx/imx5.c
@@ -37,10 +37,13 @@ void imx5_init_lowlevel(void)
{
u32 r;
- /* ARM errata ID #468414 */
__asm__ __volatile__("mrc 15, 0, %0, c1, c0, 1":"=r"(r));
+
+ if (r & (1 << 1))
+ return;
+
+ /* ARM errata ID #468414 */
r |= (1 << 5); /* enable L1NEON bit */
- r &= ~(1 << 1); /* explicitly disable L2 cache */
__asm__ __volatile__("mcr 15, 0, %0, c1, c0, 1" : : "r"(r));
/* reconfigure L2 cache aux control reg */
--
2.27.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Arm: i.MX5: Do not disable L2 cache
2020-06-18 12:12 [PATCH] Arm: i.MX5: Do not disable L2 cache Sascha Hauer
@ 2020-06-18 12:21 ` Lucas Stach
2020-06-26 4:47 ` Sascha Hauer
0 siblings, 1 reply; 3+ messages in thread
From: Lucas Stach @ 2020-06-18 12:21 UTC (permalink / raw)
To: Sascha Hauer, Barebox List
Am Donnerstag, den 18.06.2020, 14:12 +0200 schrieb Sascha Hauer:
> Disabling the L2 cache is not working in imx5_init_lowlevel() because
> the necessary cache maintenance operations are missing. This often
> results in cache corruption in a chainloaded barebox.
> Disabling the cache is unnecessary: when we come from the ROM the L2
> cache is disabled anyway, so disabling it is a no-op. When we get here
> in a chainloaded barebox the L2 cache is already enabled and correctly
> configured. So instead of initializing it again we can take an enabled
> L2 cache as a sign to skip initialization and just return from the
> function.
While this won't hurt much, shouldn't we also disable the L2 cache on
Barebox shutdown, like we do on other SoCs?
Regards,
Lucas
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> arch/arm/mach-imx/imx5.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-imx/imx5.c b/arch/arm/mach-imx/imx5.c
> index 96288f99e0..dd6c079fe3 100644
> --- a/arch/arm/mach-imx/imx5.c
> +++ b/arch/arm/mach-imx/imx5.c
> @@ -37,10 +37,13 @@ void imx5_init_lowlevel(void)
> {
> u32 r;
>
> - /* ARM errata ID #468414 */
> __asm__ __volatile__("mrc 15, 0, %0, c1, c0, 1":"=r"(r));
> +
> + if (r & (1 << 1))
> + return;
> +
> + /* ARM errata ID #468414 */
> r |= (1 << 5); /* enable L1NEON bit */
> - r &= ~(1 << 1); /* explicitly disable L2 cache */
> __asm__ __volatile__("mcr 15, 0, %0, c1, c0, 1" : : "r"(r));
>
> /* reconfigure L2 cache aux control reg */
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Arm: i.MX5: Do not disable L2 cache
2020-06-18 12:21 ` Lucas Stach
@ 2020-06-26 4:47 ` Sascha Hauer
0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2020-06-26 4:47 UTC (permalink / raw)
To: Lucas Stach; +Cc: Barebox List
On Thu, Jun 18, 2020 at 02:21:08PM +0200, Lucas Stach wrote:
> Am Donnerstag, den 18.06.2020, 14:12 +0200 schrieb Sascha Hauer:
> > Disabling the L2 cache is not working in imx5_init_lowlevel() because
> > the necessary cache maintenance operations are missing. This often
> > results in cache corruption in a chainloaded barebox.
> > Disabling the cache is unnecessary: when we come from the ROM the L2
> > cache is disabled anyway, so disabling it is a no-op. When we get here
> > in a chainloaded barebox the L2 cache is already enabled and correctly
> > configured. So instead of initializing it again we can take an enabled
> > L2 cache as a sign to skip initialization and just return from the
> > function.
>
> While this won't hurt much, shouldn't we also disable the L2 cache on
> Barebox shutdown, like we do on other SoCs?
Documentation/arm/booting.rst clearly states:
Data cache must be off.
So yes, to do it correctly we should disable the L2 cache.
So far I am happy that my QSB board no longer randomly crashes in a
secondary barebox.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-26 4:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 12:12 [PATCH] Arm: i.MX5: Do not disable L2 cache Sascha Hauer
2020-06-18 12:21 ` Lucas Stach
2020-06-26 4:47 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox