Skip to contentSkip to conversation

ARM: PJ4B: fixes for 3.10-rc

PATCH Superseded Gregory CLEMENT 5 participants 18 messages May 29, 2013 – Jun 6, 2013 Arm (32-bit)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover ARM: PJ4B: fixes for 3.10-rc

Hello,

This path set allows to fix some errata for PJ4B CPus.

Without the first one, the Armada 370 based board can't boot anymore since 3.10-rc1 and the commit "ARM: 7691/1: mm: kill unused TLB_CAN_READ_FROM_L1_CACHE and use ALT_SMP instead" . So this one really need to be appplied on 3.10-rc.

It should be a good thing to apply the others on the 3.10-rc, even we didn't observe yet a problem related to these errata, they may happen.

Note that currently PJ4B is a symbol for 2 different CPU:

- the one used in Armada 370 is a PJ4B
- the ones used in Armada XP are actually PJ4B-MP

So I planed to introduce a new symbol PJ4B-MP but for 3.11 as it is not related to a critical fix. Awaiting this new symbol I made the errata depends on ARMADA_370 or ARMADA_XP in the Kconfig.

I will resent this series once Russell will come back next week, but I would like to have a first feedback on this series.

Thanks,

Lior Amsalem (3):
ARM PJ4B: Add support for errata 4742
ARM PJ4B: Add support for errata 6124
ARM PJ4B: Add support for errata 4611

 arch/arm/Kconfig                | 36 ++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/tlbflush.h | 30 ++++++++++++++++++++++++++++++
 arch/arm/mm/cache-v7.S          |  8 ++++++++
 arch/arm/mm/copypage-v6.c       | 11 +++++++++++
 arch/arm/mm/proc-macros.S       | 13 +++++++++++++
 arch/arm/mm/proc-v7-2level.S    |  4 ++++
 arch/arm/mm/proc-v7-3level.S    |  4 ++++
 arch/arm/mm/proc-v7.S           |  7 +++++++
 8 files changed, 113 insertions(+)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/3 ARM PJ4B: Add support for errata 4742

From: Lior Amsalem <[email protected]>

This commit fix the regression on Armada 370 (the kernal hang during boot) introduced by the commit: "ARM: 7691/1: mm: kill unused TLB_CAN_READ_FROM_L1_CACHE and use ALT_SMP instead".

When coming out of either a Wait for Interrupt (WFI) or a Wait for Event (WFE) IDLE states, a specific timing sensitivity exists between the retiring WFI/WFE instructions and the newly issued subsequent instructions. This sensitivity can result in a CPU hang scenario. The workaround is to insert either a Data Synchronization Barrier (DSB) or Data Memory Barrier (DMB) command immediately after the WFI/WFE instruction

[gregory.clement at free-electrons.com:add errata description in changelog] [gregory.clement at free-electrons.com:make this errata depend on Aramda 370]

---
 arch/arm/Kconfig      | 12 ++++++++++++
 arch/arm/mm/proc-v7.S |  3 +++
 2 files changed, 15 insertions(+)
arch/arm/Kconfig +12 -0
index 49d993c..745781f 100644
@@ -1087,6 +1087,18 @@ if !MMU
 source "arch/arm/Kconfig-nommu"
 endif
 
+config PJ4B_ERRATA_4742
+        bool "PJ4B Errata 4742: IDLE Wake Up Commands can Cause the CPU Core to Cease Operation"
+        depends on CPU_PJ4B && MACH_ARMADA_370
+        help
+          When coming out of either a Wait for Interrupt (WFI) or a Wait for Event
+	  (WFE) IDLE states, a specific timing sensitivity exists between the retiring
+	  WFI/WFE instructions and the newly issued subsequent instructions.
+	  This sensitivity can result in a CPU hang scenario.
+          Workaround:
+	  The software must insert either a Data Synchronization Barrier (DSB)
+	  or Data Memory Barrier (DMB) command immediately after the WFI/WFE instruction
+
 config ARM_ERRATA_326103
 	bool "ARM errata: FSR write bit incorrect on a SWP to read-only memory"
 	depends on CPU_V6
arch/arm/mm/proc-v7.S +3 -0
index 2c73a73..f872432 100644
@@ -71,6 +71,9 @@ ENDPROC(cpu_v7_reset)
 ENTRY(cpu_v7_do_idle)
 	dsb					@ WFI may enter a low-power mode
 	wfi
+#ifdef CONFIG_PJ4B_ERRATA_4742
+        mcr     p15, 0, r0, c7, c10, 4          @barrier
+#endif
 	mov	pc, lr
 ENDPROC(cpu_v7_do_idle)
 
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH 1/3 ARM PJ4B: Add support for errata 4742

Hi Gregory,

Quoted 6 lines · Gregory CLEMENT

From: Lior Amsalem <[email protected]>

This commit fix the regression on Armada 370 (the kernal hang during boot) introduced by the commit: "ARM: 7691/1: mm: kill unused TLB_CAN_READ_FROM_L1_CACHE and use ALT_SMP instead".

Quoted 7 lines

When coming out of either a Wait for Interrupt (WFI) or a Wait for Event (WFE) IDLE states, a specific timing sensitivity exists between the retiring WFI/WFE instructions and the newly issued subsequent instructions. This sensitivity can result in a CPU hang scenario. The workaround is to insert either a Data Synchronization Barrier (DSB) or Data Memory Barrier (DMB) command immediately after the WFI/WFE instruction

Thanks for chasing this up! I have no idea why the patch you mentioned triggered this though.

arch/arm/mm/proc-v7.S ENDPROC(cpu_v7_reset) · line 76

Quoted 11 lines
arch/arm/mm/proc-v7.S +3 -0
index 2c73a73..f872432 100644
@@ -71,6 +71,9 @@ ENDPROC(cpu_v7_reset)
 ENTRY(cpu_v7_do_idle)
 	dsb					@ WFI may enter a low-power mode
 	wfi
+#ifdef CONFIG_PJ4B_ERRATA_4742
+        mcr     p15, 0, r0, c7, c10, 4          @barrier
+#endif

Is the cp15 encoding required here, or can you just use `dsb'?

Will

#3 lore raw

PATCH 1/3 ARM PJ4B: Add support for errata 4742

Hi Will,

Quoted 31 lines

From: Will Deacon [mailto:will.deacon at arm.com]
Sent: Wednesday, May 29, 2013 2:04 PM

Hi Gregory,

Quoted 6 lines · Gregory CLEMENT

From: Lior Amsalem <[email protected]>

This commit fix the regression on Armada 370 (the kernal hang during boot) introduced by the commit: "ARM: 7691/1: mm: kill unused TLB_CAN_READ_FROM_L1_CACHE and use ALT_SMP instead".

Quoted 7 lines

When coming out of either a Wait for Interrupt (WFI) or a Wait for Event (WFE) IDLE states, a specific timing sensitivity exists between the retiring WFI/WFE instructions and the newly issued subsequent instructions. This sensitivity can result in a CPU hang scenario. The workaround is to insert either a Data Synchronization Barrier (DSB) or Data Memory Barrier (DMB) command immediately after the WFI/WFE instruction

Thanks for chasing this up! I have no idea why the patch you mentioned triggered this though.

arch/arm/mm/proc-v7.S ENDPROC(cpu_v7_reset) · line 72

Quoted 7 lines
arch/arm/mm/proc-v7.S index renamed from arch/arm/mm/proc-v7.S +0 -0

2c73a73..f872432 100644

arch/arm/mm/proc-v7.S +0 -0
@@ -71,6 +71,9 @@ ENDPROC(cpu_v7_reset)
 ENTRY(cpu_v7_do_idle)
 	dsb					@ WFI may enter a low-

power mode

Quoted 6 lines

arch/arm/mm/proc-v7.S ENDPROC(cpu_v7_reset) · line 76

Quoted 4 lines
arch/arm/mm/proc-v7.S +3 -0
 	wfi
+#ifdef CONFIG_PJ4B_ERRATA_4742
+        mcr     p15, 0, r0, c7, c10, 4          @barrier
+#endif

Is the cp15 encoding required here, or can you just use `dsb'?

A DSB will also do the job here, we'll change that.
Anyway, this CP15 command is with-in the arch commands as well (not Marvell specific).

BTW, thanks for all the comments, I'll refer them all.

Quoted 2 lines

Will

Regards,
Lior Amsalem

#4 lore raw

PATCH 2/3 ARM PJ4B: Add support for errata 6124

In reply to Gregory CLEMENT

From: Lior Amsalem <[email protected]>

A rare timing scenario exists where a clean operation occurs, followed by an additional store operation. If a matching snoop also occurs, it is possible for the write-back from the original clean operation and the intervention from the snoop to race, which could result in data corruption.
Replacing all clean cache maintenance operations with Clean & Invalidate operation to avoid the issue

[gregory.clement at free-electrons.com:add errata description in changelog] [gregory.clement at free-electrons.com: make this errata depend on Aramda XP]

---
 arch/arm/Kconfig                | 13 +++++++++++++
 arch/arm/include/asm/tlbflush.h |  8 ++++++++
 arch/arm/mm/cache-v7.S          |  8 ++++++++
 arch/arm/mm/proc-v7-2level.S    |  4 ++++
 arch/arm/mm/proc-v7-3level.S    |  4 ++++
 arch/arm/mm/proc-v7.S           |  4 ++++
 6 files changed, 41 insertions(+)
arch/arm/Kconfig +13 -0
index 745781f..48cdbea 100644
@@ -1099,6 +1099,19 @@ config PJ4B_ERRATA_4742
 	  The software must insert either a Data Synchronization Barrier (DSB)
 	  or Data Memory Barrier (DMB) command immediately after the WFI/WFE instruction
 
+config PJ4B_ERRATA_6124
+        bool "PJ4B Errata 6124: Multiple writebacks can be issued in a rare timing scenario associated with a clean operation and an incoming snoop"
+        depends on CPU_PJ4B && MACH_ARMADA_XP
+        help
+	  A rare timing scenario exists where a clean operation occurs, followed
+	  by an additional store operation. If a matching snoop also occurs, it
+	  is possible for the write-back from the original clean operation and
+	  the intervention from the snoop to race, which could result in data
+	  corruption.
+	  Workaround:
+	  Replacing all clean cache maintenance operations with
+	  Clean & Invalidate operation will avoid the issue
+
 config ARM_ERRATA_326103
 	bool "ARM errata: FSR write bit incorrect on a SWP to read-only memory"
 	depends on CPU_V6
arch/arm/include/asm/tlbflush.h +8 -0
index a3625d1..e3a8064 100644
@@ -475,7 +475,11 @@ static inline void flush_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
+#else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
+#endif
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 
 	if (tlb_flag(TLB_WB))
@@ -486,7 +490,11 @@ static inline void clean_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
+#else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
+#endif
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 }
 
arch/arm/mm/cache-v7.S +8 -0
index 15451ee..d353649 100644
@@ -270,7 +270,11 @@ ENTRY(v7_coherent_user_range)
 	ALT_UP(W(nop))
 #endif
 1:
+#ifdef CONFIG_PJ4B_ERRATA_6124
+ USER(	mcr	p15, 0, r12, c7, c14, 1	)	@ clean & invalidate D line to the point of unification
+#else
  USER(	mcr	p15, 0, r12, c7, c11, 1	)	@ clean D line to the point of unification
+#endif
 	add	r12, r12, r2
 	cmp	r12, r1
 	blo	1b
@@ -378,7 +382,11 @@ v7_dma_clean_range:
 	ALT_UP(W(nop))
 #endif
 1:
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	mcr	p15, 0, r0, c7, c14, 1		@ clean & invalidate D line to the point of unification
+#else
 	mcr	p15, 0, r0, c7, c10, 1		@ clean D / U line
+#endif
 	add	r0, r0, r2
 	cmp	r0, r1
 	blo	1b
arch/arm/mm/proc-v7-2level.S +4 -0
index 9704097..0999fd3 100644
@@ -111,8 +111,12 @@ ENTRY(cpu_v7_set_pte_ext)
  THUMB(	add	r0, r0, #2048 )
  THUMB(	str	r3, [r0] )
 	ALT_SMP(mov	pc,lr)
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	ALT_UP (mcr	p15, 0, r0, c7, c14, 1)		@ flush_pte by clean & invalidate D entry
+#else
 	ALT_UP (mcr	p15, 0, r0, c7, c10, 1)		@ flush_pte
 #endif
+#endif
 	mov	pc, lr
 ENDPROC(cpu_v7_set_pte_ext)
 
arch/arm/mm/proc-v7-3level.S +4 -0
index 363027e..7a917ff 100644
@@ -74,8 +74,12 @@ ENTRY(cpu_v7_set_pte_ext)
 	orreq	r2, #L_PTE_RDONLY
 1:	strd	r2, r3, [r0]
 	ALT_SMP(mov	pc, lr)
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	ALT_UP (mcr	p15, 0, r0, c7, c14, 1)		@ flush_pte by clean & invalidate D entry
+#else
 	ALT_UP (mcr	p15, 0, r0, c7, c10, 1)		@ flush_pte
 #endif
+#endif
 	mov	pc, lr
 ENDPROC(cpu_v7_set_pte_ext)
 
arch/arm/mm/proc-v7.S +4 -0
index f872432..b86d688 100644
@@ -81,7 +81,11 @@ ENTRY(cpu_v7_dcache_clean_area)
 	ALT_SMP(mov	pc, lr)			@ MP extensions imply L1 PTW
 	ALT_UP(W(nop))
 	dcache_line_size r2, r3
+#ifdef CONFIG_PJ4B_ERRATA_6124
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean & invalidate D entry
+#else
 1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+#endif
 	add	r0, r0, r2
 	subs	r1, r1, r2
 	bhi	1b
Signature · 1 line
1.8.1.2
#5 lore raw

PATCH 2/3 ARM PJ4B: Add support for errata 6124

Quoted 9 lines · Gregory CLEMENT

From: Lior Amsalem <[email protected]>

A rare timing scenario exists where a clean operation occurs, followed by an additional store operation. If a matching snoop also occurs, it is possible for the write-back from the original clean operation and the intervention from the snoop to race, which could result in data corruption.
Replacing all clean cache maintenance operations with Clean & Invalidate operation to avoid the issue

Curious: do you not have a chicken bit for this? Upgrading clean to clean & invalidate is a pretty common thing to do and is even architected with the virtualisation extensions.

Quoted 43 lines

[gregory.clement at free-electrons.com:add errata description in changelog] [gregory.clement at free-electrons.com: make this errata depend on Aramda XP]

---
 arch/arm/Kconfig                | 13 +++++++++++++
 arch/arm/include/asm/tlbflush.h |  8 ++++++++
 arch/arm/mm/cache-v7.S          |  8 ++++++++
 arch/arm/mm/proc-v7-2level.S    |  4 ++++
 arch/arm/mm/proc-v7-3level.S    |  4 ++++
 arch/arm/mm/proc-v7.S           |  4 ++++
 6 files changed, 41 insertions(+)
arch/arm/Kconfig +13 -0
index 745781f..48cdbea 100644
@@ -1099,6 +1099,19 @@ config PJ4B_ERRATA_4742
 	  The software must insert either a Data Synchronization Barrier (DSB)
 	  or Data Memory Barrier (DMB) command immediately after the WFI/WFE instruction
 
+config PJ4B_ERRATA_6124
+        bool "PJ4B Errata 6124: Multiple writebacks can be issued in a rare timing scenario associated with a clean operation and an incoming snoop"
+        depends on CPU_PJ4B && MACH_ARMADA_XP
+        help
+	  A rare timing scenario exists where a clean operation occurs, followed
+	  by an additional store operation. If a matching snoop also occurs, it
+	  is possible for the write-back from the original clean operation and
+	  the intervention from the snoop to race, which could result in data
+	  corruption.
+	  Workaround:
+	  Replacing all clean cache maintenance operations with
+	  Clean & Invalidate operation will avoid the issue
+
 config ARM_ERRATA_326103
 	bool "ARM errata: FSR write bit incorrect on a SWP to read-only memory"
 	depends on CPU_V6
arch/arm/include/asm/tlbflush.h +0 -0
index a3625d1..e3a8064 100644

arch/arm/include/asm/tlbflush.h static inline void flush_pmd_entry(void *pmd) · line 479

Quoted 5 lines
arch/arm/include/asm/tlbflush.h +2 -0
@@ -475,7 +475,11 @@ static inline void flush_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);

Can you elaborate on the comment please?

arch/arm/include/asm/tlbflush.h static inline void clean_pmd_entry(void *pmd) · line 494

Quoted 12 lines
arch/arm/include/asm/tlbflush.h +4 -0
+#else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
+#endif
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 
 	if (tlb_flag(TLB_WB))
@@ -486,7 +490,11 @@ static inline void clean_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);

and here.

Quoted 11 lines
arch/arm/include/asm/tlbflush.h +2 -0
+#else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
+#endif
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 }
 
arch/arm/mm/cache-v7.S +0 -0
index 15451ee..d353649 100644

arch/arm/mm/cache-v7.S ENTRY(v7_coherent_user_range) · line 274

Quoted 5 lines
arch/arm/mm/cache-v7.S +2 -0
@@ -270,7 +270,11 @@ ENTRY(v7_coherent_user_range)
 	ALT_UP(W(nop))
 #endif
 1:
+#ifdef CONFIG_PJ4B_ERRATA_6124
+ USER(	mcr	p15, 0, r12, c7, c14, 1	)	@ clean & invalidate D line to the point of unification

This flushes to the point of coherency (there is no PoU clean & inv).

arch/arm/mm/cache-v7.S v7_dma_clean_range: · line 386

Quoted 12 lines
arch/arm/mm/cache-v7.S +4 -0
+#else
  USER(	mcr	p15, 0, r12, c7, c11, 1	)	@ clean D line to the point of unification
+#endif
 	add	r12, r12, r2
 	cmp	r12, r1
 	blo	1b
@@ -378,7 +382,11 @@ v7_dma_clean_range:
 	ALT_UP(W(nop))
 #endif
 1:
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	mcr	p15, 0, r0, c7, c14, 1		@ clean & invalidate D line to the point of unification

Similarly, although I don't understand why you care about the erratum for dma_clean_range. There should be no pending stores to the buffer, otherwise you risk corruption anyway (from the device's point of view).

Quoted 11 lines
arch/arm/mm/cache-v7.S +2 -0
+#else
 	mcr	p15, 0, r0, c7, c10, 1		@ clean D / U line
+#endif
 	add	r0, r0, r2
 	cmp	r0, r1
 	blo	1b
arch/arm/mm/proc-v7-2level.S +0 -0
index 9704097..0999fd3 100644

arch/arm/mm/proc-v7-2level.S ENTRY(cpu_v7_set_pte_ext) · line 115

Quoted 5 lines
arch/arm/mm/proc-v7-2level.S +2 -0
@@ -111,8 +111,12 @@ ENTRY(cpu_v7_set_pte_ext)
  THUMB(	add	r0, r0, #2048 )
  THUMB(	str	r3, [r0] )
 	ALT_SMP(mov	pc,lr)
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	ALT_UP (mcr	p15, 0, r0, c7, c14, 1)		@ flush_pte by clean & invalidate D entry

The use of `by' is a bit confusing, since you can also do maintenance by set/way.

Quoted 29 lines
arch/arm/mm/proc-v7-2level.S +2 -0
+#else
 	ALT_UP (mcr	p15, 0, r0, c7, c10, 1)		@ flush_pte
 #endif
+#endif
 	mov	pc, lr
 ENDPROC(cpu_v7_set_pte_ext)
 
arch/arm/mm/proc-v7-3level.S +4 -0
index 363027e..7a917ff 100644
@@ -74,8 +74,12 @@ ENTRY(cpu_v7_set_pte_ext)
 	orreq	r2, #L_PTE_RDONLY
 1:	strd	r2, r3, [r0]
 	ALT_SMP(mov	pc, lr)
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	ALT_UP (mcr	p15, 0, r0, c7, c14, 1)		@ flush_pte by clean & invalidate D entry
+#else
 	ALT_UP (mcr	p15, 0, r0, c7, c10, 1)		@ flush_pte
 #endif
+#endif
 	mov	pc, lr
 ENDPROC(cpu_v7_set_pte_ext)
 
arch/arm/mm/proc-v7.S +0 -0
index f872432..b86d688 100644

arch/arm/mm/proc-v7.S ENTRY(cpu_v7_dcache_clean_area) · line 83

Quoted 3 lines
arch/arm/mm/proc-v7.S +0 -0
@@ -81,7 +81,11 @@ ENTRY(cpu_v7_dcache_clean_area)
 	ALT_SMP(mov	pc, lr)			@ MP extensions imply L1 PTW
 	ALT_UP(W(nop))
 	dcache_line_size r2, r3

You could move the 1: label here.

arch/arm/mm/proc-v7.S ENTRY(cpu_v7_dcache_clean_area) · line 88

Quoted 5 lines
arch/arm/mm/proc-v7.S +4 -0
+#ifdef CONFIG_PJ4B_ERRATA_6124
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean & invalidate D entry
+#else
 1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+#endif

Will

#6 lore raw

PATCH 2/3 ARM PJ4B: Add support for errata 6124

Quoted 14 lines

From: Will Deacon [mailto:will.deacon at arm.com]
Sent: Wednesday, May 29, 2013 2:17 PM

Quoted 9 lines · Gregory CLEMENT

From: Lior Amsalem <[email protected]>

A rare timing scenario exists where a clean operation occurs, followed by an additional store operation. If a matching snoop also occurs, it is possible for the write-back from the original clean operation and the intervention from the snoop to race, which could result in data corruption.
Replacing all clean cache maintenance operations with Clean & Invalidate operation to avoid the issue

Quoted 3 lines

Curious: do you not have a chicken bit for this? Upgrading clean to clean & invalidate is a pretty common thing to do and is even architected with the virtualisation extensions.

We don't have virtualization extension.
As for the chicken bit, I'm looking into that with the design team. I'll update on my findings.

Quoted 53 lines
Quoted 4 lines

[gregory.clement at free-electrons.com:add errata description in changelog]
[gregory.clement at free-electrons.com: make this errata depend on

Aramda

Quoted 17 lines

XP]

---
 arch/arm/Kconfig                | 13 +++++++++++++
 arch/arm/include/asm/tlbflush.h |  8 ++++++++
 arch/arm/mm/cache-v7.S          |  8 ++++++++
 arch/arm/mm/proc-v7-2level.S    |  4 ++++
 arch/arm/mm/proc-v7-3level.S    |  4 ++++
 arch/arm/mm/proc-v7.S           |  4 ++++
 6 files changed, 41 insertions(+)
arch/arm/Kconfig index renamed from arch/arm/Kconfig +0 -0

745781f..48cdbea 100644

arch/arm/Kconfig config PJ4B_ERRATA_4742 · line 1100

Quoted 2 lines
arch/arm/Kconfig +0 -0
@@ -1099,6 +1099,19 @@ config PJ4B_ERRATA_4742
 	  The software must insert either a Data Synchronization Barrier (DSB)
 	  or Data Memory Barrier (DMB) command immediately after the

WFI/WFE

arch/arm/Kconfig

Quoted 4 lines

instruction

arch/arm/Kconfig +2 -0
+config PJ4B_ERRATA_6124
+        bool "PJ4B Errata 6124: Multiple writebacks can be issued in a rare

timing scenario associated with a clean operation and an incoming snoop"

arch/arm/Kconfig config PJ4B_ERRATA_4742

Quoted 3 lines
arch/arm/Kconfig +3 -0
+        depends on CPU_PJ4B && MACH_ARMADA_XP
+        help
+	  A rare timing scenario exists where a clean operation occurs,

followed

arch/arm/Kconfig config PJ4B_ERRATA_4742

Quoted 10 lines
arch/arm/Kconfig +8 -0
+	  by an additional store operation. If a matching snoop also occurs, it
+	  is possible for the write-back from the original clean operation and
+	  the intervention from the snoop to race, which could result in data
+	  corruption.
+	  Workaround:
+	  Replacing all clean cache maintenance operations with
+	  Clean & Invalidate operation will avoid the issue
+
 config ARM_ERRATA_326103
 	bool "ARM errata: FSR write bit incorrect on a SWP to read-only

memory"

Quoted 8 lines
arch/arm/Kconfig +0 -0
 	depends on CPU_V6
(quoted diff) +0 -0

b/arch/arm/include/asm/tlbflush.h index a3625d1..e3a8064 100644

arch/arm/include/asm/tlbflush.h +0 -0
@@ -475,7 +475,11 @@ static inline void flush_pmd_entry(void *pmd)  {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
Quoted 4 lines

arch/arm/include/asm/tlbflush.h static inline void flush_pmd_entry(void *pmd) { · line 478

Quoted 2 lines
arch/arm/include/asm/tlbflush.h +2 -0
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);

Can you elaborate on the comment please?

Yes, I'll add clean & invalidate to the comment there.

Quoted 6 lines
Quoted 6 lines
arch/arm/include/asm/tlbflush.h +2 -0
+#else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
+#endif
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 
Quoted 8 lines

arch/arm/include/asm/tlbflush.h static inline void clean_pmd_entry(void *pmd) { · line 493

Quoted 6 lines
arch/arm/include/asm/tlbflush.h +2 -0
 	if (tlb_flag(TLB_WB))
@@ -486,7 +490,11 @@ static inline void clean_pmd_entry(void *pmd)  {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);

and here.

Same.

Quoted 18 lines
Quoted 11 lines
arch/arm/include/asm/tlbflush.h +2 -0
+#else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
+#endif
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);  }
 
arch/arm/mm/cache-v7.S index renamed from arch/arm/mm/cache-v7.S +0 -0

15451ee..d353649 100644

arch/arm/mm/cache-v7.S ENTRY(v7_coherent_user_range) · line 274

Quoted 5 lines
arch/arm/mm/cache-v7.S +2 -0
@@ -270,7 +270,11 @@ ENTRY(v7_coherent_user_range)
 	ALT_UP(W(nop))
 #endif
 1:
+#ifdef CONFIG_PJ4B_ERRATA_6124
+ USER(	mcr	p15, 0, r12, c7, c14, 1	)	@ clean & invalidate

D line to the point of unification

Quoted 1 line

This flushes to the point of coherency (there is no PoU clean & inv).

Thanks, I'll update the comment.

Quoted 16 lines

arch/arm/mm/cache-v7.S ENTRY(v7_coherent_user_range) · line 276

Quoted 3 lines
arch/arm/mm/cache-v7.S +1 -0
+#else
  USER(	mcr	p15, 0, r12, c7, c11, 1	)	@ clean D line to the

point of unification

arch/arm/mm/cache-v7.S v7_dma_clean_range: · line 386

Quoted 10 lines
arch/arm/mm/cache-v7.S +3 -0
+#endif
 	add	r12, r12, r2
 	cmp	r12, r1
 	blo	1b
@@ -378,7 +382,11 @@ v7_dma_clean_range:
 	ALT_UP(W(nop))
 #endif
 1:
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	mcr	p15, 0, r0, c7, c14, 1		@ clean & invalidate D line to

the point of unification

Quoted 3 lines

Similarly, although I don't understand why you care about the erratum for dma_clean_range. There should be no pending stores to the buffer, otherwise you risk corruption anyway (from the device's point of view).

You're raising an interesting point (and logically sound correct). I'll have to look into it and run some tests to ensure all is valid.

Quoted 19 lines
Quoted 12 lines
arch/arm/mm/cache-v7.S +2 -0
+#else
 	mcr	p15, 0, r0, c7, c10, 1		@ clean D / U line
+#endif
 	add	r0, r0, r2
 	cmp	r0, r1
 	blo	1b
(quoted diff) +0 -0

b/arch/arm/mm/proc-v7-2level.S index 9704097..0999fd3 100644

arch/arm/mm/proc-v7-2level.S ENTRY(cpu_v7_set_pte_ext) · line 115

Quoted 5 lines
arch/arm/mm/proc-v7-2level.S +2 -0
@@ -111,8 +111,12 @@ ENTRY(cpu_v7_set_pte_ext)
  THUMB(	add	r0, r0, #2048 )
  THUMB(	str	r3, [r0] )
 	ALT_SMP(mov	pc,lr)
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	ALT_UP (mcr	p15, 0, r0, c7, c14, 1)		@ flush_pte by clean

& invalidate D entry

Quoted 2 lines

The use of `by' is a bit confusing, since you can also do maintenance by set/way.

I'll change that to 'using' instead.

Quoted 33 lines
Quoted 13 lines
arch/arm/mm/proc-v7-2level.S +2 -0
+#else
 	ALT_UP (mcr	p15, 0, r0, c7, c10, 1)		@ flush_pte
 #endif
+#endif
 	mov	pc, lr
 ENDPROC(cpu_v7_set_pte_ext)
 
(quoted diff) +0 -0

b/arch/arm/mm/proc-v7-3level.S index 363027e..7a917ff 100644

arch/arm/mm/proc-v7-3level.S ENTRY(cpu_v7_set_pte_ext) · line 78

Quoted 5 lines
arch/arm/mm/proc-v7-3level.S +2 -0
@@ -74,8 +74,12 @@ ENTRY(cpu_v7_set_pte_ext)
 	orreq	r2, #L_PTE_RDONLY
 1:	strd	r2, r3, [r0]
 	ALT_SMP(mov	pc, lr)
+#ifdef CONFIG_PJ4B_ERRATA_6124
+	ALT_UP (mcr	p15, 0, r0, c7, c14, 1)		@ flush_pte by clean

& invalidate D entry

arch/arm/mm/proc-v7.S ENTRY(cpu_v7_dcache_clean_area) · line 81

Quoted 13 lines
arch/arm/mm/proc-v7-3level.S +2 -0
+#else
 	ALT_UP (mcr	p15, 0, r0, c7, c10, 1)		@ flush_pte
 #endif
+#endif
 	mov	pc, lr
 ENDPROC(cpu_v7_set_pte_ext)
 
arch/arm/mm/proc-v7.S index renamed from arch/arm/mm/proc-v7.S +0 -0

f872432..b86d688 100644

arch/arm/mm/proc-v7.S +0 -0
@@ -81,7 +81,11 @@ ENTRY(cpu_v7_dcache_clean_area)
 	ALT_SMP(mov	pc, lr)			@ MP extensions imply L1

PTW

Quoted 4 lines

arch/arm/mm/proc-v7.S ENTRY(cpu_v7_dcache_clean_area) · line 83

Quoted 2 lines
arch/arm/mm/proc-v7.S +0 -0
 	ALT_UP(W(nop))
 	dcache_line_size r2, r3

You could move the 1: label here.

Right, will do.

Quoted 8 lines

arch/arm/mm/proc-v7.S ENTRY(cpu_v7_dcache_clean_area) · line 88

Quoted 6 lines
arch/arm/mm/proc-v7.S +4 -0
+#ifdef CONFIG_PJ4B_ERRATA_6124
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean & invalidate D entry
+#else
 1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+#endif

Will

Regards,
Lior Amsalem

#7 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

In reply to Gregory CLEMENT

From: Lior Amsalem <[email protected]>

A CP15 clean operation can result in a dead lock state if it is hit by an incoming snoop event. the fiw to this issue is the following:
before any CP15 clean type operation in Cache Coherency mode, issue a Data Memory Barrier (DMB) or a Data Synchronization Barrier (DSB) instruction.

[gregory.clement at free-electrons.com:add errata description in changelog] [gregory.clement at free-electrons.com:make this errata depend on Aramda 370]

---
 arch/arm/Kconfig                | 11 +++++++++++
 arch/arm/include/asm/tlbflush.h | 22 ++++++++++++++++++++++
 arch/arm/mm/copypage-v6.c       | 11 +++++++++++
 arch/arm/mm/proc-macros.S       | 13 +++++++++++++
 4 files changed, 57 insertions(+)
arch/arm/Kconfig +11 -0
index 48cdbea..05c13f9 100644
@@ -1087,6 +1087,17 @@ if !MMU
 source "arch/arm/Kconfig-nommu"
 endif
 
+config PJ4B_ERRATA_4611
+        bool "PJ4B Errata 4611: A Deadlock can Occur if a CP15 Clean/Clean and Invalidate Operation is Hit By a Snoop Event"
+        depends on CPU_PJ4B && MACH_ARMADA_370
+        help
+          A CP15 clean operation can result in a dead lock state if it is hit by
+          an incoming snoop event.
+          Workaround:
+	  Before any CP15 clean type operation in Cache Coherency mode, issue
+          a Data Memory Barrier (DMB) or a Data Synchronization Barrier (DSB)
+          instruction.
+
 config PJ4B_ERRATA_4742
         bool "PJ4B Errata 4742: IDLE Wake Up Commands can Cause the CPU Core to Cease Operation"
         depends on CPU_PJ4B && MACH_ARMADA_370
arch/arm/include/asm/tlbflush.h +22 -0
index e3a8064..112f778 100644
@@ -475,11 +475,22 @@ static inline void flush_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	unsigned long flags;
+	raw_local_irq_save(flags);
+	dmb();
+#endif
+
 #ifdef CONFIG_PJ4B_ERRATA_6124
 	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
 #else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
 #endif
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	raw_local_irq_restore(flags);
+#endif
+
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 
 	if (tlb_flag(TLB_WB))
@@ -490,11 +501,22 @@ static inline void clean_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	unsigned long flags;
+	raw_local_irq_save(flags);
+	dmb();
+#endif
+
 #ifdef CONFIG_PJ4B_ERRATA_6124
 	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
 #else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
 #endif
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	raw_local_irq_restore(flags);
+#endif
+
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 }
 
arch/arm/mm/copypage-v6.c +11 -0
index b9bcc9d..20b69ad 100644
@@ -59,11 +59,22 @@ static void v6_clear_user_highpage_nonaliasing(struct page *page, unsigned long
  */
 static void discard_old_kernel_data(void *kto)
 {
+#ifdef CONFIG_PJ4B_ERRATA_4611
+        unsigned long flags;
+
+        raw_local_irq_save(flags);
+        dmb();
+#endif
+
 	__asm__("mcrr	p15, 0, %1, %0, c6	@ 0xec401f06"
 	   :
 	   : "r" (kto),
 	     "r" ((unsigned long)kto + PAGE_SIZE - L1_CACHE_BYTES)
 	   : "cc");
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+        raw_local_irq_restore(flags);
+#endif
 }
 
 /*
arch/arm/mm/proc-macros.S +13 -0
index f9a0aa7..ca81291 100644
@@ -178,7 +178,20 @@
 #endif
 
 	str	r3, [r0]
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	mrs     r2, cpsr
+	orr     r3, r2, #PSR_F_BIT | PSR_I_BIT
+	msr     cpsr_c, r3                      @ Disable interrupts
+	dmb                                     @ ensure ordering with previous memory accesses
+#endif
+
 	mcr	p15, 0, r0, c7, c10, 1		@ flush_pte
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	msr     cpsr_c, r2                      @ Restore interrupts
+	mcr     p15, 0, r0, c7, c10, 4          @ drain write buffer
+#endif
 	.endm
 
 
Signature · 1 line
1.8.1.2
#8 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

Quoted 4 lines · Gregory CLEMENT

From: Lior Amsalem <[email protected]>

A CP15 clean operation can result in a dead lock state if it is hit by an incoming snoop event. the fiw to this issue is the following:

s/fiw/fix/

Quoted 3 lines

before any CP15 clean type operation in Cache Coherency mode, issue a Data Memory Barrier (DMB) or a Data Synchronization Barrier (DSB) instruction.

Could you combine this with #6124, so we don't have back-to-back ifdefs all over the place? Also, there are more clean operations than you have described here, so why haven't you have to touch them all?

Quoted 47 lines

[gregory.clement at free-electrons.com:add errata description in changelog] [gregory.clement at free-electrons.com:make this errata depend on Aramda 370]

---
 arch/arm/Kconfig                | 11 +++++++++++
 arch/arm/include/asm/tlbflush.h | 22 ++++++++++++++++++++++
 arch/arm/mm/copypage-v6.c       | 11 +++++++++++
 arch/arm/mm/proc-macros.S       | 13 +++++++++++++
 4 files changed, 57 insertions(+)
arch/arm/Kconfig +11 -0
index 48cdbea..05c13f9 100644
@@ -1087,6 +1087,17 @@ if !MMU
 source "arch/arm/Kconfig-nommu"
 endif
 
+config PJ4B_ERRATA_4611
+        bool "PJ4B Errata 4611: A Deadlock can Occur if a CP15 Clean/Clean and Invalidate Operation is Hit By a Snoop Event"
+        depends on CPU_PJ4B && MACH_ARMADA_370
+        help
+          A CP15 clean operation can result in a dead lock state if it is hit by
+          an incoming snoop event.
+          Workaround:
+	  Before any CP15 clean type operation in Cache Coherency mode, issue
+          a Data Memory Barrier (DMB) or a Data Synchronization Barrier (DSB)
+          instruction.
+
 config PJ4B_ERRATA_4742
         bool "PJ4B Errata 4742: IDLE Wake Up Commands can Cause the CPU Core to Cease Operation"
         depends on CPU_PJ4B && MACH_ARMADA_370
arch/arm/include/asm/tlbflush.h +5 -0
index e3a8064..112f778 100644
@@ -475,11 +475,22 @@ static inline void flush_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	unsigned long flags;
+	raw_local_irq_save(flags);
+	dmb();
+#endif

arch/arm/include/asm/tlbflush.h static inline void flush_pmd_entry(void *pmd) · line 492

Quoted 10 lines
arch/arm/include/asm/tlbflush.h +5 -0
+
 #ifdef CONFIG_PJ4B_ERRATA_6124
 	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
 #else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
 #endif
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	raw_local_irq_restore(flags);
+#endif

Eeek. Why do you have to disable interrupts during this? Again, are there no chicken bits to save you?

Quoted 40 lines
arch/arm/include/asm/tlbflush.h +11 -0
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 
 	if (tlb_flag(TLB_WB))
@@ -490,11 +501,22 @@ static inline void clean_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	unsigned long flags;
+	raw_local_irq_save(flags);
+	dmb();
+#endif
+
 #ifdef CONFIG_PJ4B_ERRATA_6124
 	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
 #else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
 #endif
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	raw_local_irq_restore(flags);
+#endif
+
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 }
 
arch/arm/mm/copypage-v6.c +6 -0
index b9bcc9d..20b69ad 100644
@@ -59,11 +59,22 @@ static void v6_clear_user_highpage_nonaliasing(struct page *page, unsigned long
  */
 static void discard_old_kernel_data(void *kto)
 {
+#ifdef CONFIG_PJ4B_ERRATA_4611
+        unsigned long flags;
+
+        raw_local_irq_save(flags);
+        dmb();
+#endif

arch/arm/mm/copypage-v6.c static void v6_clear_user_highpage_nonaliasing(struct page *page, unsigned long · line 77

Quoted 10 lines
arch/arm/mm/copypage-v6.c +5 -0
+
 	__asm__("mcrr	p15, 0, %1, %0, c6	@ 0xec401f06"
 	   :
 	   : "r" (kto),
 	     "r" ((unsigned long)kto + PAGE_SIZE - L1_CACHE_BYTES)
 	   : "cc");
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+        raw_local_irq_restore(flags);
+#endif

Do you actually have an aliasing vipt cache? If not, you don't care about this function.

Quoted 12 lines
arch/arm/mm/proc-macros.S +4 -0
index f9a0aa7..ca81291 100644
@@ -178,7 +178,20 @@
 #endif
 
 	str	r3, [r0]
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	mrs     r2, cpsr
+	orr     r3, r2, #PSR_F_BIT | PSR_I_BIT

arch/arm/mm/proc-macros.S line 194

Quoted 10 lines
arch/arm/mm/proc-macros.S +9 -0
+	msr     cpsr_c, r3                      @ Disable interrupts
+	dmb                                     @ ensure ordering with previous memory accesses
+#endif
+
 	mcr	p15, 0, r0, c7, c10, 1		@ flush_pte
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	msr     cpsr_c, r2                      @ Restore interrupts
+	mcr     p15, 0, r0, c7, c10, 4          @ drain write buffer
+#endif

This could be a dsb.

Will

#9 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

Hi Will,

Quoted 8 lines · Will Deacon
Quoted 4 lines · Gregory CLEMENT

From: Lior Amsalem <[email protected]>

A CP15 clean operation can result in a dead lock state if it is hit by an incoming snoop event. the fiw to this issue is the following:

s/fiw/fix/

Quoted 7 lines
Quoted 3 lines

before any CP15 clean type operation in Cache Coherency mode, issue a Data Memory Barrier (DMB) or a Data Synchronization Barrier (DSB) instruction.

Could you combine this with #6124, so we don't have back-to-back ifdefs all over the place? Also, there are more clean operations than you have described here, so why haven't you have to touch them all?

For the first point, unfortunately it is not possible as they are errata for different CPUs. If finally the 2 last patches won't be merged in 3.10, then I will add a new patch before them, to introduce the PJ4B-MP which is the CPU used by the Armada XP whereas the Armada 370 uses the PJ4B.

For the second point and the other CPU specific questions you raised in the other emails, I am waiting for answer from Marvell engineers.

Thanks for your review

Quoted 143 lines
Quoted 48 lines

[gregory.clement at free-electrons.com:add errata description in changelog] [gregory.clement at free-electrons.com:make this errata depend on Aramda 370]

---
 arch/arm/Kconfig                | 11 +++++++++++
 arch/arm/include/asm/tlbflush.h | 22 ++++++++++++++++++++++
 arch/arm/mm/copypage-v6.c       | 11 +++++++++++
 arch/arm/mm/proc-macros.S       | 13 +++++++++++++
 4 files changed, 57 insertions(+)
arch/arm/Kconfig +11 -0
index 48cdbea..05c13f9 100644
@@ -1087,6 +1087,17 @@ if !MMU
 source "arch/arm/Kconfig-nommu"
 endif
 
+config PJ4B_ERRATA_4611
+        bool "PJ4B Errata 4611: A Deadlock can Occur if a CP15 Clean/Clean and Invalidate Operation is Hit By a Snoop Event"
+        depends on CPU_PJ4B && MACH_ARMADA_370
+        help
+          A CP15 clean operation can result in a dead lock state if it is hit by
+          an incoming snoop event.
+          Workaround:
+	  Before any CP15 clean type operation in Cache Coherency mode, issue
+          a Data Memory Barrier (DMB) or a Data Synchronization Barrier (DSB)
+          instruction.
+
 config PJ4B_ERRATA_4742
         bool "PJ4B Errata 4742: IDLE Wake Up Commands can Cause the CPU Core to Cease Operation"
         depends on CPU_PJ4B && MACH_ARMADA_370
arch/arm/include/asm/tlbflush.h +5 -0
index e3a8064..112f778 100644
@@ -475,11 +475,22 @@ static inline void flush_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	unsigned long flags;
+	raw_local_irq_save(flags);
+	dmb();
+#endif

arch/arm/include/asm/tlbflush.h static inline void flush_pmd_entry(void *pmd) · line 492

Quoted 10 lines
arch/arm/include/asm/tlbflush.h +5 -0
+
 #ifdef CONFIG_PJ4B_ERRATA_6124
 	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
 #else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
 #endif
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	raw_local_irq_restore(flags);
+#endif

Eeek. Why do you have to disable interrupts during this? Again, are there no chicken bits to save you?

Quoted 40 lines
arch/arm/include/asm/tlbflush.h +11 -0
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 
 	if (tlb_flag(TLB_WB))
@@ -490,11 +501,22 @@ static inline void clean_pmd_entry(void *pmd)
 {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	unsigned long flags;
+	raw_local_irq_save(flags);
+	dmb();
+#endif
+
 #ifdef CONFIG_PJ4B_ERRATA_6124
 	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
 #else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
 #endif
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	raw_local_irq_restore(flags);
+#endif
+
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 }
 
arch/arm/mm/copypage-v6.c +6 -0
index b9bcc9d..20b69ad 100644
@@ -59,11 +59,22 @@ static void v6_clear_user_highpage_nonaliasing(struct page *page, unsigned long
  */
 static void discard_old_kernel_data(void *kto)
 {
+#ifdef CONFIG_PJ4B_ERRATA_4611
+        unsigned long flags;
+
+        raw_local_irq_save(flags);
+        dmb();
+#endif

arch/arm/mm/copypage-v6.c static void v6_clear_user_highpage_nonaliasing(struct page *page, unsigned long · line 77

Quoted 10 lines
arch/arm/mm/copypage-v6.c +5 -0
+
 	__asm__("mcrr	p15, 0, %1, %0, c6	@ 0xec401f06"
 	   :
 	   : "r" (kto),
 	     "r" ((unsigned long)kto + PAGE_SIZE - L1_CACHE_BYTES)
 	   : "cc");
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+        raw_local_irq_restore(flags);
+#endif

Do you actually have an aliasing vipt cache? If not, you don't care about this function.

Quoted 12 lines
arch/arm/mm/proc-macros.S +4 -0
index f9a0aa7..ca81291 100644
@@ -178,7 +178,20 @@
 #endif
 
 	str	r3, [r0]
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	mrs     r2, cpsr
+	orr     r3, r2, #PSR_F_BIT | PSR_I_BIT

arch/arm/mm/proc-macros.S line 194

Quoted 10 lines
arch/arm/mm/proc-macros.S +9 -0
+	msr     cpsr_c, r3                      @ Disable interrupts
+	dmb                                     @ ensure ordering with previous memory accesses
+#endif
+
 	mcr	p15, 0, r0, c7, c10, 1		@ flush_pte
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	msr     cpsr_c, r2                      @ Restore interrupts
+	mcr     p15, 0, r0, c7, c10, 4          @ drain write buffer
+#endif

This could be a dsb.

Will

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#10 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

Quoted 9 lines · On Wednesday 29 May 2013 14:57:10 Gregory CLEMENT wrote:

For the first point, unfortunately it is not possible as they are errata for different CPUs. If finally the 2 last patches won't be merged in 3.10, then I will add a new patch before them, to introduce the PJ4B-MP which is the CPU used by the Armada XP whereas the Armada 370 uses the PJ4B.

For the second point and the other CPU specific questions you raised in the other emails, I am waiting for answer from Marvell engineers.

I've been confused by the various CPU types before. If you have any information that's not yet in the excellent Documentation/arm/Marvell/README file that Thomas added, could you put it in there?

In particular, I'd like to understand what variants of PJ4 there are, and maybe you can list their cpuid part numbers.

Arnd

#11 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

Quoted 11 lines · Arnd Bergmann
Quoted 9 lines · On Wednesday 29 May 2013 14:57:10 Gregory CLEMENT wrote:

For the first point, unfortunately it is not possible as they are errata for different CPUs. If finally the 2 last patches won't be merged in 3.10, then I will add a new patch before them, to introduce the PJ4B-MP which is the CPU used by the Armada XP whereas the Armada 370 uses the PJ4B.

For the second point and the other CPU specific questions you raised in the other emails, I am waiting for answer from Marvell engineers.

Quoted 7 lines

I've been confused by the various CPU types before. If you have any information that's not yet in the excellent Documentation/arm/Marvell/README file that Thomas added, could you put it in there?

In particular, I'd like to understand what variants of PJ4 there are, and maybe you can list their cpuid part numbers.

OK I will see what kind of information I can gather and which ones I can add to the Documentation/arm/Marvell/README file.

My current understanding is that there are at least 3 kind of CPU:
PJ4, PJ4B and PJ4B-MP and all of them belongs to the Sheeva family.

Quoted 3 lines

Arnd

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#12 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

Quoted 5 lines · On Wednesday 29 May 2013 15:27:31 Gregory CLEMENT wrote:

OK I will see what kind of information I can gather and which ones I can add to the Documentation/arm/Marvell/README file.

My current understanding is that there are at least 3 kind of CPU:
PJ4, PJ4B and PJ4B-MP and all of them belongs to the Sheeva family.

Ok. So I guess PJ4B adds LPAE support, and PJ4B-MP adds SMP support, right? Do either of them support hypervisor mode?

Regarding the errata: are those needed for production-level chips, or just for prototypes?

Arnd

#13 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

Quoted 5 lines

From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Wednesday, May 29, 2013 4:33 PM

On Wednesday 29 May 2013 15:27:31 Gregory CLEMENT wrote:

Quoted 8 lines
Quoted 5 lines

OK I will see what kind of information I can gather and which ones I can add to the Documentation/arm/Marvell/README file.

My current understanding is that there are at least 3 kind of CPU:
PJ4, PJ4B and PJ4B-MP and all of them belongs to the Sheeva family.

Ok. So I guess PJ4B adds LPAE support, and PJ4B-MP adds SMP support, right? Do either of them support hypervisor mode?

It goes like this:
PJ4B: improved version of PJ4.
PJ4B-MP: adds LPAE and SMP.
No support for virtualization on any.

Quoted 3 lines

Regarding the errata: are those needed for production-level chips, or just for prototypes?

These are production level chips.

Quoted 2 lines

Arnd

Regards,
Lior Amsalem

#14 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

Quoted 10 lines · On Tuesday 04 June 2013 14:34:53 Lior Amsalem wrote:
Quoted 10 lines

From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Wednesday, May 29, 2013 4:33 PM

Quoted 5 lines · On Wednesday 29 May 2013 15:27:31 Gregory CLEMENT wrote:

OK I will see what kind of information I can gather and which ones I can add to the Documentation/arm/Marvell/README file.

My current understanding is that there are at least 3 kind of CPU:
PJ4, PJ4B and PJ4B-MP and all of them belongs to the Sheeva family.

Quoted 7 lines
Quoted 2 lines

Ok. So I guess PJ4B adds LPAE support, and PJ4B-MP adds SMP support, right? Do either of them support hypervisor mode?

It goes like this:
PJ4B: improved version of PJ4.
PJ4B-MP: adds LPAE and SMP.
No support for virtualization on any.

Ah, interesting. So PJ4B is just faster than PJ4 and has no extra instructions or other features?

Quoted 4 lines
Quoted 2 lines

Regarding the errata: are those needed for production-level chips, or just for prototypes?

These are production level chips.

Ok, thanks for the information. To clarify, does that mean that all future PJ4B and PJ4B-MP based chips also need the errata, or is there is a chance they will be fixed in future revisions?

Arnd

#15 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

Quoted 17 lines

From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Tuesday, June 04, 2013 2:40 PM

Quoted 13 lines · On Tuesday 04 June 2013 14:34:53 Lior Amsalem wrote:
Quoted 12 lines

From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Wednesday, May 29, 2013 4:33 PM

Quoted 5 lines · On Wednesday 29 May 2013 15:27:31 Gregory CLEMENT wrote:

OK I will see what kind of information I can gather and which ones I can add to the Documentation/arm/Marvell/README file.

My current understanding is that there are at least 3 kind of CPU:
PJ4, PJ4B and PJ4B-MP and all of them belongs to the Sheeva family.

Ok. So I guess PJ4B adds LPAE support, and PJ4B-MP adds SMP support, right? Do either of them support hypervisor mode?

Quoted 7 lines
Quoted 4 lines

It goes like this:
PJ4B: improved version of PJ4.
PJ4B-MP: adds LPAE and SMP.
No support for virtualization on any.

Ah, interesting. So PJ4B is just faster than PJ4 and has no extra instructions or other features?

It's a different microarchitecture, pipeline, but I don't know all the details.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Regarding the errata: are those needed for production-level chips, or just for prototypes?

These are production level chips.

Ok, thanks for the information. To clarify, does that mean that all future PJ4B and PJ4B-MP based chips also need the errata, or is there is a chance they will be fixed in future revisions?

No, to my knowledge they're not going to be fixed.

Quoted 2 lines

Arnd

Regards,
Lior Amsalem

#16 lore raw

PATCH 3/3 ARM PJ4B: Add support for errata 4611

In reply to Will Deacon
Quoted 8 lines

From: Will Deacon [mailto:will.deacon at arm.com]
Sent: Wednesday, May 29, 2013 2:22 PM

Quoted 4 lines · Gregory CLEMENT

From: Lior Amsalem <[email protected]>

A CP15 clean operation can result in a dead lock state if it is hit by an incoming snoop event. the fiw to this issue is the following:

[Snip]

Quoted 17 lines
Quoted 17 lines

a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h index e3a8064..112f778 100644

arch/arm/include/asm/tlbflush.h +6 -0
@@ -475,11 +475,22 @@ static inline void flush_pmd_entry(void *pmd)  {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	unsigned long flags;
+	raw_local_irq_save(flags);
+	dmb();
+#endif
+
 #ifdef CONFIG_PJ4B_ERRATA_6124
 	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
 #else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
Quoted 8 lines

arch/arm/include/asm/tlbflush.h static inline void flush_pmd_entry(void *pmd) · line 492

Quoted 5 lines
arch/arm/include/asm/tlbflush.h +4 -0
 #endif
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	raw_local_irq_restore(flags);
+#endif

Eeek. Why do you have to disable interrupts during this? Again, are there no chicken bits to save you?

It's there in order to avoid an exception that will cause the workaround (of adding a DMB) to be dismissed.
No chicken bit for it...

Quoted 43 lines

arch/arm/mm/copypage-v6.c static void

Quoted 30 lines
arch/arm/include/asm/tlbflush.h +11 -0
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);
 
 	if (tlb_flag(TLB_WB))
@@ -490,11 +501,22 @@ static inline void clean_pmd_entry(void *pmd)  {
 	const unsigned int __tlb_flag = __cpu_tlb_flags;
 
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	unsigned long flags;
+	raw_local_irq_save(flags);
+	dmb();
+#endif
+
 #ifdef CONFIG_PJ4B_ERRATA_6124
 	tlb_op(TLB_DCLEAN, "c7, c14, 1	@ flush_pmd", pmd);
 #else
 	tlb_op(TLB_DCLEAN, "c7, c10, 1	@ flush_pmd", pmd);
 #endif
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	raw_local_irq_restore(flags);
+#endif
+
 	tlb_l2_op(TLB_L2CLEAN_FR, "c15, c9, 1  @ L2 flush_pmd", pmd);  }
 
arch/arm/mm/copypage-v6.c +0 -0
index b9bcc9d..20b69ad 100644
@@ -59,11 +59,22 @@ static void

v6_clear_user_highpage_nonaliasing(struct page *page, unsigned long

Quoted 12 lines
arch/arm/mm/copypage-v6.c +7 -0
  */
 static void discard_old_kernel_data(void *kto)  {
+#ifdef CONFIG_PJ4B_ERRATA_4611
+        unsigned long flags;
+
+        raw_local_irq_save(flags);
+        dmb();
+#endif
+
 	__asm__("mcrr	p15, 0, %1, %0, c6	@ 0xec401f06"
 	   :
 	   : "r" (kto),
Quoted 8 lines

arch/arm/mm/copypage-v6.c static void v6_clear_user_highpage_nonaliasing(struct page *page, unsigned long

Quoted 5 lines
arch/arm/mm/copypage-v6.c +3 -0
 	     "r" ((unsigned long)kto + PAGE_SIZE - L1_CACHE_BYTES)
 	   : "cc");
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+        raw_local_irq_restore(flags); #endif

Do you actually have an aliasing vipt cache? If not, you don't care about this function.

No, It's a mistake, will be removed. 10x for pointing that out.

Quoted 16 lines
Quoted 6 lines
arch/arm/mm/proc-macros.S +0 -0
index f9a0aa7..ca81291 100644

arch/arm/mm/proc-macros.S line 186

Quoted 9 lines
arch/arm/mm/proc-macros.S +6 -0
@@ -178,7 +178,20 @@
 #endif
 
 	str	r3, [r0]
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	mrs     r2, cpsr
+	orr     r3, r2, #PSR_F_BIT | PSR_I_BIT
+	msr     cpsr_c, r3                      @ Disable interrupts
+	dmb                                     @ ensure ordering with previous memory

accesses

Quoted 10 lines

arch/arm/mm/proc-macros.S line 194

Quoted 8 lines
arch/arm/mm/proc-macros.S +7 -0
+#endif
+
 	mcr	p15, 0, r0, c7, c10, 1		@ flush_pte
+
+#ifdef CONFIG_PJ4B_ERRATA_4611
+	msr     cpsr_c, r2                      @ Restore interrupts
+	mcr     p15, 0, r0, c7, c10, 4          @ drain write buffer
+#endif

This could be a dsb.

Yes it can.

Quoted 2 lines

Will

Regards,
Lior Amsalem

#17 lore raw

cover ARM: PJ4B: fixes for 3.10-rc

In reply to Gregory CLEMENT

Gregory,

Quoted 7 lines · Gregory CLEMENT

Without the first one, the Armada 370 based board can't boot anymore since 3.10-rc1 and the commit "ARM: 7691/1: mm: kill unused TLB_CAN_READ_FROM_L1_CACHE and use ALT_SMP instead" . So this one really need to be appplied on 3.10-rc.

It should be a good thing to apply the others on the 3.10-rc, even we didn't observe yet a problem related to these errata, they may happen.

Since Linus in encouraging smaller -rc's, we should probably just submit the first patch to rmk's patch tracker for v3.10. The other two should be considered 'fixes-non-critical' for v3.11.

thx,

Jason.