All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled
@ 2022-09-14 11:37 Pali Rohár
  2022-09-16 16:02 ` Marek Behún
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pali Rohár @ 2022-09-14 11:37 UTC (permalink / raw)
  To: Stefan Roese, Mark Kettenis, Andre Przywara, Marek Behún; +Cc: u-boot

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled
  2022-09-14 11:37 [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled Pali Rohár
@ 2022-09-16 16:02 ` Marek Behún
  2022-09-19  7:01 ` Stefan Roese
  2022-10-07 15:47 ` Tom Rini
  2 siblings, 0 replies; 4+ messages in thread
From: Marek Behún @ 2022-09-16 16:02 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Stefan Roese, Mark Kettenis, Andre Przywara, u-boot

On Wed, 14 Sep 2022 13:37:46 +0200
Pali Rohár <pali@kernel.org> wrote:

> 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>

Reviewed-by: Marek Behún <kabel@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled
  2022-09-14 11:37 [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled Pali Rohár
  2022-09-16 16:02 ` Marek Behún
@ 2022-09-19  7:01 ` Stefan Roese
  2022-10-07 15:47 ` Tom Rini
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2022-09-19  7:01 UTC (permalink / raw)
  To: Pali Rohár, Mark Kettenis, Andre Przywara, Marek Behún; +Cc: u-boot

On 14.09.22 13:37, Pali Rohár wrote:
> 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>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   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);
>   }
>   

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled
  2022-09-14 11:37 [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled Pali Rohár
  2022-09-16 16:02 ` Marek Behún
  2022-09-19  7:01 ` Stefan Roese
@ 2022-10-07 15:47 ` Tom Rini
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2022-10-07 15:47 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Stefan Roese, Mark Kettenis, Andre Przywara, Marek Behún, u-boot

[-- Attachment #1: Type: text/plain, Size: 849 bytes --]

On Wed, Sep 14, 2022 at 01:37:46PM +0200, Pali Rohár wrote:

> 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>
> Reviewed-by: Marek Behún <kabel@kernel.org>
> Reviewed-by: Stefan Roese <sr@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-07 15:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 11:37 [PATCH] armv8: cache_v8: Fix pgtables setup when MMU is already enabled Pali Rohár
2022-09-16 16:02 ` Marek Behún
2022-09-19  7:01 ` Stefan Roese
2022-10-07 15:47 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.