SMP support for Armada XP
Subsystems (4)
v5 cover SMP support for Armada XP
Hello,
This version fixed a bug introduced by the move of set_cpu_coherency in assembly, it also fixed some typo and style issues.
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 the tag marvell-mvebu-clk-3.8 to ease the incoming git pull.
The git branch called ArmadaXP-SMP-for-3.8-V5 is also available at
https://github.com/MISL-EBU-System-SW/mainline-public.git.
Changelog:v4->V5:
- Rebased on to marvell-mvebu-clk-3.8
- Fixed bug in coherency_ll.S, use r2 instead of r4 as it can lead to unexpected crash if r4 is not restored properly.
- Fixed typo and improve assembly code in coherency_ll.S
- Use for_each_node_by_type instead of a while loop and of_find_node_by_type
V3->V4:
- Rebased on to v3.7-rc6
- the function to setup the coherency of the CPU is now share between SMP and coherency part and no more duplicate. Most of the code of headsmp.S have been moved in coherency_ll.S and the redundant code have been deleted from coherency.c.
- Fixed cosmetic inconsistency in code added to proc-v7, only macros are used and no more immediate values.
- Added reviewed-by and acked-by for the patch 4.
V2 -> V3:
- Rebased on to v3.7-rc5
- removed the unnecessary used of __iomem flag for a pointer to a function. the second parameter of armada_xp_boot_cpu is now just a void *.
- removed the dsb() call in armada_xp_boot_cpu(), as the following writel calls dsb if needed.
- Change the PJ4B mask for proc_info in arch/arm/mm/proc-v7.S to be less restrictive, the last 4 bits contain revision information
- Merge the multiple 'or' instruction in a single instruction in __v7_pj4b_setup
V1 -> V2:
- Rebased on to v3.7-rc3
- Fixed typos found by Alexandre Belloni
- Added clk_prepare_enable() before getting rate clk in set_secondary_cpus_clock()
- Add explanation in the binding documentation about the per-CPU interrupt registers: the address of the virtual register must be used.
- Removed the armada_xp prefix in the coherency.c file to be more compliant with the name convention of the other files.
- Coherency_init is now called from armada_370_xp_dt_init() and is no more an early_init() call. As the device tree is not available from an early_init(), it was useless to call coherency_init() so early. The need to be able to call some function very early during the boot were already resolved by using the hard code address of the register.
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-mpic.txt | 12 +- .../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 | 8 +- 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 | 3 + arch/arm/mach-mvebu/armada-370-xp.h | 7 ++ arch/arm/mach-mvebu/coherency.c | 80 +++++++++++++ arch/arm/mach-mvebu/coherency.h | 24 ++++ arch/arm/mach-mvebu/coherency_ll.S | 47 ++++++++ arch/arm/mach-mvebu/common.h | 6 + arch/arm/mach-mvebu/headsmp.S | 50 ++++++++ arch/arm/mach-mvebu/hotplug.c | 30 +++++ arch/arm/mach-mvebu/irq-armada-370-xp.c | 92 ++++++++++++++- arch/arm/mach-mvebu/platsmp.c | 121 ++++++++++++++++++++ arch/arm/mach-mvebu/pmsu.c | 75 ++++++++++++ arch/arm/mach-mvebu/pmsu.h | 16 +++ arch/arm/mm/Kconfig | 4 + arch/arm/mm/proc-v7.S | 66 +++++++++++ 22 files changed, 680 insertions(+), 12 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/coherency_ll.S 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
PATCH v5 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 | 80 ++++++++++++++++++++ arch/arm/mach-mvebu/coherency.h | 24 ++++++ arch/arm/mach-mvebu/coherency_ll.S | 47 ++++++++++++ arch/arm/mach-mvebu/common.h | 2 + 7 files changed, 175 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 create mode 100644 arch/arm/mach-mvebu/coherency_ll.S
Documentation/devicetree/bindings/arm/coherency-fabric.txt new file +16 -0
@@ -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
@@ -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
@@ -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 coherency_ll.o
arch/arm/mach-mvebu/coherency.c new file +80 -0
80 lines not on this page · raw message
arch/arm/mach-mvebu/coherency.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* 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 + +#ifdef CONFIG_SMP +int coherency_get_cpu_count (void ); +#endif + +int set_cpu_coherent (int cpu_id,int smp_group_id); +int coherency_init (void ); + +#endif /* __MACH_370_XP_COHERENCY_H */
arch/arm/mach-mvebu/coherency_ll.S new file +47 -0
47 lines not on this page · raw message
arch/arm/mach-mvebu/common.h +2 -0
@@ -20,4 +20,6 @@ void mvebu_restart(char mode, const char *cmd);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
PATCH v5 1/5 arm: mvebu: Added support for coherency fabric in mach-mvebu
Quoted 1 line · Gregory CLEMENT
From: Yehuda Yitschak <[email protected]>
<insert commit log here>
Also -- is the author attribution still correct?
Quoted 114 lines
Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Gregory CLEMENT <[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 | 80 ++++++++++++++++++++ arch/arm/mach-mvebu/coherency.h | 24 ++++++ arch/arm/mach-mvebu/coherency_ll.S | 47 ++++++++++++ arch/arm/mach-mvebu/common.h | 2 + 7 files changed, 175 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 create mode 100644 arch/arm/mach-mvebu/coherency_ll.SDocumentation/devicetree/bindings/arm/coherency-fabric.txt new file +16
-0@@ -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@@ -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@@ -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 coherency_ll.oarch/arm/mach-mvebu/coherency.c new file +44
-0@@ -0,0 +1,80 @@ +/* +* Coherency fabric (Aurora) support for Armada 370 and XP platforms. +* +* Copyright (C) 2012 Marvell +* +* Yehuda Yitschak <[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. +* +* The Armada 370 and Armada XP SOCs have a coherency fabric which is +* responsible for ensuring hardware coherency between all CPUs and between +* CPUs and I/O masters. This file initializes the coherency fabric and +* supplies basic routines for configuring and controlling hardware coherency +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/of_address.h> +#include <linux/io.h> +#include <linux/smp.h> +#include <asm/smp_plat.h> +#include "armada-370-xp.h" + +/* Some functions in this file are called very early during SMP +* initialization. At that time the device tree framework is not yet +* ready, and it is not possible to get the register address to +* ioremap it. That's why the pointer below is given with an initial +* value matching its virtual mapping +*/ +static void __iomem *coherency_base =ARMADA_370_XP_REGS_VIRT_BASE +0x20200 ; + +/* Coherency fabric registers */ +#define COHERENCY_FABRIC_CFG_OFFSET 0x4 + +static struct of_device_id of_coherency_table[] = { + {.compatible ="marvell,coherency-fabric" }, + {/* end of list */ }, +}; +#ifdef CONFIG_SMP +int coherency_get_cpu_count (void )
arch/arm/mach-mvebu/coherency.c line 54
Quoted 10 lines
arch/arm/mach-mvebu/coherency.c new file +10
-0+{ +int reg, cnt; + + reg =readl (coherency_base +COHERENCY_FABRIC_CFG_OFFSET ); + cnt = (reg &0xF ) +1 ; + +return cnt; +} +#endif +/* Function defined in coherncy_ll.S */
coherency_ll.S
arch/arm/mach-mvebu/coherency.c line 66
Quoted 12 lines
arch/arm/mach-mvebu/coherency.c new file +12
-0+extern void ll_set_cpu_coherent (void __iomem *base_addr, +unsigned int hw_cpu_id); + +int set_cpu_coherent (unsigned int hw_cpu_id,int smp_group_id) +{ +if (!coherency_base) { +pr_warn ("Can't make CPU %d cache coherent.\n" , hw_cpu_id); +pr_warn ("Coherency fabric is not initialized\n" ); +return 1 ; + } +ll_set_cpu_coherent (coherency_base, hw_cpu_id); +return 0 ;
You can just do return ll_set_cpu_coherent(...) now.
Quoted 83 lines
arch/arm/mach-mvebu/coherency.c new file +14
-0+} + +int __init coherency_init (void ) +{ +struct device_node *np; + + np =of_find_matching_node (NULL , of_coherency_table); +if (np) { +pr_info ("Initializing Coherency fabric\n" ); + coherency_base =of_iomap (np,0 ); + } + +return 0 ; +}arch/arm/mach-mvebu/coherency.h new file +24
-0@@ -0,0 +1,24 @@ +/* +* 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 + +#ifdef CONFIG_SMP +int coherency_get_cpu_count (void ); +#endif + +int set_cpu_coherent (int cpu_id,int smp_group_id); +int coherency_init (void ); + +#endif /* __MACH_370_XP_COHERENCY_H */ arch/arm/mach-mvebu/coherency_ll.S new file +33
-0@@ -0,0 +1,47 @@ +/* + * Coherency fabric: low level functions + * + * Copyright (C) 2012 Marvell + * + * Gregory CLEMENT <[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. + * + * This file implements the assembly function to add a CPU to the + * coherency fabric. This function is called by each of the secondary + * CPUs during their early boot in an SMP kernel, this why this + * function have to callable from assembly. It can also be called by a + * primary CPU from C code during its boot. + */ + +#include <linux/linkage.h> +#define ARMADA_XP_CFB_CTL_REG_OFFSET 0x0 +#define ARMADA_XP_CFB_CFG_REG_OFFSET 0x4 + + .text +/* + * r0: Coherency fabric base register address + * r1: HW CPU id + */ +ENTRY(ll_set_cpu_coherent) + /* Create bit by cpu index */ + mov r3, #(1 << 24) + lsl r1, r3, r1 + + /* Add CPU to SMP group - Atomic */
arch/arm/mach-mvebu/coherency_ll.S line 43
Quoted 10 lines
arch/arm/mach-mvebu/coherency_ll.S new file +10
-0+ add r3, r0, #ARMADA_XP_CFB_CTL_REG_OFFSET + ldr r2, [r3] + orr r2, r2, r1 + str r2, [r0] + + /* Enable coherency on CPU - Atomic */ + add r3, r0, #ARMADA_XP_CFB_CFG_REG_OFFSET + ldr r2, [r3] + orr r2, r2, r1 + str r2, [r3]
I forgot to mention this before, but do you need a dsb or something here?
Will
PATCH v5 1/5 arm: mvebu: Added support for coherency fabric in mach-mvebu
Quoted 6 lines · Will Deacon
Quoted 1 line · Gregory CLEMENT
From: Yehuda Yitschak <[email protected]>
<insert commit log here>
Also -- is the author attribution still correct?
I don't know: the code is based on Yehuda work, but version by version I modified it. So I don't know what is the rule for this.
Quoted 119 lines
Quoted 119 lines
Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Gregory CLEMENT <[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 | 80 ++++++++++++++++++++ arch/arm/mach-mvebu/coherency.h | 24 ++++++ arch/arm/mach-mvebu/coherency_ll.S | 47 ++++++++++++ arch/arm/mach-mvebu/common.h | 2 + 7 files changed, 175 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 create mode 100644 arch/arm/mach-mvebu/coherency_ll.SDocumentation/devicetree/bindings/arm/coherency-fabric.txt new file +16
-0@@ -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@@ -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@@ -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 coherency_ll.oarch/arm/mach-mvebu/coherency.c new file +48
-0@@ -0,0 +1,80 @@ +/* +* Coherency fabric (Aurora) support for Armada 370 and XP platforms. +* +* Copyright (C) 2012 Marvell +* +* Yehuda Yitschak <[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. +* +* The Armada 370 and Armada XP SOCs have a coherency fabric which is +* responsible for ensuring hardware coherency between all CPUs and between +* CPUs and I/O masters. This file initializes the coherency fabric and +* supplies basic routines for configuring and controlling hardware coherency +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/of_address.h> +#include <linux/io.h> +#include <linux/smp.h> +#include <asm/smp_plat.h> +#include "armada-370-xp.h" + +/* Some functions in this file are called very early during SMP +* initialization. At that time the device tree framework is not yet +* ready, and it is not possible to get the register address to +* ioremap it. That's why the pointer below is given with an initial +* value matching its virtual mapping +*/ +static void __iomem *coherency_base =ARMADA_370_XP_REGS_VIRT_BASE +0x20200 ; + +/* Coherency fabric registers */ +#define COHERENCY_FABRIC_CFG_OFFSET 0x4 + +static struct of_device_id of_coherency_table[] = { + {.compatible ="marvell,coherency-fabric" }, + {/* end of list */ }, +}; +#ifdef CONFIG_SMP +int coherency_get_cpu_count (void ) +{ +int reg, cnt; + + reg =readl (coherency_base +COHERENCY_FABRIC_CFG_OFFSET );
Quoted 8 lines
arch/arm/mach-mvebu/coherency.c line 54
Quoted 6 lines
arch/arm/mach-mvebu/coherency.c new file +6
-0+ cnt = (reg &0xF ) +1 ; + + return cnt; +} +#endif +/* Function defined in coherncy_ll.S */
coherency_ll.S
I knew I have to fix it, and I forgot
Quoted 15 lines
arch/arm/mach-mvebu/coherency.c line 66
Quoted 13 lines
arch/arm/mach-mvebu/coherency.c new file +12
-0+extern void ll_set_cpu_coherent (void __iomem *base_addr, +unsigned int hw_cpu_id); + +int set_cpu_coherent (unsigned int hw_cpu_id,int smp_group_id) +{ +if (!coherency_base) { +pr_warn ("Can't make CPU %d cache coherent.\n" , hw_cpu_id); +pr_warn ("Coherency fabric is not initialized\n" ); +return 1 ; + } +ll_set_cpu_coherent (coherency_base, hw_cpu_id); +return 0 ;You can just do return
ll_set_cpu_coherent(...)now.
Yes of course that was the plan.
Quoted 104 lines
Quoted 84 lines
arch/arm/mach-mvebu/coherency.c new file +14
-0+} + +int __init coherency_init (void ) +{ +struct device_node *np; + + np =of_find_matching_node (NULL , of_coherency_table); +if (np) { +pr_info ("Initializing Coherency fabric\n" ); + coherency_base =of_iomap (np,0 ); + } + +return 0 ; +}arch/arm/mach-mvebu/coherency.h new file +24
-0@@ -0,0 +1,24 @@ +/* +* 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 + +#ifdef CONFIG_SMP +int coherency_get_cpu_count (void ); +#endif + +int set_cpu_coherent (int cpu_id,int smp_group_id); +int coherency_init (void ); + +#endif /* __MACH_370_XP_COHERENCY_H */ arch/arm/mach-mvebu/coherency_ll.S new file +33
-0@@ -0,0 +1,47 @@ +/* + * Coherency fabric: low level functions + * + * Copyright (C) 2012 Marvell + * + * Gregory CLEMENT <[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. + * + * This file implements the assembly function to add a CPU to the + * coherency fabric. This function is called by each of the secondary + * CPUs during their early boot in an SMP kernel, this why this + * function have to callable from assembly. It can also be called by a + * primary CPU from C code during its boot. + */ + +#include <linux/linkage.h> +#define ARMADA_XP_CFB_CTL_REG_OFFSET 0x0 +#define ARMADA_XP_CFB_CFG_REG_OFFSET 0x4 + + .text +/* + * r0: Coherency fabric base register address + * r1: HW CPU id + */ +ENTRY(ll_set_cpu_coherent) + /* Create bit by cpu index */ + mov r3, #(1 << 24) + lsl r1, r3, r1 + + /* Add CPU to SMP group - Atomic */arch/arm/mach-mvebu/coherency_ll.S line 43
Quoted 10 lines
arch/arm/mach-mvebu/coherency_ll.S new file +10
-0+ add r3, r0, #ARMADA_XP_CFB_CTL_REG_OFFSET + ldr r2, [r3] + orr r2, r2, r1 + str r2, [r0] + + /* Enable coherency on CPU - Atomic */ + add r3, r0, #ARMADA_XP_CFB_CFG_REG_OFFSET + ldr r2, [r3] + orr r2, r2, r1 + str r2, [r3]I forgot to mention this before, but do you need a dsb or something here?
Will
_______________________________________________
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
PATCH v5 1/5 arm: mvebu: Added support for coherency fabric in mach-mvebu
In reply to Will DeaconQuoted 236 lines · Will Deacon
Quoted 1 line · Gregory CLEMENT
From: Yehuda Yitschak <[email protected]>
<insert commit log here>
Also -- is the author attribution still correct?
Quoted 114 lines
Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Gregory CLEMENT <[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 | 80 ++++++++++++++++++++ arch/arm/mach-mvebu/coherency.h | 24 ++++++ arch/arm/mach-mvebu/coherency_ll.S | 47 ++++++++++++ arch/arm/mach-mvebu/common.h | 2 + 7 files changed, 175 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 create mode 100644 arch/arm/mach-mvebu/coherency_ll.SDocumentation/devicetree/bindings/arm/coherency-fabric.txt new file +16
-0@@ -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@@ -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@@ -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 coherency_ll.oarch/arm/mach-mvebu/coherency.c new file +44
-0@@ -0,0 +1,80 @@ +/* +* Coherency fabric (Aurora) support for Armada 370 and XP platforms. +* +* Copyright (C) 2012 Marvell +* +* Yehuda Yitschak <[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. +* +* The Armada 370 and Armada XP SOCs have a coherency fabric which is +* responsible for ensuring hardware coherency between all CPUs and between +* CPUs and I/O masters. This file initializes the coherency fabric and +* supplies basic routines for configuring and controlling hardware coherency +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/of_address.h> +#include <linux/io.h> +#include <linux/smp.h> +#include <asm/smp_plat.h> +#include "armada-370-xp.h" + +/* Some functions in this file are called very early during SMP +* initialization. At that time the device tree framework is not yet +* ready, and it is not possible to get the register address to +* ioremap it. That's why the pointer below is given with an initial +* value matching its virtual mapping +*/ +static void __iomem *coherency_base =ARMADA_370_XP_REGS_VIRT_BASE +0x20200 ; + +/* Coherency fabric registers */ +#define COHERENCY_FABRIC_CFG_OFFSET 0x4 + +static struct of_device_id of_coherency_table[] = { + {.compatible ="marvell,coherency-fabric" }, + {/* end of list */ }, +}; +#ifdef CONFIG_SMP +int coherency_get_cpu_count (void )arch/arm/mach-mvebu/coherency.c line 54
Quoted 10 lines
arch/arm/mach-mvebu/coherency.c new file +10
-0+{ +int reg, cnt; + + reg =readl (coherency_base +COHERENCY_FABRIC_CFG_OFFSET ); + cnt = (reg &0xF ) +1 ; + +return cnt; +} +#endif +/* Function defined in coherncy_ll.S */
coherency_ll.Sarch/arm/mach-mvebu/coherency.c line 66
Quoted 12 lines
arch/arm/mach-mvebu/coherency.c new file +12
-0+extern void ll_set_cpu_coherent (void __iomem *base_addr, +unsigned int hw_cpu_id); + +int set_cpu_coherent (unsigned int hw_cpu_id,int smp_group_id) +{ +if (!coherency_base) { +pr_warn ("Can't make CPU %d cache coherent.\n" , hw_cpu_id); +pr_warn ("Coherency fabric is not initialized\n" ); +return 1 ; + } +ll_set_cpu_coherent (coherency_base, hw_cpu_id); +return 0 ;You can just do return
ll_set_cpu_coherent(...)now.Quoted 87 lines
arch/arm/mach-mvebu/coherency.c new file +14
-0+} + +int __init coherency_init (void ) +{ +struct device_node *np; + + np =of_find_matching_node (NULL , of_coherency_table); +if (np) { +pr_info ("Initializing Coherency fabric\n" ); + coherency_base =of_iomap (np,0 ); + } + +return 0 ; +}arch/arm/mach-mvebu/coherency.h new file +24
-0@@ -0,0 +1,24 @@ +/* +* 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 + +#ifdef CONFIG_SMP +int coherency_get_cpu_count (void ); +#endif + +int set_cpu_coherent (int cpu_id,int smp_group_id); +int coherency_init (void ); + +#endif /* __MACH_370_XP_COHERENCY_H */ arch/arm/mach-mvebu/coherency_ll.S new file +37
-0@@ -0,0 +1,47 @@ +/* + * Coherency fabric: low level functions + * + * Copyright (C) 2012 Marvell + * + * Gregory CLEMENT <[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. + * + * This file implements the assembly function to add a CPU to the + * coherency fabric. This function is called by each of the secondary + * CPUs during their early boot in an SMP kernel, this why this + * function have to callable from assembly. It can also be called by a + * primary CPU from C code during its boot. + */ + +#include <linux/linkage.h> +#define ARMADA_XP_CFB_CTL_REG_OFFSET 0x0 +#define ARMADA_XP_CFB_CFG_REG_OFFSET 0x4 + + .text +/* + * r0: Coherency fabric base register address + * r1: HW CPU id + */ +ENTRY(ll_set_cpu_coherent) + /* Create bit by cpu index */ + mov r3, #(1 << 24) + lsl r1, r3, r1 + + /* Add CPU to SMP group - Atomic */ + add r3, r0, #ARMADA_XP_CFB_CTL_REG_OFFSET + ldr r2, [r3] + orr r2, r2, r1 + str r2, [r0]
Quoted 8 lines
arch/arm/mach-mvebu/coherency_ll.S line 43
Quoted 6 lines
arch/arm/mach-mvebu/coherency_ll.S new file +6
-0+ + /* Enable coherency on CPU - Atomic */ + add r3, r0, #ARMADA_XP_CFB_CFG_REG_OFFSET + ldr r2, [r3] + orr r2, r2, r1 + str r2, [r3]I forgot to mention this before, but do you need a dsb or something here?
The answer from Marvell engineer:
"Especially for this case, DSB is not needed because we set the MMU to be such that these configurations are in SO memory space. However, I agree with the comment and believe that it would be good practice to add a DSB at the end of this sequence (and not rely on the fact that it they are not under DEVICE memory space)"
So in short I will add a dsb here.
Quoted 3 lines
Will
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v5 2/5 arm: mvebu: Added initial support for power managmement service unit
In reply to Gregory CLEMENTFrom: 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 | 75 ++++++++++++++++++++ arch/arm/mach-mvebu/pmsu.h | 16 +++++ 6 files changed, 119 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
@@ -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
@@ -27,6 +27,12 @@ <0xd0021870 0x58>; }; + armada-370-xp-pmsu at d0022000 { + compatible = "marvell,armada-370-xp-pmsu"; + reg = <0xd0022100 0x430>, + <0xd0020800 0x20>; + }; + soc { serial at d0012200 { compatible = "ns16550";
arch/arm/mach-mvebu/Makefile +1 -1
@@ -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 coherency_ll.o +obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o addr-map.o coherency.o coherency_ll.o pmsu.o
arch/arm/mach-mvebu/common.h +1 -0
@@ -22,4 +22,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 +75 -0
75 lines not on this page · raw message
arch/arm/mach-mvebu/pmsu.h new file +16 -0
@@ -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 *phys_addr); + +#endif /* __MACH_370_XP_PMSU_H */
Signature · 1 line
1.7.9.5
PATCH v5 3/5 arm: mvebu: Added IPI support via doorbells
In reply to Gregory CLEMENTFrom: Yehuda Yitschak <[email protected]>
--- .../devicetree/bindings/arm/armada-370-xp-mpic.txt | 12 ++- arch/arm/boot/dts/armada-xp.dtsi | 2 +- arch/arm/mach-mvebu/armada-370-xp.h | 7 ++ arch/arm/mach-mvebu/irq-armada-370-xp.c | 92 ++++++++++++++++++-- 4 files changed, 103 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/arm/armada-370-xp-mpic.txt +9 -3
@@ -6,9 +6,15 @@ Required properties: - interrupt-controller: Identifies the node as an interrupt controller. - #interrupt-cells: The number of cells to define the interrupts. Should be 1. The cell is the IRQ number + - reg: Should contain PMIC registers location and length. First pair for the main interrupt registers, second pair for the per-CPU - interrupt registers + interrupt registers. For this last pair, to be compliant with SMP + support, the "virtual" must be use (For the record, these registers + automatically map to the interrupt controller registers of the + current CPU) + + Example:
@@ -18,6 +24,6 @@ Example: #address-cells = <1>; #size-cells = <1>; interrupt-controller; - reg = <0xd0020000 0x1000>, - <0xd0021000 0x1000>; + reg = <0xd0020a00 0x1d0>, + <0xd0021070 0x58>; };
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>; }; armada-370-xp-pmsu at d0022000 {
arch/arm/mach-mvebu/armada-370-xp.h +7 -0
@@ -19,4 +19,11 @@#define ARMADA_370_XP_REGS_VIRT_BASE IOMEM(0xfeb00000)#define ARMADA_370_XP_REGS_SIZE SZ_1M +#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 /* __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
PATCH v5 4/5 arm: mm: Added support for PJ4B cpu and init routines
In reply to Gregory CLEMENTFrom: Yehuda Yitschak <[email protected]>
--- arch/arm/mach-mvebu/Kconfig | 2 +- arch/arm/mm/Kconfig | 4 +++ arch/arm/mm/proc-v7.S | 66 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-)
arch/arm/mach-mvebu/Kconfig +1 -1
@@ -21,7 +21,7 @@ menu "Marvell SOC with device tree" 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
@@ -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 +66 -0
78 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v5 5/5 arm: mvebu: Added SMP support for Armada XP
In reply to Gregory CLEMENTFrom: 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/configs/mvebu_defconfig | 3 + arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 2 + arch/arm/mach-mvebu/armada-370-xp.c | 3 + arch/arm/mach-mvebu/common.h | 3 + arch/arm/mach-mvebu/headsmp.S | 50 +++++++++++++++ arch/arm/mach-mvebu/hotplug.c | 30 +++++++++ arch/arm/mach-mvebu/platsmp.c | 121 +++++++++++++++++++++++++++++++++++ 8 files changed, 213 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/configs/mvebu_defconfig +3 -0
@@ -12,6 +12,9 @@ CONFIG_ARCH_MVEBU=y CONFIG_MACH_ARMADA_370=y CONFIG_MACH_ARMADA_XP=y # CONFIG_CACHE_L2X0 is not set +# CONFIG_SWP_EMULATE is not set +CONFIG_SMP=y +# CONFIG_LOCAL_TIMERS is not set CONFIG_AEABI=y CONFIG_HIGHMEM=y # CONFIG_COMPACTION is not set
arch/arm/mach-mvebu/Kconfig +1 -0
@@ -21,6 +21,7 @@ menu "Marvell SOC with device tree" 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
@@ -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 coherency_ll.o pmsu.o +obj-$(CONFIG_SMP) += platsmp.o headsmp.o +obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
arch/arm/mach-mvebu/armada-370-xp.c +3 -0
@@ -23,6 +23,7 @@#include <asm/mach/time.h> #include "armada-370-xp.h" #include "common.h" +#include "coherency.h" static struct map_desc armada_370_xp_io_desc[]__initdata = { {
@@ -51,6 +52,7 @@ struct sys_timer armada_370_xp_timer = {static void __init armada_370_xp_dt_init (void ) {of_platform_populate (NULL , of_default_bus_match_table,NULL ,NULL ); +coherency_init (); }static const char *const armada_370_xp_dt_board_dt_compat[] = {
@@ -60,6 +62,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
@@ -20,7 +20,10 @@ void mvebu_restart(char mode, const char *cmd);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 +50 -0
50 lines not on this page · raw message
arch/arm/mach-mvebu/hotplug.c new file +30 -0
@@ -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 +121 -0
121 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v5 5/5 arm: mvebu: Added SMP support for Armada XP
Quoted 5 lines · Gregory CLEMENT
From: Yehuda Yitschak <[email protected]>
1. added smp init functions in
platsmp.c
2. added secondary cpu entry point inheadsmp.S
3. added hotplog initial support inhotplug.c
hotplug
Quoted 1 line
4. added SMP support for PJ4B cpu
Again, I think the commit message could probably be improved from a numbered list...
Quoted 139 lines
Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Gregory CLEMENT <[email protected]>--- 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 | 3 + arch/arm/mach-mvebu/common.h | 3 + arch/arm/mach-mvebu/headsmp.S | 50 +++++++++++++++ arch/arm/mach-mvebu/hotplug.c | 30 +++++++++ arch/arm/mach-mvebu/platsmp.c | 121 +++++++++++++++++++++++++++++++++++ 8 files changed, 213 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.carch/arm/configs/mvebu_defconfig +3
-0@@ -12,6 +12,9 @@ CONFIG_ARCH_MVEBU=y CONFIG_MACH_ARMADA_370=y CONFIG_MACH_ARMADA_XP=y # CONFIG_CACHE_L2X0 is not set +# CONFIG_SWP_EMULATE is not set +CONFIG_SMP=y +# CONFIG_LOCAL_TIMERS is not set CONFIG_AEABI=y CONFIG_HIGHMEM=y # CONFIG_COMPACTION is not setarch/arm/mach-mvebu/Kconfig +1
-0@@ -21,6 +21,7 @@ menu "Marvell SOC with device tree" config MACH_ARMADA_370_XP bool select ARMADA_370_XP_TIMER + select HAVE_SMP select CPU_PJ4B config MACH_ARMADA_370arch/arm/mach-mvebu/Makefile +2
-0@@ -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 coherency_ll.o pmsu.o +obj-$(CONFIG_SMP) += platsmp.o headsmp.o +obj-$(CONFIG_HOTPLUG_CPU) += hotplug.oarch/arm/mach-mvebu/armada-370-xp.c +3
-0@@ -23,6 +23,7 @@#include <asm/mach/time.h> #include "armada-370-xp.h" #include "common.h" +#include "coherency.h" static struct map_desc armada_370_xp_io_desc[]__initdata = { {@@ -51,6 +52,7 @@ struct sys_timer armada_370_xp_timer = {static void __init armada_370_xp_dt_init (void ) {of_platform_populate (NULL , of_default_bus_match_table,NULL ,NULL ); +coherency_init (); }static const char *const armada_370_xp_dt_board_dt_compat[] = {@@ -60,6 +62,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@@ -20,7 +20,10 @@ void mvebu_restart(char mode, const char *cmd);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 +38
-0@@ -0,0 +1,50 @@ +/* + * SMP support: Entry point for secondary CPUs + * + * Copyright (C) 2012 Marvell + * + * Yehuda Yitschak <[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. + * + * This file implements the assembly entry point for secondary CPUs in + * an SMP kernel. The only thing we need to do is to add the CPU to + * the coherency fabric by writing to 2 registers. Currently the base + * register addresses are hard coded due to the early initialisation + * problems. + */ + +#include <linux/linkage.h> +#include <linux/init.h> + +/* + * At this stage the secondary CPUs don't have acces yet to the MMU, so + * we have to provide physical addresses + */ +#define ARMADA_XP_CFB_BASE 0xD0020200 + + __CPUINIT + +/* + * Armada XP specific entry point for secondary CPUs. + * We add the CPU to the coherency fabric and then jump to secondary + * startup + */ +ENTRY(armada_xp_secondary_startup) +
arch/arm/mach-mvebu/headsmp.S line 48
Quoted 10 lines
arch/arm/mach-mvebu/headsmp.S new file +10
-0+ /* Read CPU id */ + mrc p15, 0, r1, c0, c0, 5 + and r1, r1, #0xF + + /* Add CPU to coherency fabric */ + ldr r0, = ARMADA_XP_CFB_BASE + mov lr, pc + + b ll_set_cpu_coherent + b secondary_startup
Why didn't you use my adr suggestion here?
Will
PATCH v5 5/5 arm: mvebu: Added SMP support for Armada XP
Quoted 157 lines · Will Deacon
Quoted 5 lines · Gregory CLEMENT
From: Yehuda Yitschak <[email protected]>
1. added smp init functions in
platsmp.c
2. added secondary cpu entry point inheadsmp.S
3. added hotplog initial support inhotplug.chotplug
Quoted 1 line
4. added SMP support for PJ4B cpu
Again, I think the commit message could probably be improved from a numbered list...
Quoted 143 lines
Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Gregory CLEMENT <[email protected]>--- 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 | 3 + arch/arm/mach-mvebu/common.h | 3 + arch/arm/mach-mvebu/headsmp.S | 50 +++++++++++++++ arch/arm/mach-mvebu/hotplug.c | 30 +++++++++ arch/arm/mach-mvebu/platsmp.c | 121 +++++++++++++++++++++++++++++++++++ 8 files changed, 213 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.carch/arm/configs/mvebu_defconfig +3
-0@@ -12,6 +12,9 @@ CONFIG_ARCH_MVEBU=y CONFIG_MACH_ARMADA_370=y CONFIG_MACH_ARMADA_XP=y # CONFIG_CACHE_L2X0 is not set +# CONFIG_SWP_EMULATE is not set +CONFIG_SMP=y +# CONFIG_LOCAL_TIMERS is not set CONFIG_AEABI=y CONFIG_HIGHMEM=y # CONFIG_COMPACTION is not setarch/arm/mach-mvebu/Kconfig +1
-0@@ -21,6 +21,7 @@ menu "Marvell SOC with device tree" config MACH_ARMADA_370_XP bool select ARMADA_370_XP_TIMER + select HAVE_SMP select CPU_PJ4B config MACH_ARMADA_370arch/arm/mach-mvebu/Makefile +2
-0@@ -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 coherency_ll.o pmsu.o +obj-$(CONFIG_SMP) += platsmp.o headsmp.o +obj-$(CONFIG_HOTPLUG_CPU) += hotplug.oarch/arm/mach-mvebu/armada-370-xp.c +3
-0@@ -23,6 +23,7 @@#include <asm/mach/time.h> #include "armada-370-xp.h" #include "common.h" +#include "coherency.h" static struct map_desc armada_370_xp_io_desc[]__initdata = { {@@ -51,6 +52,7 @@ struct sys_timer armada_370_xp_timer = {static void __init armada_370_xp_dt_init (void ) {of_platform_populate (NULL , of_default_bus_match_table,NULL ,NULL ); +coherency_init (); }static const char *const armada_370_xp_dt_board_dt_compat[] = {@@ -60,6 +62,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@@ -20,7 +20,10 @@ void mvebu_restart(char mode, const char *cmd);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 +42
-0@@ -0,0 +1,50 @@ +/* + * SMP support: Entry point for secondary CPUs + * + * Copyright (C) 2012 Marvell + * + * Yehuda Yitschak <[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. + * + * This file implements the assembly entry point for secondary CPUs in + * an SMP kernel. The only thing we need to do is to add the CPU to + * the coherency fabric by writing to 2 registers. Currently the base + * register addresses are hard coded due to the early initialisation + * problems. + */ + +#include <linux/linkage.h> +#include <linux/init.h> + +/* + * At this stage the secondary CPUs don't have acces yet to the MMU, so + * we have to provide physical addresses + */ +#define ARMADA_XP_CFB_BASE 0xD0020200 + + __CPUINIT + +/* + * Armada XP specific entry point for secondary CPUs. + * We add the CPU to the coherency fabric and then jump to secondary + * startup + */ +ENTRY(armada_xp_secondary_startup) + + /* Read CPU id */ + mrc p15, 0, r1, c0, c0, 5 + and r1, r1, #0xF +
Quoted 8 lines
arch/arm/mach-mvebu/headsmp.S line 48
Quoted 6 lines
arch/arm/mach-mvebu/headsmp.S new file +6
-0+ /* Add CPU to coherency fabric */ + ldr r0, = ARMADA_XP_CFB_BASE + mov lr, pc + + b ll_set_cpu_coherent + b secondary_startupWhy didn't you use my adr suggestion here?
Because when I used BSYM(secondary_startup), I get the following message during compilation:
Error: undefined symbol secondary_startup used as an immediate value
And I didn't want to miss the merge window for something which could be fixed during the v3.8-rc1 if needed.
Quoted 3 lines
Will
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v5 5/5 arm: mvebu: Added SMP support for Armada XP
Quoted 21 lines · Gregory CLEMENT
Quoted 11 lines · Will Deacon
Quoted 11 lines
arch/arm/mach-mvebu/headsmp.S new file +11
-0+/* + * Armada XP specific entry point for secondary CPUs. + * We add the CPU to the coherency fabric and then jump to secondary + * startup + */ +ENTRY(armada_xp_secondary_startup) + + /* Read CPU id */ + mrc p15, 0, r1, c0, c0, 5 + and r1, r1, #0xF +Quoted 8 lines
arch/arm/mach-mvebu/headsmp.S line 48
Quoted 6 lines
arch/arm/mach-mvebu/headsmp.S new file +6
-0+ /* Add CPU to coherency fabric */ + ldr r0, = ARMADA_XP_CFB_BASE + mov lr, pc + + b ll_set_cpu_coherent + b secondary_startupWhy didn't you use my adr suggestion here?
Quoted 4 lines
Because when I used
BSYM(secondary_startup), I get the following message during compilation:Error: undefined symbol
secondary_startupused as an immediate value
Sorry, my mistake (I was thinking on my feet) since secondary_startup is declared in a C file, right? How about:
ldr lr, =secondary_startup
b ll_set_cpu_coherent
Quoted 2 lines
And I didn't want to miss the merge window for something which could be fixed during the v3.8-rc1 if needed.
Sure, but it also seems daft to merge something that's nine tenths of the way there when it's straight-forward to finish it off properly.
Will
PATCH v5 5/5 arm: mvebu: Added SMP support for Armada XP
Quoted 5 lines · Will Deacon
Sorry, my mistake (I was thinking on my feet) since
secondary_startupis declared in a C file, right? How about:ldr lr, =secondary_startup
bll_set_cpu_coherent
Why? Do we really want LR to be the _virtual_ address? No we don't, because secondary_startup expects to be called with the MMU off.
So I go back to my original comment. What's wrong with:
bl ll_set_cpu_coherent
b secondary_startup
?
PATCH v5 5/5 arm: mvebu: Added SMP support for Armada XP
Quoted 10 lines · Russell King - ARM Linux
Quoted 5 lines · Will Deacon
Sorry, my mistake (I was thinking on my feet) since
secondary_startupis declared in a C file, right? How about:ldr lr, =secondary_startup
bll_set_cpu_coherentWhy? Do we really want LR to be the _virtual_ address? No we don't, because
secondary_startupexpects to be called with the MMU off.
Quoted 6 lines
So I go back to my original comment. What's wrong with:
bl
ll_set_cpu_coherent
bsecondary_startup?
Nothing wrong, it works perfectly.
Whereas indeed the code proposed by Will didn't work very well. I will take Russell's suggestion.
Thanks,
Quoted 1 line
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v5 5/5 arm: mvebu: Added SMP support for Armada XP
Quoted 13 lines · Gregory CLEMENT
Quoted 12 lines · Russell King - ARM Linux
Quoted 5 lines · Will Deacon
Sorry, my mistake (I was thinking on my feet) since
secondary_startupis declared in a C file, right? How about:ldr lr, =secondary_startup
bll_set_cpu_coherentWhy? Do we really want LR to be the _virtual_ address? No we don't, because
secondary_startupexpects to be called with the MMU off.So I go back to my original comment. What's wrong with:
Quoted 8 lines
Quoted 4 lines
bl
ll_set_cpu_coherent
bsecondary_startup?
Nothing wrong, it works perfectly.
Whereas indeed the code proposed by Will didn't work very well. I will take Russell's suggestion.
Fine by me. Somehow I thought this was jumping into C but it's actually way earlier than that.
Sorry for the confusion,
Will
PATCH v5 5/5 arm: mvebu: Added SMP support for Armada XP
In reply to Gregory CLEMENTarch/arm/mach-mvebu/headsmp.S line 48
Quoted 12 lines · Gregory CLEMENT
arch/arm/mach-mvebu/headsmp.S new file +12
-0+ENTRY(armada_xp_secondary_startup) + + /* Read CPU id */ + mrc p15, 0, r1, c0, c0, 5 + and r1, r1, #0xF + + /* Add CPU to coherency fabric */ + ldr r0, = ARMADA_XP_CFB_BASE + mov lr, pc + + b ll_set_cpu_coherent + b secondary_startup
This looks odd. Why are you doing a mov lr,pc followed by a plain branch? What's wrong with 'bl' here ?