public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Stefan Roese" <sr@denx.de>,
	"Mark Kettenis" <kettenis@openbsd.org>,
	"Andre Przywara" <andre.przywara@arm.com>,
	"Marek Behún" <kabel@kernel.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled
Date: Wed, 14 Sep 2022 13:37:46 +0200	[thread overview]
Message-ID: <20220914113746.16701-1-pali@kernel.org> (raw)

When MMU is already enabled then dcache_enable() does not call mmu_setup()
and so setup_all_pgtables() is also never called.

In this situation when some driver calls mmu_set_region_dcache_behaviour()
function then U-Boot crashes with error message:

    Emergency page table not setup.

Fix this issue by explicitly calling setup_all_pgtables() in dcache_enable()
function near condition for mmu_setup().

This change fixes chainloading U-Boot from U-Boot on Turris Mox board which
uses mvneta ethernet driver which calls mmu_set_region_dcache_behaviour().

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 arch/arm/cpu/armv8/cache_v8.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index e4736e564366..2a226fd0633d 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -503,6 +503,10 @@ void dcache_enable(void)
 		mmu_setup();
 	}
 
+	/* Set up page tables only once (it is done also by mmu_setup()) */
+	if (!gd->arch.tlb_fillptr)
+		setup_all_pgtables();
+
 	set_sctlr(get_sctlr() | CR_C);
 }
 
-- 
2.20.1


             reply	other threads:[~2022-09-14 11:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 11:37 Pali Rohár [this message]
2022-09-16 16:02 ` [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled Marek Behún
2022-09-19  7:01 ` Stefan Roese
2022-10-07 15:47 ` Tom Rini

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=20220914113746.16701-1-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=andre.przywara@arm.com \
    --cc=kabel@kernel.org \
    --cc=kettenis@openbsd.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