MCPM support for big.LITTLE Virtual Express RTSM
Subsystems (5)
cover MCPM support for big.LITTLE Virtual Express RTSM
This implements an MCPM backend for the Virtual Express b.L RTSM model.
This series was partially reviewed during previous posting of some components in the past, but some new parts were added to improve the whole thing.
Diffstat:
Documentation/devicetree/bindings/arm/cci.txt | 169 ++++++ .../devicetree/bindings/arm/rtsm-dcscb.txt | 19 + arch/arm/include/asm/cp15.h | 14 + arch/arm/mach-vexpress/Kconfig | 9 + arch/arm/mach-vexpress/Makefile | 1 + arch/arm/mach-vexpress/dcscb.c | 255 +++++++++ arch/arm/mach-vexpress/dcscb_setup.S | 38 ++ drivers/bus/Kconfig | 7 + drivers/bus/Makefile | 2 + drivers/bus/arm-cci.c | 529 ++++++++++++++++++ drivers/cpuidle/cpuidle-calxeda.c | 14 +- include/linux/arm-cci.h | 61 ++ 12 files changed, 1105 insertions(+), 13 deletions(-)
PATCH 1/8 drivers: bus: add ARM CCI support
From: Lorenzo Pieralisi <[email protected]>
On ARM multi-cluster systems coherency between cores running on different clusters is managed by the cache-coherent interconnect (CCI). It allows broadcasting of TLB invalidates and memory barriers and it guarantees cache coherency at system level through snooping of slave interfaces connected to it.
This patch enables the basic infrastructure required in Linux to handle and programme the CCI component.
Non-local variables used by the CCI management functions called by power down function calls after disabling the cache must be flushed out to main memory in advance, otherwise incoherency of those values may occur if they are sitting in the cache of some other CPU when power down functions execute. Driver code ensures that relevant data structures are flushed from inner and outer caches after the driver probe is completed.
CCI slave port resources are linked to set of CPUs through bus masters phandle properties that link the interface resources to masters node in the device tree.
Documentation describing the CCI DT bindings is provided with the patch.
--- Documentation/devicetree/bindings/arm/cci.txt | 169 ++++++++++ drivers/bus/Kconfig | 7 + drivers/bus/Makefile | 2 + drivers/bus/arm-cci.c | 426 ++++++++++++++++++++++++++ include/linux/arm-cci.h | 61 ++++ 5 files changed, 665 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/cci.txt create mode 100644 drivers/bus/arm-cci.c create mode 100644 include/linux/arm-cci.h
Documentation/devicetree/bindings/arm/cci.txt new file +169 -0
@@ -0,0 +1,169 @@ +======================================================= +ARM CCI cache coherent interconnect binding description +======================================================= + +ARM multi-cluster systems maintain intra-cluster coherency through a +cache coherent interconnect (CCI) that is capable of monitoring bus +transactions and manage coherency, TLB invalidations and memory barriers. + +It allows snooping and distributed virtual memory message broadcast across +clusters, through memory mapped interface, with a global control register +space and multiple sets of interface control registers, one per slave +interface. + +Bindings for the CCI node follow the ePAPR standard, available from: + +www.power.org/documentation/epapr-version-1-1/ + +with the addition of the bindings described in this document which are +specific to ARM. + +* CCI interconnect node + + Description: Describes a CCI cache coherent Interconnect component + + Node name must be "cci". + Node's parent must be the root node /, and the address space visible + through the CCI interconnect is the same as the one seen from the + root node (ie from CPUs perspective as per DT standard). + Every CCI node has to define the following properties: + + - compatible + Usage: required + Value type: <string> + Definition: must be set to + "arm,cci-400" + + - reg + Usage: required + Value type: <prop-encoded-array> + Definition: A standard property. Specifies base physical + address of CCI control registers common to all + interfaces. + + - ranges: + Usage: required + Value type: <prop-encoded-array> + Definition: A standard property. Follow rules in the ePAPR for + hierarchical bus addressing. CCI interfaces + addresses refer to the parent node addressing + scheme to declare their register bases. + + CCI interconnect node can define the following child nodes: + + - CCI control interface nodes + + Node name must be "slave-if". + Parent node must be CCI interconnect node. + + A CCI control interface node must contain the following + properties: + + - compatible + Usage: required + Value type: <string> + Definition: must be set to + "arm,cci-400-ctrl-if" + + - interface-type: + Usage: required + Value type: <string> + Definition: must be set to one of {"ace", "ace-lite"} + depending on the interface type the node + represents. + + - reg: + Usage: required + Value type: <prop-encoded-array> + Definition: the base address and size of the + corresponding interface programming + registers. + +* CCI interconnect bus masters + + Description: masters in the device tree connected to a CCI port + (inclusive of CPUs and their cpu nodes). + + A CCI interconnect bus master node must contain the following + properties: + + - cci-control-port: + Usage: required + Value type: <phandle> + Definition: a phandle containing the CCI control interface node + the master is connected to. + +Example: + + cpus { + #size-cells = <0>; + #address-cells = <1>; + + CPU0: cpu at 0 { + device_type = "cpu"; + compatible = "arm,cortex-a15"; + cci-control-port = <&cci_control1>; + reg = <0x0>; + }; + + CPU1: cpu at 1 { + device_type = "cpu"; + compatible = "arm,cortex-a15"; + cci-control-port = <&cci_control1>; + reg = <0x1>; + }; + + CPU2: cpu at 100 { + device_type = "cpu"; + compatible = "arm,cortex-a7"; + cci-control-port = <&cci_control2>; + reg = <0x100>; + }; + + CPU3: cpu at 101 { + device_type = "cpu"; + compatible = "arm,cortex-a7"; + cci-control-port = <&cci_control2>; + reg = <0x101>; + }; + + }; + + dma0: dma at 3000000 { + compatible = "arm,pl330", "arm,primecell"; + cci-control-port = <&cci_control0>; + reg = <0x0 0x3000000 0x0 0x1000>; + interrupts = <10>; + #dma-cells = <1>; + #dma-channels = <8>; + #dma-requests = <32>; + }; + + cci at 2c090000 { + compatible = "arm,cci-400"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x0 0x2c090000 0 0x1000>; + ranges = <0x0 0x0 0x2c090000 0x6000>; + + cci_control0: slave-if at 1000 { + interface-type = "ace-lite"; + reg = <0x1000 0x1000>; + }; + + cci_control1: slave-if at 4000 { + interface-type = "ace"; + reg = <0x4000 0x1000>; + }; + + cci_control2: slave-if at 5000 { + interface-type = "ace"; + reg = <0x5000 0x1000>; + }; + }; + +This CCI node corresponds to a CCI component whose control registers sits +at address 0x000000002c090000. +CCI slave interface @0x000000002c091000 is connected to dma controller dma0. +CCI slave interface @0x000000002c094000 is connected to CPUs {CPU0, CPU1}; +CCI slave interface @0x000000002c095000 is connected to CPUs {CPU2, CPU3};
drivers/bus/Kconfig +7 -0
@@ -26,4 +26,11 @@ config OMAP_INTERCONNECT help Driver to enable OMAP interconnect error handling driver. + +config ARM_CCI + bool "ARM CCI driver support" + depends on ARM + help + Driver supporting the CCI cache coherent interconnect for ARM + platforms. endmenu
drivers/bus/Makefile +2 -0
@@ -7,3 +7,5 @@ obj-$(CONFIG_OMAP_OCP2SCP) += omap-ocp2scp.o # Interconnect bus driver for OMAP SoCs. obj-$(CONFIG_OMAP_INTERCONNECT) += omap_l3_smx.o omap_l3_noc.o +# CCI cache coherent interconnect for ARM platforms +obj-$(CONFIG_ARM_CCI) += arm-cci.o
drivers/bus/arm-cci.c new file +426 -0
426 lines not on this page · raw message
include/linux/arm-cci.h new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 1/8 drivers: bus: add ARM CCI support
On Fri, 2013-05-24 at 01:45 -0400, Nicolas Pitre wrote:
[...]
Quoted 1 line
Documentation/devicetree/bindings/arm/cci.txt +0
-0
[...]
Quoted 12 lines
Documentation/devicetree/bindings/arm/cci.txt +12
-0+ cci at 2c090000 { + compatible = "arm,cci-400"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x0 0x2c090000 0 0x1000>; + ranges = <0x0 0x0 0x2c090000 0x6000>; + + cci_control0: slave-if at 1000 { + interface-type = "ace-lite"; + reg = <0x1000 0x1000>; + }; +
Documentation/devicetree/bindings/arm/cci.txt line 163
Quoted 10 lines
Documentation/devicetree/bindings/arm/cci.txt +10
-0+ cci_control1: slave-if at 4000 { + interface-type = "ace"; + reg = <0x4000 0x1000>; + }; + + cci_control2: slave-if at 5000 { + interface-type = "ace"; + reg = <0x5000 0x1000>; + }; + };
The above examples of slave-if nodes are missing the required compatible = "arm,cci-400-ctrl-if";
Signature · 1 line
Tixy
PATCH 1/8 drivers: bus: add ARM CCI support
Quoted 21 lines · Jon Medhurst (Tixy)
On Fri, 2013-05-24 at 01:45 -0400, Nicolas Pitre wrote:
[...]Quoted 1 line
Documentation/devicetree/bindings/arm/cci.txt +0
-0[...]
Quoted 17 lines
Documentation/devicetree/bindings/arm/cci.txt +17
-0+ cci at 2c090000 { + compatible = "arm,cci-400"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x0 0x2c090000 0 0x1000>; + ranges = <0x0 0x0 0x2c090000 0x6000>; + + cci_control0: slave-if at 1000 { + interface-type = "ace-lite"; + reg = <0x1000 0x1000>; + }; + + cci_control1: slave-if at 4000 { + interface-type = "ace"; + reg = <0x4000 0x1000>; + }; +
Quoted 8 lines
Documentation/devicetree/bindings/arm/cci.txt line 163
Quoted 5 lines
Documentation/devicetree/bindings/arm/cci.txt +5
-0+ cci_control2: slave-if at 5000 { + interface-type = "ace"; + reg = <0x5000 0x1000>; + }; + };The above examples of slave-if nodes are missing the required compatible = "arm,cci-400-ctrl-if";
Indeed. I'll fix that.
Nicolas
PATCH 2/8 drivers/bus: arm-cci: function to enable CCI ports from early boot code
In reply to Nicolas PitreThis provides cci_enable_port_for_self(). This is the counterpart to cci_disable_port_by_cpu(self).
This is meant to be called from the MCPM machine specific power_up_setup callback code when the appropriate affinity level needs to be initialized. The code therefore has to be position independent as the MMU is still off and it cannot rely on any stack space.
--- drivers/bus/arm-cci.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 109 insertions(+), 6 deletions(-)
drivers/bus/arm-cci.c +109 -6
@@ -43,6 +43,7 @@ enum cci_ace_port_type {struct cci_ace_port {void __iomem *base; +unsigned long phys;enum cci_ace_port_type type;struct device_node *dn; };
@@ -51,11 +52,13 @@ static struct cci_ace_port *ports;static unsigned int nb_cci_ports;static void __iomem *cci_ctrl_base; +static unsigned long cci_ctrl_phys;struct cpu_port {u64 mpidr;u32 port; }; +/* * Use the port MSB as valid flag, shift can be made dynamic * by computing number of bits required for port indexes.
@@ -230,6 +233,98 @@ int notrace cci_disable_port_by_cpu(u64 mpidr)EXPORT_SYMBOL_GPL (cci_disable_port_by_cpu);/** +* cci_enable_port_for_self() - function to enable a CCI port for calling CPU +* +* Enabling a CCI port for the calling CPU implies enabling the CCI +* port controlling that CPU cluster. Code enabling CPU CCI ports +* must make sure that the CPU running the code is the first active +* CPU in the cluster and all other CPUs are quiescent in a low power +* state or waiting for this CPU to complete the CCI initialization. +* +* Because this is called when the MMU is still off and with no stack, +* the code must be position independent and ideally rely on callee +* clobbered registers only. To achieve this we must code this function +* entirely in assembler. +* +* Return: +* 0 on success +* -ENODEV on port look-up failure +*/ +asmlinkage int __naked cci_enable_port_for_self(void) +{ + asmvolatile ("\n" + +" mrc p15, 0, r0, c0, c0, 5 @ get MPIDR value \n" +" and r0, r0, #"__stringify(MPIDR_HWID_BITMASK)" \n" +" adr r1, 5f \n" +" ldr r2, [r1] \n" +" add r1, r1, r2 @ &cpu_port \n" +" add ip, r1, %[sizeof_cpu_port] \n" + +/* Loop over the cpu_port array looking for a matching MPIDR */ +"1: ldr r2, [r1, %[offsetof_cpu_port_mpidr_lsb]] \n" +" cmp r2, r0 @ compare MPIDR \n" +" bne 2f \n" + +/* Found a match, now test port validity */ +" ldr r3, [r1, %[offsetof_cpu_port_port]] \n" +" tst r3, #"__stringify(PORT_VALID)" \n" +" bne 3f \n" + +/* no match, loop with the next cpu_port entry */ +"2: add r1, r1, %[sizeof_struct_cpu_port] \n" +" cmp r1, ip @ done? \n" +" blo 1b \n" +" mov r0, #"__stringify(-ENODEV)" \n" +" bx lr \n" + +/* Use matched port index to look up the corresponding ports entry */ +"3: bic r3, r3, #"__stringify(PORT_VALID)" \n" +" adr r0, 6f \n" +" ldmia r0, {r1, r2} \n" +" sub r1, r1, r0 @ virt - phys \n" +" ldr r0, [r0, r2] @ *(&ports) \n" +" mov r2, %[sizeof_struct_ace_port] \n" +" mla r0, r2, r3, r0 @ &ports[index] \n" +" sub r0, r0, r1 @ virt_to_phys() \n" + +/* Enable the CCI port */ +" ldr r0, [r0, %[offsetof_port_phys]] \n" +" mov r3, #"__stringify(CCI_ENABLE_REQ)" \n" +" str r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n" + +/* poll the status reg for completion */ +" adr r1, 7f \n" +" ldr r0, [r1] \n" +" ldr r0, [r0, r1] @ cci_ctrl_base \n" +"4: ldr r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n" +" tst r1, #1 \n" +" bne 4b \n" + +" mov r0, #0 \n" +" bx lr \n" + +" .align \n" +"5: .word cpu_port - . \n" +"6: .word . \n" +" .word ports - 6b \n" +"7: .word cci_ctrl_phys - . \n" + : : + [sizeof_cpu_port] "i" (sizeof(cpu_port)), +#ifndef __ARMEB__ + [offsetof_cpu_port_mpidr_lsb] "i" (offsetof(struct cpu_port, mpidr)), +#else + [offsetof_cpu_port_mpidr_lsb] "i" (offsetof(struct cpu_port, mpidr)+4), +#endif + [offsetof_cpu_port_port] "i" (offsetof(struct cpu_port, port)), + [sizeof_struct_cpu_port] "i" (sizeof(struct cpu_port)), + [sizeof_struct_ace_port] "i" (sizeof(struct cci_ace_port)), + [offsetof_port_phys] "i" (offsetof(struct cci_ace_port, phys)) ); + +unreachable (); +} + +/** * __cci_control_port_by_device() - function to control a CCI port by device * reference *
@@ -306,6 +401,7 @@ static int __init cci_probe(void)struct cci_nb_ports const *cci_config;int ret, i, nb_ace =0 , nb_ace_lite =0 ;struct device_node *np, *cp; +struct resource res;const char *match_str;bool is_ace;
@@ -323,9 +419,12 @@ static int __init cci_probe(void)if (!ports)return -ENOMEM ; - cci_ctrl_base =of_iomap (np,0 ); - -if (!cci_ctrl_base) { + ret =of_address_to_resource (np,0 , &res); +if (!ret) { + cci_ctrl_base =ioremap (res.start,resource_size (&res)); + cci_ctrl_phys = res.start; + } +if (ret || !cci_ctrl_base) {WARN (1 ,"unable to ioremap CCI ctrl\n" ); ret = -ENXIO ; goto memalloc_err;
@@ -353,9 +452,12 @@ static int __init cci_probe(void)continue ; } - ports[i].base =of_iomap (cp,0 ); - -if (!ports[i].base) { + ret =of_address_to_resource (cp,0 , &res); +if (!ret) { + ports[i].base =ioremap (res.start,resource_size (&res)); + ports[i].phys = res.start; + } +if (ret || !ports[i].base) {WARN (1 ,"unable to ioremap CCI port %d\n" , i);continue ; }
@@ -382,6 +484,7 @@ static int __init cci_probe(void)* cluster power-up/power-down. Make sure it reaches main memory. */ sync_cache_w (&cci_ctrl_base); +sync_cache_w (&cci_ctrl_phys);sync_cache_w (&ports);sync_cache_w (&cpu_port);__sync_cache_range_w (ports,sizeof (*ports) * nb_cci_ports);
Signature · 1 line
1.8.1.2
PATCH 2/8 drivers/bus: arm-cci: function to enable CCI ports from early boot code
Quoted 7 lines · Nicolas Pitre
This provides
cci_enable_port_for_self(). This is the counterpart tocci_disable_port_by_cpu(self).This is meant to be called from the MCPM machine specific
power_up_setupcallback code when the appropriate affinity level needs to be initialized. The code therefore has to be position independent as the MMU is still off and it cannot rely on any stack space.
This seems a fair starting point. There may be some aspects that can be optimised later.
Quoted 181 lines
Signed-off-by Nicolas Pitre <[email protected]>--- drivers/bus/arm-cci.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 109 insertions(+), 6 deletions(-)drivers/bus/arm-cci.c +109
-6@@ -43,6 +43,7 @@ enum cci_ace_port_type {struct cci_ace_port {void __iomem *base; +unsigned long phys;enum cci_ace_port_type type;struct device_node *dn; };@@ -51,11 +52,13 @@ static struct cci_ace_port *ports;static unsigned int nb_cci_ports;static void __iomem *cci_ctrl_base; +static unsigned long cci_ctrl_phys;struct cpu_port {u64 mpidr;u32 port; }; +/* * Use the port MSB as valid flag, shift can be made dynamic * by computing number of bits required for port indexes. @@ -230,6 +233,98 @@ int notrace cci_disable_port_by_cpu(u64 mpidr)EXPORT_SYMBOL_GPL (cci_disable_port_by_cpu);/** +* cci_enable_port_for_self() - function to enable a CCI port for calling CPU +* +* Enabling a CCI port for the calling CPU implies enabling the CCI +* port controlling that CPU cluster. Code enabling CPU CCI ports +* must make sure that the CPU running the code is the first active +* CPU in the cluster and all other CPUs are quiescent in a low power +* state or waiting for this CPU to complete the CCI initialization. +* +* Because this is called when the MMU is still off and with no stack, +* the code must be position independent and ideally rely on callee +* clobbered registers only. To achieve this we must code this function +* entirely in assembler. +* +* Return: +* 0 on success +* -ENODEV on port look-up failure +*/ +asmlinkage int __naked cci_enable_port_for_self(void) +{ + asmvolatile ("\n" + +" mrc p15, 0, r0, c0, c0, 5 @ get MPIDR value \n" +" and r0, r0, #"__stringify(MPIDR_HWID_BITMASK)" \n" +" adr r1, 5f \n" +" ldr r2, [r1] \n" +" add r1, r1, r2 @ &cpu_port \n" +" add ip, r1, %[sizeof_cpu_port] \n" + +/* Loop over the cpu_port array looking for a matching MPIDR */ +"1: ldr r2, [r1, %[offsetof_cpu_port_mpidr_lsb]] \n" +" cmp r2, r0 @ compare MPIDR \n" +" bne 2f \n" + +/* Found a match, now test port validity */ +" ldr r3, [r1, %[offsetof_cpu_port_port]] \n" +" tst r3, #"__stringify(PORT_VALID)" \n" +" bne 3f \n" + +/* no match, loop with the next cpu_port entry */ +"2: add r1, r1, %[sizeof_struct_cpu_port] \n" +" cmp r1, ip @ done? \n" +" blo 1b \n" +" mov r0, #"__stringify(-ENODEV)" \n" +" bx lr \n" + +/* Use matched port index to look up the corresponding ports entry */ +"3: bic r3, r3, #"__stringify(PORT_VALID)" \n" +" adr r0, 6f \n" +" ldmia r0, {r1, r2} \n" +" sub r1, r1, r0 @ virt - phys \n" +" ldr r0, [r0, r2] @ *(&ports) \n" +" mov r2, %[sizeof_struct_ace_port] \n" +" mla r0, r2, r3, r0 @ &ports[index] \n" +" sub r0, r0, r1 @ virt_to_phys() \n" + +/* Enable the CCI port */ +" ldr r0, [r0, %[offsetof_port_phys]] \n" +" mov r3, #"__stringify(CCI_ENABLE_REQ)" \n" +" str r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n" + +/* poll the status reg for completion */ +" adr r1, 7f \n" +" ldr r0, [r1] \n" +" ldr r0, [r0, r1] @ cci_ctrl_base \n" +"4: ldr r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n" +" tst r1, #1 \n" +" bne 4b \n" + +" mov r0, #0 \n" +" bx lr \n" + +" .align \n" +"5: .word cpu_port - . \n" +"6: .word . \n" +" .word ports - 6b \n" +"7: .word cci_ctrl_phys - . \n" + : : + [sizeof_cpu_port] "i" (sizeof(cpu_port)), +#ifndef __ARMEB__ + [offsetof_cpu_port_mpidr_lsb] "i" (offsetof(struct cpu_port, mpidr)), +#else + [offsetof_cpu_port_mpidr_lsb] "i" (offsetof(struct cpu_port, mpidr)+4), +#endif + [offsetof_cpu_port_port] "i" (offsetof(struct cpu_port, port)), + [sizeof_struct_cpu_port] "i" (sizeof(struct cpu_port)), + [sizeof_struct_ace_port] "i" (sizeof(struct cci_ace_port)), + [offsetof_port_phys] "i" (offsetof(struct cci_ace_port, phys)) ); + +unreachable (); +} + +/** * __cci_control_port_by_device() - function to control a CCI port by device * reference * @@ -306,6 +401,7 @@ static int __init cci_probe(void)struct cci_nb_ports const *cci_config;int ret, i, nb_ace =0 , nb_ace_lite =0 ;struct device_node *np, *cp; +struct resource res;const char *match_str;bool is_ace;@@ -323,9 +419,12 @@ static int __init cci_probe(void)if (!ports)return -ENOMEM ; - cci_ctrl_base =of_iomap (np,0 ); - -if (!cci_ctrl_base) { + ret =of_address_to_resource (np,0 , &res); +if (!ret) { + cci_ctrl_base =ioremap (res.start,resource_size (&res)); + cci_ctrl_phys = res.start; + } +if (ret || !cci_ctrl_base) {WARN (1 ,"unable to ioremap CCI ctrl\n" ); ret = -ENXIO ; goto memalloc_err;@@ -353,9 +452,12 @@ static int __init cci_probe(void)continue ; } - ports[i].base =of_iomap (cp,0 ); - -if (!ports[i].base) { + ret =of_address_to_resource (cp,0 , &res); +if (!ret) { + ports[i].base =ioremap (res.start,resource_size (&res)); + ports[i].phys = res.start; + } +if (ret || !ports[i].base) {WARN (1 ,"unable to ioremap CCI port %d\n" , i);continue ; }@@ -382,6 +484,7 @@ static int __init cci_probe(void)* cluster power-up/power-down. Make sure it reaches main memory. */ sync_cache_w (&cci_ctrl_base); +sync_cache_w (&cci_ctrl_phys);sync_cache_w (&ports);sync_cache_w (&cpu_port);__sync_cache_range_w (ports,sizeof (*ports) * nb_cci_ports);Signature · 1 line
1.8.1.2
PATCH 3/8 ARM: introduce common set_auxcr/get_auxcr functions
In reply to Nicolas PitreFrom: Rob Herring <[email protected]>
Move the private set_auxcr/get_auxcr functions from drivers/cpuidle/cpuidle-calxeda.c so they can be used across platforms.
--- arch/arm/include/asm/cp15.h | 14 ++++++++++++++ drivers/cpuidle/cpuidle-calxeda.c | 14 +------------- 2 files changed, 15 insertions(+), 13 deletions(-)
arch/arm/include/asm/cp15.h +14 -0
@@ -61,6 +61,20 @@ static inline void set_cr(unsigned int val)isb (); } +static inline unsigned int get_auxcr (void ) +{ +unsigned int val; + asm("mrc p15, 0, %0, c1, c0, 1 @ get AUXCR" :"=r" (val)); +return val; +} + +static inline void set_auxcr (unsigned int val) +{ + asmvolatile ("mcr p15, 0, %0, c1, c0, 1 @ set AUXCR" + : :"r" (val)); +isb (); +} +#ifndef CONFIG_SMP extern void adjust_cr (unsigned long mask,unsigned long set);#endif
drivers/cpuidle/cpuidle-calxeda.c +1 -13
@@ -37,19 +37,7 @@extern void highbank_set_cpu_jump (int cpu,void *jump_addr);extern void *scu_base_addr; -static inline unsigned int get_auxcr (void ) -{ -unsigned int val; - asm("mrc p15, 0, %0, c1, c0, 1 @ get AUXCR" :"=r" (val) : :"cc" ); -return val; -} - -static inline void set_auxcr (unsigned int val) -{ - asmvolatile ("mcr p15, 0, %0, c1, c0, 1 @ set AUXCR" - : :"r" (val) :"cc" ); -isb (); -} +static struct cpuidle_device __percpu *calxeda_idle_cpuidle_devices; static noinline void calxeda_idle_restore(void) {
Signature · 1 line
1.8.1.2
PATCH 3/8 ARM: introduce common set_auxcr/get_auxcr functions
Quoted 53 lines · Nicolas Pitre
From: Rob Herring <[email protected]>
Move the private set_auxcr/get_auxcr functions from
drivers/cpuidle/cpuidle-calxeda.cso they can be used across platforms.Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Signed-off-by Nicolas Pitre <[email protected]>Acked-by Tony Lindgren <[email protected]>Reviewed-by Will Deacon <[email protected]>--- arch/arm/include/asm/cp15.h | 14 ++++++++++++++ drivers/cpuidle/cpuidle-calxeda.c | 14 +------------- 2 files changed, 15 insertions(+), 13 deletions(-)arch/arm/include/asm/cp15.h +14
-0@@ -61,6 +61,20 @@ static inline void set_cr(unsigned int val)isb (); } +static inline unsigned int get_auxcr (void ) +{ +unsigned int val; + asm("mrc p15, 0, %0, c1, c0, 1 @ get AUXCR" :"=r" (val)); +return val; +} + +static inline void set_auxcr (unsigned int val) +{ + asmvolatile ("mcr p15, 0, %0, c1, c0, 1 @ set AUXCR" + : :"r" (val)); +isb (); +} +#ifndef CONFIG_SMP extern void adjust_cr (unsigned long mask,unsigned long set);#endif drivers/cpuidle/cpuidle-calxeda.c +0
-4@@ -37,19 +37,7 @@extern void highbank_set_cpu_jump (int cpu,void *jump_addr);extern void *scu_base_addr; -static inline unsigned int get_auxcr (void ) -{ -unsigned int val; - asm("mrc p15, 0, %0, c1, c0, 1 @ get AUXCR" :"=r" (val) : :"cc" );
drivers/cpuidle/cpuidle-calxeda.c line 40
Quoted 10 lines
drivers/cpuidle/cpuidle-calxeda.c +1
-9-return val; -} - -static inline void set_auxcr (unsigned int val) -{ - asmvolatile ("mcr p15, 0, %0, c1, c0, 1 @ set AUXCR" - : :"r" (val) :"cc" ); -isb (); -} +static struct cpuidle_device __percpu *calxeda_idle_cpuidle_devices;
The added line above looks like a merge error to me.
Quoted 2 lines
drivers/cpuidle/cpuidle-calxeda.c +0
-0static noinline void calxeda_idle_restore(void) {
Signature · 1 line
Tixy
PATCH 3/8 ARM: introduce common set_auxcr/get_auxcr functions
Quoted 50 lines · Jon Medhurst (Tixy)
Quoted 49 lines · Nicolas Pitre
From: Rob Herring <[email protected]>
Move the private set_auxcr/get_auxcr functions from
drivers/cpuidle/cpuidle-calxeda.cso they can be used across platforms.Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Signed-off-by Nicolas Pitre <[email protected]>Acked-by Tony Lindgren <[email protected]>Reviewed-by Will Deacon <[email protected]>--- arch/arm/include/asm/cp15.h | 14 ++++++++++++++ drivers/cpuidle/cpuidle-calxeda.c | 14 +------------- 2 files changed, 15 insertions(+), 13 deletions(-)arch/arm/include/asm/cp15.h +14
-0@@ -61,6 +61,20 @@ static inline void set_cr(unsigned int val)isb (); } +static inline unsigned int get_auxcr (void ) +{ +unsigned int val; + asm("mrc p15, 0, %0, c1, c0, 1 @ get AUXCR" :"=r" (val)); +return val; +} + +static inline void set_auxcr (unsigned int val) +{ + asmvolatile ("mcr p15, 0, %0, c1, c0, 1 @ set AUXCR" + : :"r" (val)); +isb (); +} +#ifndef CONFIG_SMP extern void adjust_cr (unsigned long mask,unsigned long set);#endif drivers/cpuidle/cpuidle-calxeda.c +0
-0@@ -37,19 +37,7 @@extern void highbank_set_cpu_jump (int cpu,void *jump_addr);extern void *scu_base_addr;
Quoted 16 lines
Quoted 4 lines
drivers/cpuidle/cpuidle-calxeda.c +0
-4-static inline unsigned int get_auxcr (void ) -{ -unsigned int val; - asm("mrc p15, 0, %0, c1, c0, 1 @ get AUXCR" :"=r" (val) : :"cc" );drivers/cpuidle/cpuidle-calxeda.c line 40
Quoted 10 lines
drivers/cpuidle/cpuidle-calxeda.c +1
-9-return val; -} - -static inline void set_auxcr (unsigned int val) -{ - asmvolatile ("mcr p15, 0, %0, c1, c0, 1 @ set AUXCR" - : :"r" (val) :"cc" ); -isb (); -} +static struct cpuidle_device __percpu *calxeda_idle_cpuidle_devices;The added line above looks like a merge error to me.
Yep, good catch.
Nicolas
PATCH 4/8 ARM: vexpress: introduce DCSCB support
In reply to Nicolas PitreThis adds basic CPU and cluster reset controls on RTSM for the A15x4-A7x4 model configuration using the Dual Cluster System Configuration Block (DCSCB).
The cache coherency interconnect (CCI) is not handled yet.
--- .../devicetree/bindings/arm/rtsm-dcscb.txt | 19 +++ arch/arm/mach-vexpress/Kconfig | 8 + arch/arm/mach-vexpress/Makefile | 1 + arch/arm/mach-vexpress/dcscb.c | 162 +++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/rtsm-dcscb.txt create mode 100644 arch/arm/mach-vexpress/dcscb.c
Documentation/devicetree/bindings/arm/rtsm-dcscb.txt new file +19 -0
@@ -0,0 +1,19 @@ +ARM Dual Cluster System Configuration Block +------------------------------------------- + +The Dual Cluster System Configuration Block (DCSCB) provides basic +functionality for controlling clocks, resets and configuration pins in +the Dual Cluster System implemented by the Real-Time System Model (RTSM). + +Required properties: + +- compatible : should be "arm,rtsm,dcscb" + +- reg : physical base address and the size of the registers window + +Example: + + dcscb at 60000000 { + compatible = "arm,rtsm,dcscb"; + reg = <0x60000000 0x1000>; + };
arch/arm/mach-vexpress/Kconfig +8 -0
@@ -57,4 +57,12 @@ config ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA config ARCH_VEXPRESS_CA9X4 bool "Versatile Express Cortex-A9x4 tile" +config ARCH_VEXPRESS_DCSCB + bool "Dual Cluster System Control Block (DCSCB) support" + depends on MCPM + help + Support for the Dual Cluster System Configuration Block (DCSCB). + This is needed to provide CPU and cluster power management + on RTSM implementing big.LITTLE. + endmenu
arch/arm/mach-vexpress/Makefile +1 -0
@@ -6,5 +6,6 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include \ obj-y := v2m.o obj-$(CONFIG_ARCH_VEXPRESS_CA9X4) += ct-ca9x4.o +obj-$(CONFIG_ARCH_VEXPRESS_DCSCB) += dcscb.o obj-$(CONFIG_SMP) += platsmp.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
arch/arm/mach-vexpress/dcscb.c new file +162 -0
162 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 5/8 ARM: vexpress/dcscb: add CPU use counts to the power up/down API implementation
In reply to Nicolas PitreIt is possible for a CPU to be told to power up before it managed to power itself down. Solve this race with a usage count to deal with this possibility as mandated by the MCPM API definition.
--- arch/arm/mach-vexpress/dcscb.c | 74 +++++++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 15 deletions(-)
arch/arm/mach-vexpress/dcscb.c +59 -15
@@ -44,6 +44,7 @@static arch_spinlock_t dcscb_lock = __ARCH_SPIN_LOCK_UNLOCKED;static void __iomem *dcscb_base; +static int dcscb_use_count[4 ][2 ];static int dcscb_power_up (unsigned int cpu,unsigned int cluster) {
@@ -60,14 +61,27 @@ static int dcscb_power_up(unsigned int cpu, unsigned int cluster)local_irq_disable ();arch_spin_lock (&dcscb_lock); - rst_hold =readl_relaxed (dcscb_base +RST_HOLD0 + cluster *4 ); -if (rst_hold & (1 <<8 )) { -/* remove cluster reset and add individual CPU's reset */ - rst_hold &= ~(1 <<8 ); - rst_hold |=0xf ; + dcscb_use_count[cpu][cluster]++; +if (dcscb_use_count[cpu][cluster] ==1 ) { + rst_hold =readl_relaxed (dcscb_base +RST_HOLD0 + cluster *4 ); +if (rst_hold & (1 <<8 )) { +/* remove cluster reset and add individual CPU's reset */ + rst_hold &= ~(1 <<8 ); + rst_hold |=0xf ; + } + rst_hold &= ~(cpumask | (cpumask <<4 )); +writel_relaxed (rst_hold, dcscb_base +RST_HOLD0 + cluster *4 ); + }else if (dcscb_use_count[cpu][cluster] !=2 ) { +/* +* The only possible values are: +* 0 = CPU down +* 1 = CPU (still) up +* 2 = CPU requested to be up before it had a chance +* to actually make itself down. +* Any other value is a bug. +*/ +BUG (); } - rst_hold &= ~(cpumask | (cpumask <<4 )); -writel_relaxed (rst_hold, dcscb_base +RST_HOLD0 + cluster *4 );arch_spin_unlock (&dcscb_lock);local_irq_enable ();
@@ -77,7 +91,8 @@ static int dcscb_power_up(unsigned int cpu, unsigned int cluster)static void dcscb_power_down (void ) { -unsigned int mpidr, cpu, cluster, rst_hold, cpumask, last_man; +unsigned int mpidr, cpu, cluster, rst_hold, cpumask; +bool last_man = false, skip_wfi = false; mpidr =read_cpuid_mpidr (); cpu =MPIDR_AFFINITY_LEVEL (mpidr,0 );
@@ -88,13 +103,26 @@ static void dcscb_power_down(void)BUG_ON (cpu >=4 || cluster >=2 );arch_spin_lock (&dcscb_lock); - rst_hold =readl_relaxed (dcscb_base +RST_HOLD0 + cluster *4 ); - rst_hold |= cpumask; -if (((rst_hold | (rst_hold >>4 )) &0xf ) ==0xf ) - rst_hold |= (1 <<8 ); -writel_relaxed (rst_hold, dcscb_base +RST_HOLD0 + cluster *4 ); + dcscb_use_count[cpu][cluster]--; +if (dcscb_use_count[cpu][cluster] ==0 ) { + rst_hold =readl_relaxed (dcscb_base +RST_HOLD0 + cluster *4 ); + rst_hold |= cpumask; +if (((rst_hold | (rst_hold >>4 )) &0xf ) ==0xf ) { + rst_hold |= (1 <<8 ); + last_man = true; + } +writel_relaxed (rst_hold, dcscb_base +RST_HOLD0 + cluster *4 ); + }else if (dcscb_use_count[cpu][cluster] ==1 ) { +/* +* A power_up request went ahead of us. +* Even if we do not want to shut this CPU down, +* the caller expects a certain state as if the WFI +* was aborted. So let's continue with cache cleaning. +*/ + skip_wfi = true; + }else +BUG ();arch_spin_unlock (&dcscb_lock); - last_man = (rst_hold & (1 <<8 ));/* * Now let's clean our L1 cache and shut ourself down.
@@ -122,7 +150,8 @@ static void dcscb_power_down(void)/* Now we are prepared for power-down, do it: */ dsb (); -wfi (); +if (!skip_wfi) +wfi ();/* Not dead@this point? Let our caller cope. */ }
@@ -132,6 +161,19 @@ static const struct mcpm_platform_ops dcscb_power_ops = { .power_down = dcscb_power_down, }; +static void __init dcscb_usage_count_init (void ) +{ +unsigned int mpidr, cpu, cluster; + + mpidr =read_cpuid_mpidr (); + cpu =MPIDR_AFFINITY_LEVEL (mpidr,0 ); + cluster =MPIDR_AFFINITY_LEVEL (mpidr,1 ); + +pr_debug ("%s: cpu %u cluster %u\n" , __func__, cpu, cluster); +BUG_ON (cpu >=4 || cluster >=2 ); + dcscb_use_count[cpu][cluster] =1 ; +} +static int __init dcscb_init (void ) {struct device_node *node;
@@ -144,6 +186,8 @@ static int __init dcscb_init(void)if (!dcscb_base)return -EADDRNOTAVAIL ; +dcscb_usage_count_init (); + ret =mcpm_platform_register (&dcscb_power_ops);if (ret) {iounmap (dcscb_base);
Signature · 1 line
1.8.1.2
PATCH 6/8 ARM: vexpress/dcscb: do not hardcode number of CPUs per cluster
In reply to Nicolas PitreIf 4 CPUs are assumed, the A15x1-A7x1 model configuration would never shut down the initial cluster as the 0xf reset bit mask will never be observed. Let's construct this mask based on the provided information in the DCSCB config register for the number of CPUs per cluster.
--- arch/arm/mach-vexpress/dcscb.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
arch/arm/mach-vexpress/dcscb.c +10 -4
@@ -45,10 +45,12 @@ static arch_spinlock_t dcscb_lock = __ARCH_SPIN_LOCK_UNLOCKED;static void __iomem *dcscb_base;static int dcscb_use_count[4 ][2 ]; +static int dcscb_mcpm_cpu_mask[2 ];static int dcscb_power_up (unsigned int cpu,unsigned int cluster) {unsigned int rst_hold, cpumask = (1 << cpu); +unsigned int mcpm_mask = dcscb_mcpm_cpu_mask[cluster];pr_debug ("%s: cpu %u cluster %u\n" , __func__, cpu, cluster);if (cpu >=4 || cluster >=2 )
@@ -67,7 +69,7 @@ static int dcscb_power_up(unsigned int cpu, unsigned int cluster)if (rst_hold & (1 <<8 )) {/* remove cluster reset and add individual CPU's reset */ rst_hold &= ~(1 <<8 ); - rst_hold |=0xf ; + rst_hold |= mcpm_mask; } rst_hold &= ~(cpumask | (cpumask <<4 ));writel_relaxed (rst_hold, dcscb_base +RST_HOLD0 + cluster *4 );
@@ -91,13 +93,14 @@ static int dcscb_power_up(unsigned int cpu, unsigned int cluster)static void dcscb_power_down (void ) { -unsigned int mpidr, cpu, cluster, rst_hold, cpumask; +unsigned int mpidr, cpu, cluster, rst_hold, cpumask, mcpm_mask;bool last_man = false, skip_wfi = false; mpidr =read_cpuid_mpidr (); cpu =MPIDR_AFFINITY_LEVEL (mpidr,0 ); cluster =MPIDR_AFFINITY_LEVEL (mpidr,1 ); cpumask = (1 << cpu); + mcpm_mask = dcscb_mcpm_cpu_mask[cluster];pr_debug ("%s: cpu %u cluster %u\n" , __func__, cpu, cluster);BUG_ON (cpu >=4 || cluster >=2 );
@@ -107,7 +110,7 @@ static void dcscb_power_down(void)if (dcscb_use_count[cpu][cluster] ==0 ) { rst_hold =readl_relaxed (dcscb_base +RST_HOLD0 + cluster *4 ); rst_hold |= cpumask; -if (((rst_hold | (rst_hold >>4 )) &0xf ) ==0xf ) { +if (((rst_hold | (rst_hold >>4 )) & mcpm_mask) == mcpm_mask) { rst_hold |= (1 <<8 ); last_man = true; }
@@ -177,6 +180,7 @@ static void __init dcscb_usage_count_init(void)static int __init dcscb_init (void ) {struct device_node *node; +unsigned int cfg;int ret; node =of_find_compatible_node (NULL ,NULL ,"arm,rtsm,dcscb" );
@@ -185,7 +189,9 @@ static int __init dcscb_init(void) dcscb_base =of_iomap (node,0 );if (!dcscb_base)return -EADDRNOTAVAIL ; - + cfg =readl_relaxed (dcscb_base +DCS_CFG_R ); + dcscb_mcpm_cpu_mask[0 ] = (1 << (((cfg >>16 ) >> (0 <<2 )) &0xf )) -1 ; + dcscb_mcpm_cpu_mask[1 ] = (1 << (((cfg >>16 ) >> (1 <<2 )) &0xf )) -1 ;dcscb_usage_count_init (); ret =mcpm_platform_register (&dcscb_power_ops);
Signature · 1 line
1.8.1.2
PATCH 7/8 ARM: vexpress/dcscb: handle platform coherency exit/setup and CCI
In reply to Nicolas PitreFrom: Dave Martin <[email protected]>
Add the required code to properly handle race free platform coherency exit to the DCSCB power down method.
The power_up_setup callback is used to enable the CCI interface for the cluster being brought up. This must be done in assembly before the kernel environment is entered.
Thanks to Achin Gupta and Nicolas Pitre for their help and contributions.
--- arch/arm/mach-vexpress/Kconfig | 1 + arch/arm/mach-vexpress/Makefile | 2 +- arch/arm/mach-vexpress/dcscb.c | 79 +++++++++++++++++++++++++++--------- arch/arm/mach-vexpress/dcscb_setup.S | 38 +++++++++++++++++ 4 files changed, 100 insertions(+), 20 deletions(-) create mode 100644 arch/arm/mach-vexpress/dcscb_setup.S
arch/arm/mach-vexpress/Kconfig +1 -0
@@ -60,6 +60,7 @@ config ARCH_VEXPRESS_CA9X4 config ARCH_VEXPRESS_DCSCB bool "Dual Cluster System Control Block (DCSCB) support" depends on MCPM + select ARM_CCI help Support for the Dual Cluster System Configuration Block (DCSCB). This is needed to provide CPU and cluster power management
arch/arm/mach-vexpress/Makefile +1 -1
@@ -6,6 +6,6 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include \ obj-y := v2m.o obj-$(CONFIG_ARCH_VEXPRESS_CA9X4) += ct-ca9x4.o -obj-$(CONFIG_ARCH_VEXPRESS_DCSCB) += dcscb.o +obj-$(CONFIG_ARCH_VEXPRESS_DCSCB) += dcscb.o dcscb_setup.o obj-$(CONFIG_SMP) += platsmp.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
arch/arm/mach-vexpress/dcscb.c +60 -19
127 lines not on this page · raw message
arch/arm/mach-vexpress/dcscb_setup.S new file +38 -0
@@ -0,0 +1,38 @@ +/* + * arch/arm/include/asm/dcscb_setup.S + * + * Created by: Dave Martin, 2012-06-22 + * Copyright: (C) 2012-2013 Linaro Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/linkage.h> + + +ENTRY(dcscb_power_up_setup) + + cmp r0, #0 @ check affinity level + beq 2f + +/* + * Enable cluster-level coherency, in preparation for turning on the MMU. + * The ACTLR SMP bit does not need to be set here, because cpu_resume() + * already restores that. + * + * A15/A7 may not require explicit L2 invalidation on reset, dependent + * on hardware integration decisions. + * For now, this code assumes that L2 is either already invalidated, + * or invalidation is not required. + */ + + b cci_enable_port_for_self + +2: @ Implementation-specific local CPU setup operations should go here, + @ if any. In this case, there is nothing to do. + + bx lr + +ENDPROC(dcscb_power_up_setup)
Signature · 1 line
1.8.1.2
PATCH 7/8 ARM: vexpress/dcscb: handle platform coherency exit/setup and CCI
Quoted 155 lines · Nicolas Pitre
From: Dave Martin <[email protected]>
Add the required code to properly handle race free platform coherency exit to the DCSCB power down method.
The
power_up_setupcallback is used to enable the CCI interface for the cluster being brought up. This must be done in assembly before the kernel environment is entered.Thanks to Achin Gupta and Nicolas Pitre for their help and contributions.
Signed-off-by Dave Martin <[email protected]>Signed-off-by Nicolas Pitre <[email protected]>Reviewed-by Santosh Shilimkar <[email protected]>Acked-by Pawel Moll <[email protected]>--- arch/arm/mach-vexpress/Kconfig | 1 + arch/arm/mach-vexpress/Makefile | 2 +- arch/arm/mach-vexpress/dcscb.c | 79 +++++++++++++++++++++++++++--------- arch/arm/mach-vexpress/dcscb_setup.S | 38 +++++++++++++++++ 4 files changed, 100 insertions(+), 20 deletions(-) create mode 100644 arch/arm/mach-vexpress/dcscb_setup.Sarch/arm/mach-vexpress/Kconfig +1
-0@@ -60,6 +60,7 @@ config ARCH_VEXPRESS_CA9X4 config ARCH_VEXPRESS_DCSCB bool "Dual Cluster System Control Block (DCSCB) support" depends on MCPM + select ARM_CCI help Support for the Dual Cluster System Configuration Block (DCSCB). This is needed to provide CPU and cluster power managementarch/arm/mach-vexpress/Makefile +1
-1@@ -6,6 +6,6 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include \ obj-y := v2m.o obj-$(CONFIG_ARCH_VEXPRESS_CA9X4) += ct-ca9x4.o -obj-$(CONFIG_ARCH_VEXPRESS_DCSCB) += dcscb.o +obj-$(CONFIG_ARCH_VEXPRESS_DCSCB) += dcscb.o dcscb_setup.o obj-$(CONFIG_SMP) += platsmp.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.oarch/arm/mach-vexpress/dcscb.c +52
-19@@ -16,6 +16,7 @@#include <linux/errno.h> #include <linux/of_address.h> #include <linux/vexpress.h> +#include <linux/arm-cci.h> #include <asm/mcpm.h> #include <asm/proc-fns.h> @@ -105,7 +106,10 @@ static void dcscb_power_down(void)pr_debug ("%s: cpu %u cluster %u\n" , __func__, cpu, cluster);BUG_ON (cpu >=4 || cluster >=2 ); +__mcpm_cpu_going_down (cpu, cluster); +arch_spin_lock (&dcscb_lock); +BUG_ON (__mcpm_cluster_state (cluster) !=CLUSTER_UP ); dcscb_use_count[cpu][cluster]--;if (dcscb_use_count[cpu][cluster] ==0 ) { rst_hold =readl_relaxed (dcscb_base +RST_HOLD0 + cluster *4 );@@ -125,31 +129,59 @@ static void dcscb_power_down(void) skip_wfi = true; }else BUG (); -arch_spin_unlock (&dcscb_lock); - -/* -* Now let's clean our L1 cache and shut ourself down. -* If we're the last CPU in this cluster then clean L2 too. -*/ -/* -* A15/A7 can hit in the cache with SCTLR.C=0, so we don't need -* a preliminary flush here for those CPUs. At least, that's -* the theory -- without the extra flush, Linux explodes on -* RTSM (to be investigated).. -*/ -flush_cache_louis (); -set_cr (get_cr () & ~CR_C ); +if (last_man &&__mcpm_outbound_enter_critical (cpu, cluster)) { +arch_spin_unlock (&dcscb_lock); -if (!last_man) { -flush_cache_louis (); - }else { +/* +* Flush all cache levels for this cluster. +* +* A15/A7 can hit in the cache with SCTLR.C=0, so we don't need +* a preliminary flush here for those CPUs. At least, that's +* the theory -- without the extra flush, Linux explodes on +* RTSM (to be investigated). +*/ +flush_cache_all (); +set_cr (get_cr () & ~CR_C );flush_cache_all (); + +/* +* This is a harmless no-op. On platforms with a real +* outer cache this might either be needed or not, +* depending on where the outer cache sits. +*/ outer_flush_all (); + +/* Disable local coherency by clearing the ACTLR "SMP" bit: */ +set_auxcr (get_auxcr () & ~(1 <<6 )); + +/* +* Disable cluster-level coherency by masking +* incoming snoops and DVM messages: +*/ +cci_disable_port_by_cpu (mpidr); + +__mcpm_outbound_leave_critical (cluster,CLUSTER_DOWN ); + }else { +arch_spin_unlock (&dcscb_lock); + +/* +* Flush the local CPU cache. +* +* A15/A7 can hit in the cache with SCTLR.C=0, so we don't need +* a preliminary flush here for those CPUs. At least, that's +* the theory -- without the extra flush, Linux explodes on +* RTSM (to be investigated). +*/ +flush_cache_louis (); +set_cr (get_cr () & ~CR_C ); +flush_cache_louis (); + +/* Disable local coherency by clearing the ACTLR "SMP" bit: */ +set_auxcr (get_auxcr () & ~(1 <<6 )); } -/* Disable local coherency by clearing the ACTLR "SMP" bit: */ -set_auxcr (get_auxcr () & ~(1 <<6 )); +__mcpm_cpu_down (cpu, cluster);/* Now we are prepared for power-down, do it: */ dsb ();@@ -177,12 +209,17 @@ static void __init dcscb_usage_count_init(void) dcscb_use_count[cpu][cluster] =1 ; } +extern void dcscb_power_up_setup (unsigned int affinity_level);
arch/arm/mach-vexpress/dcscb.c static void __init dcscb_usage_count_init(void) · line 222
Quoted 10 lines
arch/arm/mach-vexpress/dcscb.c +4
-0+static int __init dcscb_init (void ) {struct device_node *node;unsigned int cfg;int ret; +if (!cci_probed ()) +return -ENODEV ; +
I can't see where cci_probed() is defined, this seems to be the only occurrence in this patch set.
Quoted 63 lines
arch/arm/mach-vexpress/dcscb.c +4
-0node =of_find_compatible_node (NULL ,NULL ,"arm,rtsm,dcscb" );if (!node)return -ENODEV ;@@ -195,11 +232,15 @@ static int __init dcscb_init(void)dcscb_usage_count_init (); ret =mcpm_platform_register (&dcscb_power_ops); +if (!ret) + ret =mcpm_sync_init (dcscb_power_up_setup);if (ret) {iounmap (dcscb_base);return ret; } +pr_info ("VExpress DCSCB support installed\n" ); +/* * Future entries into the kernel can now go * through the cluster entry vectors. arch/arm/mach-vexpress/dcscb_setup.S new file +38
-0@@ -0,0 +1,38 @@ +/* + * arch/arm/include/asm/dcscb_setup.S + * + * Created by: Dave Martin, 2012-06-22 + * Copyright: (C) 2012-2013 Linaro Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/linkage.h> + + +ENTRY(dcscb_power_up_setup) + + cmp r0, #0 @ check affinity level + beq 2f + +/* + * Enable cluster-level coherency, in preparation for turning on the MMU. + * The ACTLR SMP bit does not need to be set here, because cpu_resume() + * already restores that. + * + * A15/A7 may not require explicit L2 invalidation on reset, dependent + * on hardware integration decisions. + * For now, this code assumes that L2 is either already invalidated, + * or invalidation is not required. + */ + + b cci_enable_port_for_self + +2: @ Implementation-specific local CPU setup operations should go here, + @ if any. In this case, there is nothing to do. + + bx lr + +ENDPROC(dcscb_power_up_setup)
Signature · 1 line
Tixy
PATCH 7/8 ARM: vexpress/dcscb: handle platform coherency exit/setup and CCI
Quoted 163 lines · Jon Medhurst (Tixy)
Quoted 162 lines · Nicolas Pitre
From: Dave Martin <[email protected]>
Add the required code to properly handle race free platform coherency exit to the DCSCB power down method.
The
power_up_setupcallback is used to enable the CCI interface for the cluster being brought up. This must be done in assembly before the kernel environment is entered.Thanks to Achin Gupta and Nicolas Pitre for their help and contributions.
Signed-off-by Dave Martin <[email protected]>Signed-off-by Nicolas Pitre <[email protected]>Reviewed-by Santosh Shilimkar <[email protected]>Acked-by Pawel Moll <[email protected]>--- arch/arm/mach-vexpress/Kconfig | 1 + arch/arm/mach-vexpress/Makefile | 2 +- arch/arm/mach-vexpress/dcscb.c | 79 +++++++++++++++++++++++++++--------- arch/arm/mach-vexpress/dcscb_setup.S | 38 +++++++++++++++++ 4 files changed, 100 insertions(+), 20 deletions(-) create mode 100644 arch/arm/mach-vexpress/dcscb_setup.Sarch/arm/mach-vexpress/Kconfig +1
-0@@ -60,6 +60,7 @@ config ARCH_VEXPRESS_CA9X4 config ARCH_VEXPRESS_DCSCB bool "Dual Cluster System Control Block (DCSCB) support" depends on MCPM + select ARM_CCI help Support for the Dual Cluster System Configuration Block (DCSCB). This is needed to provide CPU and cluster power managementarch/arm/mach-vexpress/Makefile +1
-1@@ -6,6 +6,6 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include \ obj-y := v2m.o obj-$(CONFIG_ARCH_VEXPRESS_CA9X4) += ct-ca9x4.o -obj-$(CONFIG_ARCH_VEXPRESS_DCSCB) += dcscb.o +obj-$(CONFIG_ARCH_VEXPRESS_DCSCB) += dcscb.o dcscb_setup.o obj-$(CONFIG_SMP) += platsmp.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.oarch/arm/mach-vexpress/dcscb.c +53
-19@@ -16,6 +16,7 @@#include <linux/errno.h> #include <linux/of_address.h> #include <linux/vexpress.h> +#include <linux/arm-cci.h> #include <asm/mcpm.h> #include <asm/proc-fns.h> @@ -105,7 +106,10 @@ static void dcscb_power_down(void)pr_debug ("%s: cpu %u cluster %u\n" , __func__, cpu, cluster);BUG_ON (cpu >=4 || cluster >=2 ); +__mcpm_cpu_going_down (cpu, cluster); +arch_spin_lock (&dcscb_lock); +BUG_ON (__mcpm_cluster_state (cluster) !=CLUSTER_UP ); dcscb_use_count[cpu][cluster]--;if (dcscb_use_count[cpu][cluster] ==0 ) { rst_hold =readl_relaxed (dcscb_base +RST_HOLD0 + cluster *4 );@@ -125,31 +129,59 @@ static void dcscb_power_down(void) skip_wfi = true; }else BUG (); -arch_spin_unlock (&dcscb_lock); - -/* -* Now let's clean our L1 cache and shut ourself down. -* If we're the last CPU in this cluster then clean L2 too. -*/ -/* -* A15/A7 can hit in the cache with SCTLR.C=0, so we don't need -* a preliminary flush here for those CPUs. At least, that's -* the theory -- without the extra flush, Linux explodes on -* RTSM (to be investigated).. -*/ -flush_cache_louis (); -set_cr (get_cr () & ~CR_C ); +if (last_man &&__mcpm_outbound_enter_critical (cpu, cluster)) { +arch_spin_unlock (&dcscb_lock); -if (!last_man) { -flush_cache_louis (); - }else { +/* +* Flush all cache levels for this cluster. +* +* A15/A7 can hit in the cache with SCTLR.C=0, so we don't need +* a preliminary flush here for those CPUs. At least, that's +* the theory -- without the extra flush, Linux explodes on +* RTSM (to be investigated). +*/ +flush_cache_all (); +set_cr (get_cr () & ~CR_C );flush_cache_all (); + +/* +* This is a harmless no-op. On platforms with a real +* outer cache this might either be needed or not, +* depending on where the outer cache sits. +*/ outer_flush_all (); + +/* Disable local coherency by clearing the ACTLR "SMP" bit: */ +set_auxcr (get_auxcr () & ~(1 <<6 )); + +/* +* Disable cluster-level coherency by masking +* incoming snoops and DVM messages: +*/ +cci_disable_port_by_cpu (mpidr); + +__mcpm_outbound_leave_critical (cluster,CLUSTER_DOWN ); + }else { +arch_spin_unlock (&dcscb_lock); + +/* +* Flush the local CPU cache. +* +* A15/A7 can hit in the cache with SCTLR.C=0, so we don't need +* a preliminary flush here for those CPUs. At least, that's +* the theory -- without the extra flush, Linux explodes on +* RTSM (to be investigated). +*/ +flush_cache_louis (); +set_cr (get_cr () & ~CR_C ); +flush_cache_louis (); + +/* Disable local coherency by clearing the ACTLR "SMP" bit: */ +set_auxcr (get_auxcr () & ~(1 <<6 )); } -/* Disable local coherency by clearing the ACTLR "SMP" bit: */ -set_auxcr (get_auxcr () & ~(1 <<6 )); +__mcpm_cpu_down (cpu, cluster);/* Now we are prepared for power-down, do it: */ dsb ();@@ -177,12 +209,17 @@ static void __init dcscb_usage_count_init(void) dcscb_use_count[cpu][cluster] =1 ; } +extern void dcscb_power_up_setup (unsigned int affinity_level); +static int __init dcscb_init (void ) {struct device_node *node;unsigned int cfg;int ret;
Quoted 6 lines
arch/arm/mach-vexpress/dcscb.c static void __init dcscb_usage_count_init(void) · line 222
Quoted 3 lines
arch/arm/mach-vexpress/dcscb.c +3
-0+if (!cci_probed ()) +return -ENODEV ; +I can't see where
cci_probed()is defined, this seems to be the only occurrence in this patch set.
cci_probed() is defined in patch 1 of these series, in include/linux/arm-cci.h and drivers/bus/arm-cci.c
Cheers,
Javi
PATCH 8/8 ARM: vexpress/dcscb: select multi-cluster SMP operations
In reply to Nicolas PitreWhen the DCSCB code is successfully probed and initialized, then the generic MCPM SPM ops should be used as those operations need to be arbitrated through the MCPM layer.
--- arch/arm/mach-vexpress/dcscb.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-vexpress/dcscb.c +2 -0
@@ -239,6 +239,8 @@ static int __init dcscb_init(void)return ret; } +mcpm_smp_set_ops (); +pr_info ("VExpress DCSCB support installed\n" );/*
Signature · 1 line
1.8.1.2
PATCH 8/8 ARM: vexpress/dcscb: select multi-cluster SMP operations
Quoted 14 lines · Nicolas Pitre
When the DCSCB code is successfully probed and initialized, then the generic MCPM SPM ops should be used as those operations need to be arbitrated through the MCPM layer.
Signed-off-by Nicolas Pitre <[email protected]>--- arch/arm/mach-vexpress/dcscb.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-vexpress/dcscb.c +0
-0
arch/arm/mach-vexpress/dcscb.c static int __init dcscb_init(void) · line 243
Quoted 5 lines
arch/arm/mach-vexpress/dcscb.c +2
-0@@ -239,6 +239,8 @@ static int __init dcscb_init(void)return ret; } +mcpm_smp_set_ops (); +
This is going to change the platform's smp_ops after setup_arch() has already set them, is that OK and not too late?
I ask, because for me, RTSM doesn't boot the secondary CPUs if we rely on this change to set the smp_ops, but having a hook in setup_arch() to select instead of the standard vexpress ops does work.
I haven't investigated this more fully yet.
Signature · 1 line
Tixy
PATCH 8/8 ARM: vexpress/dcscb: select multi-cluster SMP operations
Quoted 18 lines · Jon Medhurst (Tixy)
Quoted 17 lines · Nicolas Pitre
When the DCSCB code is successfully probed and initialized, then the generic MCPM SPM ops should be used as those operations need to be arbitrated through the MCPM layer.
Signed-off-by Nicolas Pitre <[email protected]>--- arch/arm/mach-vexpress/dcscb.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-vexpress/dcscb.c +0
-0@@ -239,6 +239,8 @@ static int __init dcscb_init(void)return ret; }
Quoted 5 lines
arch/arm/mach-vexpress/dcscb.c static int __init dcscb_init(void) · line 243
Quoted 2 lines
arch/arm/mach-vexpress/dcscb.c +2
-0+mcpm_smp_set_ops (); +This is going to change the platform's
smp_opsaftersetup_arch()has already set them, is that OK and not too late?
Well... The only methods being invoked before the booting of secondary CPUs are smp_init_cpus and smp_prepare_cpus. In the MCPM case they're both no-ops.
Quoted 3 lines
I ask, because for me, RTSM doesn't boot the secondary CPUs if we rely on this change to set the
smp_ops, but having a hook insetup_arch()to select instead of the standard vexpress ops does work.
Strange. That works for me both ways.
I did it this way because the alternative probe for a CCI in unrelated code in order to install the MCPM ops and this really looks awkward. And it won't work if for example PSCI mode decides not to let Linux see the CCI.
Is there something in the default vexpress smp_init_cpus and smp_prepare_cpus code that could prevent booting through MCPM later on?
Nicolas
PATCH 8/8 ARM: vexpress/dcscb: select multi-cluster SMP operations
Quoted 30 lines · Nicolas Pitre
Quoted 18 lines · Jon Medhurst (Tixy)
Quoted 17 lines · Nicolas Pitre
When the DCSCB code is successfully probed and initialized, then the generic MCPM SPM ops should be used as those operations need to be arbitrated through the MCPM layer.
Signed-off-by Nicolas Pitre <[email protected]>--- arch/arm/mach-vexpress/dcscb.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-vexpress/dcscb.c +0
-0@@ -239,6 +239,8 @@ static int __init dcscb_init(void)return ret; }Quoted 5 lines
arch/arm/mach-vexpress/dcscb.c static int __init dcscb_init(void) · line 243
Quoted 2 lines
arch/arm/mach-vexpress/dcscb.c +2
-0+mcpm_smp_set_ops (); +This is going to change the platform's
smp_opsaftersetup_arch()has already set them, is that OK and not too late?Well... The only methods being invoked before the booting of secondary CPUs are
smp_init_cpusandsmp_prepare_cpus. In the MCPM case they're both no-ops.
Quoted 5 lines
Quoted 3 lines
I ask, because for me, RTSM doesn't boot the secondary CPUs if we rely on this change to set the
smp_ops, but having a hook insetup_arch()to select instead of the standard vexpress ops does work.Strange. That works for me both ways.
Actually, this patch series works for me if I take it on it's own but what should be the same changes in the IKS branch don't. I'll do more investigation...
Signature · 1 line
Tixy
PATCH 8/8 ARM: vexpress/dcscb: select multi-cluster SMP operations
Quoted 35 lines · Jon Medhurst (Tixy)
Quoted 34 lines · Nicolas Pitre
Quoted 18 lines · Jon Medhurst (Tixy)
Quoted 17 lines · Nicolas Pitre
When the DCSCB code is successfully probed and initialized, then the generic MCPM SPM ops should be used as those operations need to be arbitrated through the MCPM layer.
Signed-off-by Nicolas Pitre <[email protected]>--- arch/arm/mach-vexpress/dcscb.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-vexpress/dcscb.c +0
-0@@ -239,6 +239,8 @@ static int __init dcscb_init(void)return ret; }Quoted 5 lines
arch/arm/mach-vexpress/dcscb.c static int __init dcscb_init(void) · line 243
Quoted 2 lines
arch/arm/mach-vexpress/dcscb.c +2
-0+mcpm_smp_set_ops (); +This is going to change the platform's
smp_opsaftersetup_arch()has already set them, is that OK and not too late?Well... The only methods being invoked before the booting of secondary CPUs are
smp_init_cpusandsmp_prepare_cpus. In the MCPM case they're both no-ops.Quoted 3 lines
I ask, because for me, RTSM doesn't boot the secondary CPUs if we rely on this change to set the
smp_ops, but having a hook insetup_arch()to select instead of the standard vexpress ops does work.
Quoted 5 lines
Quoted 1 line
Strange. That works for me both ways.
Actually, this patch series works for me if I take it on it's own but what should be the same changes in the IKS branch don't. I'll do more investigation...
After a closer look, I noticed that I only have 5 out of 8 CPUs online.
So as I suspected, the default prepare_cpus method is not empty and causing problems here. In this case, vexpress_smp_prepare_cpus() is calling vexpress_flags_set() sending any waiting CPU into versatile_secondary_startup where they'll stay forever (the MCPM code expects every new born to go through mcpm_entry_point).
I'll revert to the previous arrangement and we could revisit the awkwardness of it later.
Nicolas