Skip to contentSkip to conversation

SMP support for Armada XP

PATCH Superseded Gregory CLEMENT 3 participants 17 messages Oct 22, 2012 – Oct 23, 2012

Subsystems (4)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover SMP support for Armada XP

Hello,

The purpose of this patch set is to add the SMP support for the Armada XP SoCs. Beside the SMP support itself brought by the last 3 patches, this patch set also adds the support for the coherency fabric unit and the power management service unit.

The coherency fabric is responsible for ensuring hardware coherency between all CPUs and between CPUs and I/O masters. This unit is also available for Armada 370 and will be used in an incoming patch set for hardware I/O cache coherency.

The power management service unit is responsible for powering down and waking up CPUs and other SOC units.

The original code is from Yehuda Yitschak, it was reworked by myself and reviewed by Yehuda.

This patch set is based on 3.7-rc2 and depends one the framework clock support (the last version was posted last week:
http://thread.gmane.org/gmane.linux.kernel/1375701). The git branch called ArmadaXP-SMP-for-3.8 is also available at
https://github.com/MISL-EBU-System-SW/mainline-public.git.

Regards,

Yehuda Yitschak (5):
arm: mvebu: Added support for coherency fabric in mach-mvebu
arm: mvebu: Added initial support for power managmement service unit
arm: mvebu: Added IPI support via doorbells
arm: mm: Added support for PJ4B cpu and init routines
arm: mvebu: Added SMP support for Armada XP

 .../devicetree/bindings/arm/armada-370-xp-pmsu.txt |   20 ++++
 .../devicetree/bindings/arm/coherency-fabric.txt   |   16 +++
 arch/arm/boot/dts/armada-370-xp.dtsi               |    5 +
 arch/arm/boot/dts/armada-xp.dtsi                   |   12 +-
 arch/arm/configs/mvebu_defconfig                   |    3 +
 arch/arm/mach-mvebu/Kconfig                        |    3 +-
 arch/arm/mach-mvebu/Makefile                       |    4 +-
 arch/arm/mach-mvebu/armada-370-xp.c                |    1 +
 arch/arm/mach-mvebu/armada-370-xp.h                |   10 ++
 arch/arm/mach-mvebu/coherency.c                    |   92 +++++++++++++++
 arch/arm/mach-mvebu/coherency.h                    |   20 ++++
 arch/arm/mach-mvebu/common.h                       |    6 +
 arch/arm/mach-mvebu/headsmp.S                      |   65 +++++++++++
 arch/arm/mach-mvebu/hotplug.c                      |   30 +++++
 arch/arm/mach-mvebu/irq-armada-370-xp.c            |   92 ++++++++++++++-
 arch/arm/mach-mvebu/platsmp.c                      |  123 ++++++++++++++++++++
 arch/arm/mach-mvebu/pmsu.c                         |   78 +++++++++++++
 arch/arm/mach-mvebu/pmsu.h                         |   16 +++
 arch/arm/mm/Kconfig                                |    4 +
 arch/arm/mm/proc-v7.S                              |   46 ++++++++
 20 files changed, 637 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/armada-370-xp-pmsu.txt
 create mode 100644 Documentation/devicetree/bindings/arm/coherency-fabric.txt
 create mode 100644 arch/arm/mach-mvebu/coherency.c
 create mode 100644 arch/arm/mach-mvebu/coherency.h
 create mode 100644 arch/arm/mach-mvebu/headsmp.S
 create mode 100644 arch/arm/mach-mvebu/hotplug.c
 create mode 100644 arch/arm/mach-mvebu/platsmp.c
 create mode 100644 arch/arm/mach-mvebu/pmsu.c
 create mode 100644 arch/arm/mach-mvebu/pmsu.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/5 arm: mvebu: Added support for coherency fabric in mach-mvebu

From: Yehuda Yitschak <[email protected]>

---
 .../devicetree/bindings/arm/coherency-fabric.txt   |   16 ++++
 arch/arm/boot/dts/armada-370-xp.dtsi               |    5 ++
 arch/arm/mach-mvebu/Makefile                       |    2 +-
 arch/arm/mach-mvebu/coherency.c                    |   92 ++++++++++++++++++++
 arch/arm/mach-mvebu/coherency.h                    |   20 +++++
 arch/arm/mach-mvebu/common.h                       |    2 +
 6 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/arm/coherency-fabric.txt
 create mode 100644 arch/arm/mach-mvebu/coherency.c
 create mode 100644 arch/arm/mach-mvebu/coherency.h
Documentation/devicetree/bindings/arm/coherency-fabric.txt new file +16 -0
new file mode 100644
index 0000000..2bfbf67
@@ -0,0 +1,16 @@
+Coherency fabric
+----------------
+Available on Marvell SOCs: Armada 370 and Armada XP
+
+Required properties:
+
+- compatible: "marvell,coherency-fabric"
+- reg: Should contain,coherency fabric registers location and length.
+
+Example:
+
+coherency-fabric at d0020200 {
+	compatible = "marvell,coherency-fabric";
+	reg = <0xd0020200 0xb0>;
+};
+
arch/arm/boot/dts/armada-370-xp.dtsi +5 -0
index 94b4b9e..b0d075b 100644
@@ -36,6 +36,11 @@
 	      interrupt-controller;
 	};
 
+	coherency-fabric at d0020200 {
+		compatible = "marvell,coherency-fabric";
+		reg = <0xd0020200 0xb0>;
+	};
+
 	soc {
 		#address-cells = <1>;
 		#size-cells = <1>;
arch/arm/mach-mvebu/Makefile +1 -1
index 57f996b..abd6d3b 100644
@@ -2,4 +2,4 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include \
 	-I$(srctree)/arch/arm/plat-orion/include
 
 obj-y += system-controller.o
-obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o addr-map.o
+obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o addr-map.o coherency.o
arch/arm/mach-mvebu/coherency.c new file +92 -0

92 lines not on this page · raw message

arch/arm/mach-mvebu/coherency.h new file +20 -0
new file mode 100644
index 0000000..3c7e5b2
@@ -0,0 +1,20 @@
+/*
+ * arch/arm/mach-mvebu/include/mach/coherency.h
+ *
+ *
+ * Coherency fabric (Aurora) support for Armada 370 and XP platforms.
+ *
+ * Copyright (C) 2012 Marvell
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef __MACH_370_XP_COHERENCY_H
+#define __MACH_370_XP_COHERENCY_H
+
+int armada_370_xp_set_cpu_coherent(int cpu_id, int smp_group_id);
+int armada_xp_get_cpu_count(void);
+
+#endif	/* __MACH_370_XP_COHERENCY_H */
arch/arm/mach-mvebu/common.h +2 -0
index 281fab3..ea08919 100644
@@ -21,4 +21,6 @@ void mvebu_clocks_init(void);
 void armada_370_xp_init_irq(void);
 void armada_370_xp_handle_irq(struct pt_regs *regs);
 
+
+int armada_370_xp_coherency_init(void);
 #endif
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/5 arm: mvebu: Added initial support for power managmement service unit

In reply to Gregory CLEMENT

From: Yehuda Yitschak <[email protected]>

---
 .../devicetree/bindings/arm/armada-370-xp-pmsu.txt |   20 +++++
 arch/arm/boot/dts/armada-xp.dtsi                   |    6 ++
 arch/arm/mach-mvebu/Makefile                       |    2 +-
 arch/arm/mach-mvebu/common.h                       |    1 +
 arch/arm/mach-mvebu/pmsu.c                         |   78 ++++++++++++++++++++
 arch/arm/mach-mvebu/pmsu.h                         |   16 ++++
 6 files changed, 122 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/arm/armada-370-xp-pmsu.txt
 create mode 100644 arch/arm/mach-mvebu/pmsu.c
 create mode 100644 arch/arm/mach-mvebu/pmsu.h
Documentation/devicetree/bindings/arm/armada-370-xp-pmsu.txt new file +20 -0
new file mode 100644
index 0000000..926b4d6
@@ -0,0 +1,20 @@
+Power Management Service Unit(PMSU)
+-----------------------------------
+Available on Marvell SOCs: Armada 370 and Armada XP
+
+Required properties:
+
+- compatible: "marvell,armada-370-xp-pmsu"
+
+- reg: Should contain PMSU registers location and length. First pair
+  for the per-CPU SW Reset Control registers, second pair for the
+  Power Management Service Unit.
+
+Example:
+
+armada-370-xp-pmsu at d0022000 {
+	compatible = "marvell,armada-370-xp-pmsu";
+	reg = <0xd0022100 0x430>,
+	      <0xd0020800 0x20>;
+};
+
arch/arm/boot/dts/armada-xp.dtsi +6 -0
index a564b52..f521ed8 100644
@@ -27,6 +27,12 @@
 		    <0xd0021870 0x58>;
 	};
 
+	armada-370-xp-pmsu at d0022000 {
+		compatible = "marvell,armada-370-xp-pmsu";
+		reg = <0xd0022100 0x430>,
+		      <0xd0020800 0x20>;
+	};
+
 	cpus {
 	    #address-cells = <1>;
 	    #size-cells = <0>;
arch/arm/mach-mvebu/Makefile +1 -1
index abd6d3b..8e6e50b 100644
@@ -2,4 +2,4 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include \
 	-I$(srctree)/arch/arm/plat-orion/include
 
 obj-y += system-controller.o
-obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o addr-map.o coherency.o
+obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o addr-map.o coherency.o pmsu.o
arch/arm/mach-mvebu/common.h +1 -0
index ea08919..74ee0b2 100644
@@ -23,4 +23,5 @@ void armada_370_xp_handle_irq(struct pt_regs *regs);
 
 
 int armada_370_xp_coherency_init(void);
+int armada_370_xp_pmsu_init(void);
 #endif
arch/arm/mach-mvebu/pmsu.c new file +78 -0

78 lines not on this page · raw message

arch/arm/mach-mvebu/pmsu.h new file +16 -0
new file mode 100644
index 0000000..bafac8e
@@ -0,0 +1,16 @@
+/*
+ * Power Management Service Unit (PMSU) support for Armada 370/XP platforms.
+ *
+ * Copyright (C) 2012 Marvell
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef __MACH_MVEBU_PMSU_H
+#define __MACH_MVEBU_PMSU_H
+
+int armada_xp_boot_cpu(unsigned int cpu_id, void __iomem *phys_addr);
+
+#endif	/* __MACH_370_XP_PMSU_H */
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/5 arm: mvebu: Added IPI support via doorbells

In reply to Gregory CLEMENT

From: Yehuda Yitschak <[email protected]>

---
 arch/arm/boot/dts/armada-xp.dtsi        |    2 +-
 arch/arm/mach-mvebu/armada-370-xp.h     |   10 ++++
 arch/arm/mach-mvebu/irq-armada-370-xp.c |   92 +++++++++++++++++++++++++++++--
 3 files changed, 97 insertions(+), 7 deletions(-)
arch/arm/boot/dts/armada-xp.dtsi +1 -1
index f521ed8..531619f 100644
@@ -24,7 +24,7 @@
 
 	mpic: interrupt-controller at d0020000 {
 	      reg = <0xd0020a00 0x1d0>,
-		    <0xd0021870 0x58>;
+		    <0xd0021070 0x58>;
 	};
 
 	armada-370-xp-pmsu at d0022000 {
arch/arm/mach-mvebu/armada-370-xp.h +10 -0
index aac9beb..dce590d 100644
@@ -19,4 +19,14 @@
 #define ARMADA_370_XP_REGS_VIRT_BASE	IOMEM(0xfeb00000)
 #define ARMADA_370_XP_REGS_SIZE		SZ_1M
 
+#ifndef __ASSEMBLY__
+
+#ifdef CONFIG_SMP
+#include <linux/cpumask.h>
+
+void armada_mpic_send_doorbell(const struct cpumask *mask, unsigned int irq);
+void armada_xp_mpic_smp_cpu_init(void);
+#endif
+#endif
+
 #endif /* __MACH_ARMADA_370_XP_H */
arch/arm/mach-mvebu/irq-armada-370-xp.c +86 -6

142 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#4 lore raw

PATCH 3/5 arm: mvebu: Added IPI support via doorbells

Quoted 15 lines · Gregory CLEMENT

From: Yehuda Yitschak <[email protected]>

---
 arch/arm/boot/dts/armada-xp.dtsi        |    2 +-
 arch/arm/mach-mvebu/armada-370-xp.h     |   10 ++++
 arch/arm/mach-mvebu/irq-armada-370-xp.c |   92 +++++++++++++++++++++++++++++--
 3 files changed, 97 insertions(+), 7 deletions(-)
arch/arm/boot/dts/armada-xp.dtsi +0 -0
index f521ed8..531619f 100644

arch/arm/boot/dts/armada-xp.dtsi line 28

Quoted 6 lines
arch/arm/boot/dts/armada-xp.dtsi +1 -1
@@ -24,7 +24,7 @@
 
 	mpic: interrupt-controller at d0020000 {
 	      reg = <0xd0020a00 0x1d0>,
-		    <0xd0021870 0x58>;
+		    <0xd0021070 0x58>;
 	};

Hi Gregory

Is this a bug fix needed for 3.7?

Andrew

#5 lore raw

PATCH 3/5 arm: mvebu: Added IPI support via doorbells

Quoted 25 lines · Andrew Lunn
Quoted 15 lines · Gregory CLEMENT

From: Yehuda Yitschak <[email protected]>

---
 arch/arm/boot/dts/armada-xp.dtsi        |    2 +-
 arch/arm/mach-mvebu/armada-370-xp.h     |   10 ++++
 arch/arm/mach-mvebu/irq-armada-370-xp.c |   92 +++++++++++++++++++++++++++++--
 3 files changed, 97 insertions(+), 7 deletions(-)
arch/arm/boot/dts/armada-xp.dtsi +0 -0
index f521ed8..531619f 100644

arch/arm/boot/dts/armada-xp.dtsi line 28

Quoted 6 lines
arch/arm/boot/dts/armada-xp.dtsi +1 -1
@@ -24,7 +24,7 @@
 
 	mpic: interrupt-controller at d0020000 {
 	      reg = <0xd0020a00 0x1d0>,
-		    <0xd0021870 0x58>;
+		    <0xd0021070 0x58>;
 	};

Hi Gregory

Quoted 4 lines

Is this a bug fix needed for 3.7?

Andrew

I don't think so.
We extended the reg map to be able to use registers only used for SMP. When we didn't have SMP support the mapping was correct, and now by introducing SMP we extend it.

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

PATCH 3/5 arm: mvebu: Added IPI support via doorbells

Quoted 26 lines · Gregory CLEMENT
Quoted 25 lines · Andrew Lunn
Quoted 15 lines · Gregory CLEMENT

From: Yehuda Yitschak <[email protected]>

---
 arch/arm/boot/dts/armada-xp.dtsi        |    2 +-
 arch/arm/mach-mvebu/armada-370-xp.h     |   10 ++++
 arch/arm/mach-mvebu/irq-armada-370-xp.c |   92 +++++++++++++++++++++++++++++--
 3 files changed, 97 insertions(+), 7 deletions(-)
arch/arm/boot/dts/armada-xp.dtsi +0 -0
index f521ed8..531619f 100644

arch/arm/boot/dts/armada-xp.dtsi line 28

Quoted 6 lines
arch/arm/boot/dts/armada-xp.dtsi +1 -1
@@ -24,7 +24,7 @@
 
 	mpic: interrupt-controller at d0020000 {
 	      reg = <0xd0020a00 0x1d0>,
-		    <0xd0021870 0x58>;
+		    <0xd0021070 0x58>;
 	};

Hi Gregory

Quoted 8 lines
Quoted 4 lines

Is this a bug fix needed for 3.7?

Andrew

I don't think so.
We extended the reg map to be able to use registers only used for SMP. When we didn't have SMP support the mapping was correct, and now by introducing SMP we extend it.

The length has stayed the same, so its not extended. Its now 0x800 bytes earlier in the address space.

Andrew

#7 lore raw

PATCH 3/5 arm: mvebu: Added IPI support via doorbells

Quoted 31 lines · Andrew Lunn
Quoted 30 lines · Gregory CLEMENT
Quoted 29 lines · Andrew Lunn
Quoted 15 lines · Gregory CLEMENT

From: Yehuda Yitschak <[email protected]>

---
 arch/arm/boot/dts/armada-xp.dtsi        |    2 +-
 arch/arm/mach-mvebu/armada-370-xp.h     |   10 ++++
 arch/arm/mach-mvebu/irq-armada-370-xp.c |   92 +++++++++++++++++++++++++++++--
 3 files changed, 97 insertions(+), 7 deletions(-)
arch/arm/boot/dts/armada-xp.dtsi +0 -0
index f521ed8..531619f 100644

arch/arm/boot/dts/armada-xp.dtsi line 28

Quoted 6 lines
arch/arm/boot/dts/armada-xp.dtsi +1 -1
@@ -24,7 +24,7 @@
 
 	mpic: interrupt-controller at d0020000 {
 	      reg = <0xd0020a00 0x1d0>,
-		    <0xd0021870 0x58>;
+		    <0xd0021070 0x58>;
 	};

Hi Gregory

Is this a bug fix needed for 3.7?

Andrew

Quoted 8 lines
Quoted 4 lines

I don't think so.
We extended the reg map to be able to use registers only used for SMP. When we didn't have SMP support the mapping was correct, and now by introducing SMP we extend it.

The length has stayed the same, so its not extended. Its now 0x800 bytes earlier in the address space.

Right!
I didn't check it, sorry.

The correct explanation is that the offset +21070 is a CPU virtual offset. That means that depending of the CPU core which will access to this register, the controller will internally change the offset automagically to point the correct offset.

I should have added an explanation in the commit log. I will do it for V2.

Quoted 2 lines

Andrew

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

PATCH 3/5 arm: mvebu: Added IPI support via doorbells

Quoted 6 lines · Gregory CLEMENT

The correct explanation is that the offset +21070 is a CPU virtual offset. That means that depending of the CPU core which will access to this register, the controller will internally change the offset automagically to point the correct offset.

I should have added an explanation in the commit log. I will do it for V2.

Just to expand on Gr?gory's comment: there is per-CPU banking for the interrupt controller registers. At 0x21070, you have "virtual" registers that automatically map to the interrupt controller registers of the current CPU. At 0x21870, you have the interrupt controllers registers of CPU0, regardless of which CPU you are running on.

Before this patch set, there was no SMP support for Armada 370/XP, so accessing the interrupt controller registers at 0x21870 was OK (accessing them from 0x21070 would have been OK as well). With the introduction of SMP support, accessing them from 0x21870 no longer works, so we switch to the virtual registers at 0x21070.

In other words: no it is not a bug fix and it therefore doesn't need to go into 3.7.

Best regards,

Thomas

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

PATCH 3/5 arm: mvebu: Added IPI support via doorbells

Quoted 16 lines · Thomas Petazzoni
Quoted 6 lines · Gregory CLEMENT

The correct explanation is that the offset +21070 is a CPU virtual offset. That means that depending of the CPU core which will access to this register, the controller will internally change the offset automagically to point the correct offset.

I should have added an explanation in the commit log. I will do it for V2.

Just to expand on Gr??gory's comment: there is per-CPU banking for the interrupt controller registers. At 0x21070, you have "virtual" registers that automatically map to the interrupt controller registers of the current CPU. At 0x21870, you have the interrupt controllers registers of CPU0, regardless of which CPU you are running on.

Quoted 8 lines

Before this patch set, there was no SMP support for Armada 370/XP, so accessing the interrupt controller registers at 0x21870 was OK (accessing them from 0x21070 would have been OK as well). With the introduction of SMP support, accessing them from 0x21870 no longer works, so we switch to the virtual registers at 0x21070.

In other words: no it is not a bug fix and it therefore doesn't need to go into 3.7.

Hi Thomas

Thanks for the clear reply. Does the binding documentation make this clear? Should it be extended to indicate which address range should be used?

Thanks
Andrew

#10 lore raw

PATCH 3/5 arm: mvebu: Added IPI support via doorbells

Andrew,

Quoted 3 lines · Andrew Lunn

Thanks for the clear reply. Does the binding documentation make this clear? Should it be extended to indicate which address range should be used?

Indeed it should be clarified in the DT binding documentation. I'll see with Gr?gory to add such a clarification in his v2 of the SMP patch set, if that's ok with you.

Best regards,

Thomas

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

PATCH 4/5 arm: mm: Added support for PJ4B cpu and init routines

In reply to Gregory CLEMENT

From: Yehuda Yitschak <[email protected]>

---
 arch/arm/mach-mvebu/Kconfig |    2 +-
 arch/arm/mm/Kconfig         |    4 ++++
 arch/arm/mm/proc-v7.S       |   43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
arch/arm/mach-mvebu/Kconfig +1 -1
index 17d246b..9bfaa0c 100644
@@ -22,7 +22,7 @@ config MVEBU_CLK_CPU
 config MACH_ARMADA_370_XP
 	bool
 	select ARMADA_370_XP_TIMER
-	select CPU_V7
+	select CPU_PJ4B
 
 config MACH_ARMADA_370
 	bool "Marvell Armada 370 boards"
arch/arm/mm/Kconfig +4 -0
index 94186b6..3fd629d 100644
@@ -352,6 +352,10 @@ config CPU_PJ4
 	select ARM_THUMBEE
 	select CPU_V7
 
+config CPU_PJ4B
+	bool
+	select CPU_V7
+
 # ARMv6
 config CPU_V6
 	bool "Support ARM V6 processor" if ARCH_INTEGRATOR || MACH_REALVIEW_EB || MACH_REALVIEW_PBX
arch/arm/mm/proc-v7.S +43 -0

55 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#12 lore raw

PATCH 5/5 arm: mvebu: Added SMP support for Armada XP

In reply to Gregory CLEMENT

From: Yehuda Yitschak <[email protected]>

1. added smp init functions in platsmp.c
2. added secondary cpu entry point in headsmp.S
3. added hotplog initial support in hotplug.c
4. added SMP support for PJ4B cpu

---
 arch/arm/boot/dts/armada-xp.dtsi    |    4 ++
 arch/arm/configs/mvebu_defconfig    |    3 +
 arch/arm/mach-mvebu/Kconfig         |    1 +
 arch/arm/mach-mvebu/Makefile        |    2 +
 arch/arm/mach-mvebu/armada-370-xp.c |    1 +
 arch/arm/mach-mvebu/common.h        |    3 +
 arch/arm/mach-mvebu/headsmp.S       |   65 ++++++++++++++++++
 arch/arm/mach-mvebu/hotplug.c       |   30 +++++++++
 arch/arm/mach-mvebu/platsmp.c       |  123 +++++++++++++++++++++++++++++++++++
 arch/arm/mm/proc-v7.S               |    3 +
 10 files changed, 235 insertions(+)
 create mode 100644 arch/arm/mach-mvebu/headsmp.S
 create mode 100644 arch/arm/mach-mvebu/hotplug.c
 create mode 100644 arch/arm/mach-mvebu/platsmp.c
arch/arm/boot/dts/armada-xp.dtsi +4 -0
index 531619f..7f968dc 100644
@@ -38,24 +38,28 @@
 	    #size-cells = <0>;
 
 	    cpu at 0 {
+		device_type = "cpu";
 	       	compatible = "marvell,sheeva-v7";
 		reg = <0>;
 		clocks = <&cpuclk 0>;
 	    };
 
 	    cpu at 1 {
+		device_type = "cpu";
 		compatible = "marvell,sheeva-v7";
 		reg = <1>;
 		clocks = <&cpuclk 1>;
 	    };
 
 	    cpu at 2 {
+		device_type = "cpu";
 		compatible = "marvell,sheeva-v7";
 		reg = <2>;
 		clocks = <&cpuclk 2>;
 	    };
 
 	    cpu at 3 {
+		device_type = "cpu";
 		compatible = "marvell,sheeva-v7";
 		reg = <3>;
 		clocks = <&cpuclk 3>;
arch/arm/configs/mvebu_defconfig +3 -0
index 7bcf850..c0590c6 100644
@@ -10,6 +10,9 @@ CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_ARCH_MVEBU=y
 CONFIG_MACH_ARMADA_370_XP=y
+# CONFIG_SWP_EMULATE is not set
+CONFIG_SMP=y
+# CONFIG_LOCAL_TIMERS is not set
 CONFIG_AEABI=y
 CONFIG_HIGHMEM=y
 CONFIG_USE_OF=y
arch/arm/mach-mvebu/Kconfig +1 -0
index 9bfaa0c..d70afe3 100644
@@ -22,6 +22,7 @@ config MVEBU_CLK_CPU
 config MACH_ARMADA_370_XP
 	bool
 	select ARMADA_370_XP_TIMER
+	select HAVE_SMP
 	select CPU_PJ4B
 
 config MACH_ARMADA_370
arch/arm/mach-mvebu/Makefile +2 -0
index 8e6e50b..eb3cbd1 100644
@@ -3,3 +3,5 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include \
 
 obj-y += system-controller.o
 obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o addr-map.o coherency.o pmsu.o
+obj-$(CONFIG_SMP)                += platsmp.o headsmp.o
+obj-$(CONFIG_HOTPLUG_CPU)        += hotplug.o
arch/arm/mach-mvebu/armada-370-xp.c +1 -0
index 2af6ce5..41431a1 100644
@@ -59,6 +59,7 @@ static const char * const armada_370_xp_dt_board_dt_compat[] = {
 };
 
 DT_MACHINE_START(ARMADA_XP_DT, "Marvell Aramada 370/XP (Device Tree)")
+	.smp		= smp_ops(armada_xp_smp_ops),
 	.init_machine	= armada_370_xp_dt_init,
 	.map_io		= armada_370_xp_map_io,
 	.init_irq	= armada_370_xp_init_irq,
arch/arm/mach-mvebu/common.h +3 -0
index 74ee0b2..86484bb 100644
@@ -21,7 +21,10 @@ void mvebu_clocks_init(void);
 void armada_370_xp_init_irq(void);
 void armada_370_xp_handle_irq(struct pt_regs *regs);
 
+void armada_xp_cpu_die(unsigned int cpu);
 
 int armada_370_xp_coherency_init(void);
 int armada_370_xp_pmsu_init(void);
+void armada_xp_secondary_startup(void);
+extern struct smp_operations armada_xp_smp_ops;
 #endif
arch/arm/mach-mvebu/headsmp.S new file +65 -0

65 lines not on this page · raw message

arch/arm/mach-mvebu/hotplug.c new file +30 -0
new file mode 100644
index 0000000..b228b6a
@@ -0,0 +1,30 @@
+/*
+ * Symmetric Multi Processing (SMP) support for Armada XP
+ *
+ * Copyright (C) 2012 Marvell
+ *
+ * Lior Amsalem <[email protected]>
+ * Gregory CLEMENT <[email protected]>
+ * Thomas Petazzoni <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/smp.h>
+#include <asm/proc-fns.h>
+
+/*
+ * platform-specific code to shutdown a CPU
+ *
+ * Called with IRQs disabled
+ */
+void __ref armada_xp_cpu_die(unsigned int cpu)
+{
+	cpu_do_idle();
+
+	/* We should never return from idle */
+	panic("mvebu: cpu %d unexpectedly exit from shutdown\n", cpu);
+}
arch/arm/mach-mvebu/platsmp.c new file +123 -0

123 lines not on this page · raw message

arch/arm/mm/proc-v7.S +3 -0
index 1a373c2..4add2c4 100644
@@ -191,6 +191,9 @@ __v7_pj4b_setup:
 
 	/* Auxiliary Functional Modes Control Register 0 */
 	mrc	p15, 1,	r0, c15, c2, 0
+#ifdef CONFIG_SMP
+	orr	r0, r0, #(1 << 1)     @ Set SMP mode. Join the coherncy fabric
+#endif
 	orr	r0, r0, #(1 << 2)     @ Support L1 parity checking
 	orr	r0, r0, #(1 << 8)     @ Broadcast Cache and TLB maintenance
 	mcr	p15, 1,	r0, c15, c2, 0
Signature · 1 line
1.7.9.5
maintainer
#13 lore raw

PATCH 5/5 arm: mvebu: Added SMP support for Armada XP

Hi Gregory

Quoted 30 lines
arch/arm/mach-mvebu/platsmp.c new file +30 -0
+void __init set_secondary_cpus_clock(void)
+{
+	int cpu;
+	unsigned long rate;
+	struct clk *cpu_clk = NULL;
+	struct device_node *np = NULL;
+
+	cpu = smp_processor_id();
+	np = of_find_node_by_type(np, "cpu");
+	np = NULL;
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+		const u32 *reg;
+		int len;
+		reg = of_get_property(np, "reg", &len);
+		if (!reg || len != 4) {
+			pr_err("%s missing reg property\n", np->full_name);
+			continue;
+		}
+		if (be32_to_cpup(reg) == cpu) {
+			cpu_clk = of_clk_get(np, 0);
+			break;
+		}
+	}
+	WARN_ON(IS_ERR(cpu_clk));
+	rate = clk_get_rate(cpu_clk);
+
+	/* set all the other CPU clk to the same rate than the boot CPU */
+	np = NULL;
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+		const u32 *reg;

arch/arm/mach-mvebu/platsmp.c line 70

Quoted 10 lines
arch/arm/mach-mvebu/platsmp.c new file +10 -0
+		int len;
+		reg = of_get_property(np, "reg", &len);
+		if (!reg || len != 4) {
+			pr_err("%s missing reg property\n", np->full_name);
+			continue;
+		}
+		if (be32_to_cpup(reg) != cpu) {
+			cpu_clk = of_clk_get(np, 0);
+			clk_set_rate(cpu_clk, rate);
+		}

Maybe its hiding somewhere, but where is the clk_prepare_enable() for this cpu_clk clock?

Andrew

#14 lore raw

PATCH 5/5 arm: mvebu: Added SMP support for Armada XP

Quoted 37 lines · Andrew Lunn

Hi Gregory

Quoted 35 lines
arch/arm/mach-mvebu/platsmp.c new file +35 -0
+void __init set_secondary_cpus_clock(void)
+{
+	int cpu;
+	unsigned long rate;
+	struct clk *cpu_clk = NULL;
+	struct device_node *np = NULL;
+
+	cpu = smp_processor_id();
+	np = of_find_node_by_type(np, "cpu");
+	np = NULL;
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+		const u32 *reg;
+		int len;
+		reg = of_get_property(np, "reg", &len);
+		if (!reg || len != 4) {
+			pr_err("%s missing reg property\n", np->full_name);
+			continue;
+		}
+		if (be32_to_cpup(reg) == cpu) {
+			cpu_clk = of_clk_get(np, 0);
+			break;
+		}
+	}
+	WARN_ON(IS_ERR(cpu_clk));
+	rate = clk_get_rate(cpu_clk);
+
+	/* set all the other CPU clk to the same rate than the boot CPU */
+	np = NULL;
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+		const u32 *reg;
+		int len;
+		reg = of_get_property(np, "reg", &len);
+		if (!reg || len != 4) {
+			pr_err("%s missing reg property\n", np->full_name);
+			continue;
Quoted 9 lines

arch/arm/mach-mvebu/platsmp.c line 70

Quoted 5 lines
arch/arm/mach-mvebu/platsmp.c new file +5 -0
+		}
+		if (be32_to_cpup(reg) != cpu) {
+			cpu_clk = of_clk_get(np, 0);
+			clk_set_rate(cpu_clk, rate);
+		}

Maybe its hiding somewhere, but where is the clk_prepare_enable() for this cpu_clk clock?

Well the clocks are always enable. In the clock framework, the cpu clocks don't provide an enable function.
But maybe it is cleaner to call clk_prepare_enable() even if it does nothing except update the usage count.

Thanks,

Gregory

maintainer
#15 lore raw

PATCH 5/5 arm: mvebu: Added SMP support for Armada XP

Quoted 48 lines · Gregory CLEMENT
Quoted 37 lines · Andrew Lunn

Hi Gregory

Quoted 35 lines
arch/arm/mach-mvebu/platsmp.c new file +35 -0
+void __init set_secondary_cpus_clock(void)
+{
+	int cpu;
+	unsigned long rate;
+	struct clk *cpu_clk = NULL;
+	struct device_node *np = NULL;
+
+	cpu = smp_processor_id();
+	np = of_find_node_by_type(np, "cpu");
+	np = NULL;
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+		const u32 *reg;
+		int len;
+		reg = of_get_property(np, "reg", &len);
+		if (!reg || len != 4) {
+			pr_err("%s missing reg property\n", np->full_name);
+			continue;
+		}
+		if (be32_to_cpup(reg) == cpu) {
+			cpu_clk = of_clk_get(np, 0);
+			break;
+		}
+	}
+	WARN_ON(IS_ERR(cpu_clk));
+	rate = clk_get_rate(cpu_clk);
+
+	/* set all the other CPU clk to the same rate than the boot CPU */
+	np = NULL;
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+		const u32 *reg;
+		int len;
+		reg = of_get_property(np, "reg", &len);
+		if (!reg || len != 4) {
+			pr_err("%s missing reg property\n", np->full_name);
+			continue;
Quoted 9 lines

arch/arm/mach-mvebu/platsmp.c line 70

Quoted 5 lines
arch/arm/mach-mvebu/platsmp.c new file +5 -0
+		}
+		if (be32_to_cpup(reg) != cpu) {
+			cpu_clk = of_clk_get(np, 0);
+			clk_set_rate(cpu_clk, rate);
+		}

Maybe its hiding somewhere, but where is the clk_prepare_enable() for this cpu_clk clock?

Quoted 2 lines

Well the clocks are always enable. In the clock framework, the cpu clocks don't provide an enable function.

Is it possible in the hardware to disable them? Turning them off might save some power. If these chips end up in some data center server, it might be that CPU hotplugging is used.

Quoted 2 lines

But maybe it is cleaner to call clk_prepare_enable() even if it does nothing except update the usage count.

You also have to watch out for the late_initcall which will disable all clocks which are running but nobody has claimed. This will become an issue if you do have enable/disable function in later versions of the clock functions.

Andrew

#16 lore raw

PATCH 5/5 arm: mvebu: Added SMP support for Armada XP

Quoted 49 lines · Andrew Lunn
Quoted 48 lines · Gregory CLEMENT
Quoted 46 lines · Andrew Lunn

Hi Gregory

Quoted 30 lines
arch/arm/mach-mvebu/platsmp.c new file +30 -0
+void __init set_secondary_cpus_clock(void)
+{
+	int cpu;
+	unsigned long rate;
+	struct clk *cpu_clk = NULL;
+	struct device_node *np = NULL;
+
+	cpu = smp_processor_id();
+	np = of_find_node_by_type(np, "cpu");
+	np = NULL;
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+		const u32 *reg;
+		int len;
+		reg = of_get_property(np, "reg", &len);
+		if (!reg || len != 4) {
+			pr_err("%s missing reg property\n", np->full_name);
+			continue;
+		}
+		if (be32_to_cpup(reg) == cpu) {
+			cpu_clk = of_clk_get(np, 0);
+			break;
+		}
+	}
+	WARN_ON(IS_ERR(cpu_clk));
+	rate = clk_get_rate(cpu_clk);
+
+	/* set all the other CPU clk to the same rate than the boot CPU */
+	np = NULL;
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+		const u32 *reg;

arch/arm/mach-mvebu/platsmp.c line 70

Quoted 10 lines
arch/arm/mach-mvebu/platsmp.c new file +10 -0
+		int len;
+		reg = of_get_property(np, "reg", &len);
+		if (!reg || len != 4) {
+			pr_err("%s missing reg property\n", np->full_name);
+			continue;
+		}
+		if (be32_to_cpup(reg) != cpu) {
+			cpu_clk = of_clk_get(np, 0);
+			clk_set_rate(cpu_clk, rate);
+		}

Maybe its hiding somewhere, but where is the clk_prepare_enable() for this cpu_clk clock?

Quoted 6 lines
Quoted 2 lines

Well the clocks are always enable. In the clock framework, the cpu clocks don't provide an enable function.

Is it possible in the hardware to disable them? Turning them off might save some power. If these chips end up in some data center server, it might be that CPU hotplugging is used.

Well I didn't find anything about it. You can power off a CPU using the PMSU but not the clock itself. I guess that once you have power off the CPU the clock will be turned off as well.

Quoted 8 lines
Quoted 3 lines

But maybe it is cleaner to call clk_prepare_enable() even if it does nothing except update the usage count.

You also have to watch out for the late_initcall which will disable all clocks which are running but nobody has claimed. This will become an issue if you do have enable/disable function in later versions of the clock functions.

I don't think there will be enable/disable functions for the family clock currently used (armada-xp-cpu-clockctrl). But in future if a new version of mvebu SoC will use a new clock family which will have these functions, then it will be an issue. So to be future proof I will ad this call in the next version of the patch set.

Quoted 8 lines

Andrew

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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