public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: pali@kernel.org, "U-Boot Mailing List" <u-boot@lists.denx.de>,
	"Marek Behún" <kabel@kernel.org>
Subject: [PATCH u-boot-marvell 4/5] arm: mvebu: Enable L2 cache also on Armada 38x
Date: Thu,  8 Sep 2022 16:06:53 +0200	[thread overview]
Message-ID: <20220908140654.7051-5-kabel@kernel.org> (raw)
In-Reply-To: <20220908140654.7051-1-kabel@kernel.org>

From: Pali Rohár <pali@kernel.org>

For some unknown reason when L2 cache is disabled on Armada 385 then loadb,
loadx and loady commands do not work with higher baudrates than 115200
(they just abort transfer) and lzmadec command with lzma image of size
0x7000000 (maybe even smaller, we tested this one) is doing decompression
for more than 2 minutes. After enabling L2 cache decompression takes only
30s and loadb, loadx and loady are stable and working fine.

git bisect identified problematic commit 3308933d2fe9 ("arm: mvebu: Avoid
reading MVEBU_REG_PCIE_DEVID register too many times"). Before this commit
above issues were not present.

But investigation showed that above issue was possible to reproduce also by
reverting that commit and forcing compiler to do inline optimization of
mvebu_soc_family() function. Which seems that the root of this issue is in
caches and position of instruction of segments. So currently it is unknown
what is or was broken, but code movement, code inlining or other compiler
optimization triggered it.

Commit 3e5ce7ceeb94 ("arm: mvebu: Enable L2 cache on Armada XP") mentioned
that enabling L2 cache on Armada XP improved performance and that Armada
38x has L2 disabled (which is default state) and if needed it has to be
enabled in separate patch. As enabling L2 cache also improve performance
on Armada 38x, enable it.

Note that Aurora cache in no outer mode is available only on Armada XP,
hence it is not touched for Armada 38x code.

Fixes: 3308933d2fe9 ("arm: mvebu: Avoid reading MVEBU_REG_PCIE_DEVID register too many times")
Reported-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
---
 arch/arm/mach-mvebu/cpu.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c
index 8e5d1ba21e..d410b87171 100644
--- a/arch/arm/mach-mvebu/cpu.c
+++ b/arch/arm/mach-mvebu/cpu.c
@@ -671,13 +671,21 @@ void enable_caches(void)
 
 void v7_outer_cache_enable(void)
 {
+	struct pl310_regs *const pl310 =
+		(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
+
+	/* The L2 cache is already disabled at this point */
+
+	/*
+	 * For now L2 cache will be enabled only for Armada XP and Armada 38x.
+	 * It can be enabled also for other SoCs after testing that it works fine.
+	 */
+	if (!IS_ENABLED(CONFIG_ARMADA_XP) && !IS_ENABLED(CONFIG_ARMADA_38X))
+		return;
+
 	if (IS_ENABLED(CONFIG_ARMADA_XP)) {
-		struct pl310_regs *const pl310 =
-			(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
 		u32 u;
 
-		/* The L2 cache is already disabled at this point */
-
 		/*
 		 * For Aurora cache in no outer mode, enable via the CP15
 		 * coprocessor broadcasting of cache commands to L2.
@@ -687,10 +695,10 @@ void v7_outer_cache_enable(void)
 		asm volatile("mcr p15, 1, %0, c15, c2, 0" : : "r" (u));
 
 		isb();
-
-		/* Enable the L2 cache */
-		setbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
 	}
+
+	/* Enable the L2 cache */
+	setbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
 }
 
 void v7_outer_cache_disable(void)
-- 
2.35.1


  parent reply	other threads:[~2022-09-08 14:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 14:06 [PATCH u-boot-marvell 0/5] mvebu important fixes Marek Behún
2022-09-08 14:06 ` [PATCH u-boot-marvell 1/5] arm: mvebu: Fix function enable_caches Marek Behún
2022-09-12  6:57   ` Stefan Roese
2022-09-08 14:06 ` [PATCH u-boot-marvell 2/5] arm: mvebu: Guard non-AXP code by checking for AXP Marek Behún
2022-09-12  6:58   ` Stefan Roese
2022-09-08 14:06 ` [PATCH u-boot-marvell 3/5] arm: mvebu: lowlevel.S: Use CR_M from asm/system.h Marek Behún
2022-09-12  6:58   ` Stefan Roese
2022-09-08 14:06 ` Marek Behún [this message]
2022-09-12  6:58   ` [PATCH u-boot-marvell 4/5] arm: mvebu: Enable L2 cache also on Armada 38x Stefan Roese
2022-09-08 14:06 ` [PATCH u-boot-marvell 5/5] arm: mvebu: Fix moving internal registers Marek Behún
2022-09-12  6:59   ` Stefan Roese
2022-09-12  7:04 ` [PATCH u-boot-marvell 0/5] mvebu important fixes Stefan Roese

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=20220908140654.7051-5-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=pali@kernel.org \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.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