Skip to contentSkip to conversation

arm: mvebu: AC5/AC5X: use fixed page table size

PATCH In review Chris Packham 3 participants 6 messages Oct 18, 2023 – Oct 21, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mvebu: AC5/AC5X: use fixed page table size

Since commit 6cdf6b7a340d ("arm64: Use FEAT_HAFDBS to track dirty pages when available") the default get_page_table_size() sets some flags for more efficient handling of dirty page table entries. This causes problems on the AC5/AC5X SoC (specifically a lockup when calling __asm_switch_ttbr() via mmu_set_region_dcache_behaviour()).

The reason for the lockup isn't at all clear but it can be avoided if we provide our own get_page_table_size() which stops gd->arch.has_hafdbs from being set to true effectively returning the AC5/AC5X to the older behaviour. This also opts for a simple fixed page table size rather than trying to duplicate the more complicated logic to optimise the table size.

---

 arch/arm/mach-mvebu/alleycat5/cpu.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/mach-mvebu/alleycat5/cpu.c +5 -0
index 8204d9627515..7ba57ae75e76 100644
@@ -63,6 +63,11 @@ static struct mm_region ac5_mem_map[] = {
 
 struct mm_region *mem_map = ac5_mem_map;
 
+u64 get_page_table_size(void)
+{
+	return 0x80000;
+}
+
 void reset_cpu(void)
 {
 }
Signature · 1 line
2.42.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Chris,

Quoted 6 lines · Chris Packham

Since commit 6cdf6b7a340d ("arm64: Use FEAT_HAFDBS to track dirty pages when available") the default get_page_table_size() sets some flags for more efficient handling of dirty page table entries. This causes problems on the AC5/AC5X SoC (specifically a lockup when calling __asm_switch_ttbr() via mmu_set_region_dcache_behaviour()).

Quoted 8 lines

The reason for the lockup isn't at all clear but it can be avoided if we provide our own get_page_table_size() which stops gd->arch.has_hafdbs from being set to true effectively returning the AC5/AC5X to the older behaviour. This also opts for a simple fixed page table size rather than trying to duplicate the more complicated logic to optimise the table size.

I'm not 100% happy with this approach / workaround - still it fixes an issue on your board, so:

Perhaps you (or someone else) can look into this in more depth to get to the root of this issue at a later time.

Thanks,
Stefan

Quoted 11 lines

---

  arch/arm/mach-mvebu/alleycat5/cpu.c | 5 +++++
  1 file changed, 5 insertions(+)
arch/arm/mach-mvebu/alleycat5/cpu.c +0 -0
index 8204d9627515..7ba57ae75e76 100644
@@ -63,6 +63,11 @@ static struct mm_region ac5_mem_map[] = {
 

arch/arm/mach-mvebu/alleycat5/cpu.c static struct mm_region ac5_mem_map[] = { · line 73

Quoted 10 lines
arch/arm/mach-mvebu/alleycat5/cpu.c +5 -0
  struct mm_region *mem_map = ac5_mem_map;
 
+u64 get_page_table_size(void)
+{
+	return 0x80000;
+}
+
  void reset_cpu(void)
  {
  }

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#2 lore raw
Quoted 16 lines · Stefan Roese,

Hi Chris,

Quoted 13 lines · Chris Packham

Since commit 6cdf6b7a340d ("arm64: Use FEAT_HAFDBS to track dirty pages when available") the default get_page_table_size() sets some flags for more efficient handling of dirty page table entries. This causes problems on the AC5/AC5X SoC (specifically a lockup when calling __asm_switch_ttbr() via mmu_set_region_dcache_behaviour()).

The reason for the lockup isn't at all clear but it can be avoided if we provide our own get_page_table_size() which stops gd->arch.has_hafdbs from being set to true effectively returning the AC5/AC5X to the older behaviour. This also opts for a simple fixed page table size rather than trying to duplicate the more complicated logic to optimise the table size.

Quoted 7 lines
Quoted 1 line

I'm not 100% happy with this approach / workaround - still it fixes an issue on your board, so:

Yeah I'm not super happy about this either. But this is about the best I could come up with.

Quoted 3 lines

Perhaps you (or someone else) can look into this in more depth to get to the root of this issue at a later time.

I did spend a reasonable amount of time tracking down where things were going wrong, even if I couldn't figure out why. The commit message basically reflects what I found.

Quoted 34 lines

Thanks,
Stefan

Review

Quoted 6 lines

---

  arch/arm/mach-mvebu/alleycat5/cpu.c | 5 +++++
  1 file changed, 5 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-mvebu/alleycat5/cpu.c

Quoted 5 lines

index 8204d9627515..7ba57ae75e76 100644

arch/arm/mach-mvebu/alleycat5/cpu.c +0 -0
@@ -63,6 +63,11 @@ static struct mm_region ac5_mem_map[] = {
 

arch/arm/mach-mvebu/alleycat5/cpu.c static struct mm_region ac5_mem_map[] = { · line 73

Quoted 10 lines
arch/arm/mach-mvebu/alleycat5/cpu.c +5 -0
  struct mm_region *mem_map = ac5_mem_map;
 
+u64 get_page_table_size(void)
+{
+     return 0x80000;
+}
+
  void reset_cpu(void)
  {
  }

Viele Grüße,
Stefan Roese

--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]

#3 lore raw
Quoted 34 lines · Chris Packham

On Fri, 20 Oct 2023, 7:18 pm Stefan Roese, <[email protected] <mailto:[email protected]>> wrote:

Hi Chris,

On 10/18/23 22:53, Chris Packham wrote:
> Since commit 6cdf6b7a340d ("arm64: Use FEAT_HAFDBS to track dirty
pages
> when available") the default get_page_table_size() sets some
flags for
> more efficient handling of dirty page table entries. This causes > problems on the AC5/AC5X SoC (specifically a lockup when calling > __asm_switch_ttbr() via mmu_set_region_dcache_behaviour()). >
> The reason for the lockup isn't at all clear but it can be
avoided if we
> provide our own get_page_table_size() which stops gd->arch.has_hafdbs > from being set to true effectively returning the AC5/AC5X to the
older
> behaviour. This also opts for a simple fixed page table size
rather than
> trying to duplicate the more complicated logic to optimise the table > size.
>
> Signed-off-by: Chris Packham <[email protected]
<mailto:[email protected]>>

I'm not 100% happy with this approach / workaround - still it fixes an issue on your board, so:

Reviewed-by Stefan Roese <[email protected] <mailto:[email protected]>>
Quoted 8 lines

Yeah I'm not super happy about this either. But this is about the best I could come up with.

Perhaps you (or someone else) can look into this in more depth to get to the root of this issue at a later time.

I did spend a reasonable amount of time tracking down where things were going wrong, even if I couldn't figure out why. The commit message basically reflects what I found.

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 28 lines

    Thanks,
    Stefan

     > ---
     >
     >   arch/arm/mach-mvebu/alleycat5/cpu.c | 5 +++++
     >   1 file changed, 5 insertions(+)
     >
     > diff --git a/arch/arm/mach-mvebu/alleycat5/cpu.c
    b/arch/arm/mach-mvebu/alleycat5/cpu.c
     > index 8204d9627515..7ba57ae75e76 100644
     > --- a/arch/arm/mach-mvebu/alleycat5/cpu.c
     > +++ b/arch/arm/mach-mvebu/alleycat5/cpu.c
     > @@ -63,6 +63,11 @@ static struct mm_region ac5_mem_map[] = {
     >
     >   struct mm_region *mem_map = ac5_mem_map;
     >
     > +u64 get_page_table_size(void)
     > +{
     > +     return 0x80000;
     > +}
     > +
     >   void reset_cpu(void)
     >   {
     >   }
Quoted 9 lines
    Viele Grüße,
    Stefan Roese

    -- 
    DENX Software Engineering GmbH,      Managing Director: Erika Unter
    HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
    Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email:
    [email protected] <mailto:[email protected]>

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#4 lore raw
In reply to Chris Packham
Quoted 26 lines · Chris Packham

Since commit 6cdf6b7a340d ("arm64: Use FEAT_HAFDBS to track dirty pages when available") the default get_page_table_size() sets some flags for more efficient handling of dirty page table entries. This causes problems on the AC5/AC5X SoC (specifically a lockup when calling __asm_switch_ttbr() via mmu_set_region_dcache_behaviour()).

The reason for the lockup isn't at all clear but it can be avoided if we provide our own get_page_table_size() which stops gd->arch.has_hafdbs from being set to true effectively returning the AC5/AC5X to the older behaviour. This also opts for a simple fixed page table size rather than trying to duplicate the more complicated logic to optimise the table size.

---

 arch/arm/mach-mvebu/alleycat5/cpu.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/mach-mvebu/alleycat5/cpu.c +0 -0
index 8204d9627515..7ba57ae75e76 100644
@@ -63,6 +63,11 @@ static struct mm_region ac5_mem_map[] = {
 

arch/arm/mach-mvebu/alleycat5/cpu.c static struct mm_region ac5_mem_map[] = { · line 73

Quoted 10 lines
arch/arm/mach-mvebu/alleycat5/cpu.c +5 -0
 struct mm_region *mem_map = ac5_mem_map;
 
+u64 get_page_table_size(void)
+{
+	return 0x80000;
+}
+
 void reset_cpu(void)
 {
 }

This looks terribly wrong. In all honesty, if the original patch creates problems and that people add this sort of stuff to paper over it, I'd rather your *revert* my patch altogether.

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#5 lore raw
Quoted 31 lines · Marc Zyngier,
Quoted 30 lines · Chris Packham

Since commit 6cdf6b7a340d ("arm64: Use FEAT_HAFDBS to track dirty pages when available") the default get_page_table_size() sets some flags for more efficient handling of dirty page table entries. This causes problems on the AC5/AC5X SoC (specifically a lockup when calling __asm_switch_ttbr() via mmu_set_region_dcache_behaviour()).

The reason for the lockup isn't at all clear but it can be avoided if we
provide our own get_page_table_size() which stops gd->arch.has_hafdbs from being set to true effectively returning the AC5/AC5X to the older behaviour. This also opts for a simple fixed page table size rather than
trying to duplicate the more complicated logic to optimise the table size.

---

 arch/arm/mach-mvebu/alleycat5/cpu.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/mach-mvebu/alleycat5/cpu.c +0 -0
index 8204d9627515..7ba57ae75e76 100644
@@ -63,6 +63,11 @@ static struct mm_region ac5_mem_map[] = {
 
 struct mm_region *mem_map = ac5_mem_map;
 
Quoted 13 lines

arch/arm/mach-mvebu/alleycat5/cpu.c static struct mm_region ac5_mem_map[] = { · line 73

Quoted 8 lines
arch/arm/mach-mvebu/alleycat5/cpu.c +5 -0
+u64 get_page_table_size(void)
+{
+     return 0x80000;
+}
+
 void reset_cpu(void)
 {
 }

This looks terribly wrong. In all honesty, if the original patch creates problems and that people add this sort of stuff to paper over it, I'd rather your *revert* my patch altogether.

There are other platforms that define a get_page_table_size(). That may mean that they are just inadvertently avoiding the issues I'm seeing.

I'm happy to prepare a series reverting the problematic changes. But I'm sure that there's something about the AC5 that's the actual problem. I'm just out of my depth in terms of my ability to progress it.

Quoted 4 lines
         M.

--
Jazz is not dead. It just smells funny...