ARM: vexpress: add support for multiple core tiles
Subsystems (3)
PATCH v4 1/1 ARM: vexpress: add support for multiple core tiles
The current Versatile Express BSP defines the MACHINE_START macro in the core tile code.
This patch moves this into the generic board code and introduces a method for determining the current tile at runtime, allowing the Kernel to have support for multiple tiles compiled in. Tile-specific functions are executed via a descriptor struct containing the correct implementations for the current tile.
---
Rebased against -next and updated following discussion with Russell on the list.
arch/arm/mach-vexpress/core.h | 5 -- arch/arm/mach-vexpress/ct-ca9x4.c | 41 ++++++++++---- arch/arm/mach-vexpress/include/mach/ct-ca9x4.h | 2 + arch/arm/mach-vexpress/include/mach/motherboard.h | 21 +++++++ arch/arm/mach-vexpress/platsmp.c | 33 ++--------- arch/arm/mach-vexpress/v2m.c | 62 +++++++++++++++++---- 6 files changed, 109 insertions(+), 55 deletions(-)
arch/arm/mach-vexpress/core.h +0 -5
@@ -17,8 +17,3 @@ struct amba_device name##_device = { \ .irq = IRQ_##base, \ /* .dma = DMA_##base,*/ \ } - -struct map_desc ; - -void v2m_map_io (struct map_desc *tile,size_t num); -extern struct sys_timer v2m_timer;
arch/arm/mach-vexpress/ct-ca9x4.c +29 -12
69 lines not on this page · raw message
arch/arm/mach-vexpress/include/mach/ct-ca9x4.h +2 -0
@@ -45,4 +45,6 @@#define IRQ_CT_CA9X4_PMU_CPU2 94#define IRQ_CT_CA9X4_PMU_CPU3 95 +extern struct ct_desc ct_ca9x4_desc; +#endif
arch/arm/mach-vexpress/include/mach/motherboard.h +21 -0
@@ -118,4 +118,25 @@int v2m_cfg_write (u32 devfn,u32 data);int v2m_cfg_read (u32 devfn,u32 *data); +/* +* Core tile IDs +*/ +#define V2M_CT_ID_CA9 0x0c000191 +#define V2M_CT_ID_UNSUPPORTED 0xff000191 +#define V2M_CT_ID_MASK 0xff000fff + +struct ct_desc { +u32 id; +const char *name; +void (*map_io)(void ); +void (*init_irq)(void ); +void (*init_tile)(void ); +#ifdef CONFIG_SMP +void (*init_cpu_map)(void ); +void (*smp_enable)(unsigned int ); +#endif +}; + +extern struct ct_desc *ct_desc; +#endif
arch/arm/mach-vexpress/platsmp.c +6 -27
@@ -17,10 +17,8 @@#include <linux/io.h> #include <asm/cacheflush.h> -#include <asm/smp_scu.h> #include <asm/unified.h> -#include <mach/ct-ca9x4.h> #include <mach/motherboard.h> #define V2M_PA_CS7 0x10000000
@@ -34,11 +32,6 @@ extern void vexpress_secondary_startup(void);*/ volatile int __cpuinitdata pen_release =-1 ; -static void __iomem *scu_base_addr (void ) -{ -return MMIO_P2V (A9_MPCORE_SCU ); -} -static DEFINE_SPINLOCK (boot_lock);void __cpuinit platform_secondary_init (unsigned int cpu)
@@ -115,36 +108,22 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)*/ void __init smp_init_cpus (void ) { -void __iomem *scu_base =scu_base_addr (); -unsigned int i, ncores; - - ncores = scu_base ?scu_get_core_count (scu_base) :1 ; - -/* sanity check */ -if (ncores >NR_CPUS ) { + ct_desc->init_cpu_map (); +if (!num_possible_cpus ()) {printk (KERN_WARNING -"vexpress: no. of cores (%d) greater than configured " -"maximum of %d - clipping\n" , - ncores,NR_CPUS ); - ncores =NR_CPUS ; +"vexpress: no possible CPUs declared, forcing logical " +"CPU 0\n" ); +set_cpu_possible (0 , true); } - -for (i =0 ; i < ncores; i++) -set_cpu_possible (i, true); }void __init platform_smp_prepare_cpus (unsigned int max_cpus) { -int i; -/* * Initialise the present map, which describes the set of CPUs * actually populated@the present time. */ -for (i =0 ; i < max_cpus; i++) -set_cpu_present (i, true); - -scu_enable (scu_base_addr ()); + ct_desc->smp_enable (max_cpus);/* * Write the address of secondary startup into the
arch/arm/mach-vexpress/v2m.c +51 -11
96 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v4 1/1 ARM: vexpress: add support for multiple core tiles
Quoted 11 lines · Will Deacon
arch/arm/mach-vexpress/platsmp.c +0
-7@@ -115,36 +108,22 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)*/ void __init smp_init_cpus (void ) { -void __iomem *scu_base =scu_base_addr (); -unsigned int i, ncores; - - ncores = scu_base ?scu_get_core_count (scu_base) :1 ; - -/* sanity check */ -if (ncores >NR_CPUS ) {
arch/arm/mach-vexpress/platsmp.c int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) · line 116
Quoted 10 lines
arch/arm/mach-vexpress/platsmp.c +5
-4+ ct_desc->init_cpu_map (); +if (!num_possible_cpus ()) {printk (KERN_WARNING -"vexpress: no. of cores (%d) greater than configured " -"maximum of %d - clipping\n" , - ncores,NR_CPUS ); - ncores =NR_CPUS ; +"vexpress: no possible CPUs declared, forcing logical " +"CPU 0\n" ); +set_cpu_possible (0 , true);
Hmm. The right check is whether the current CPU number is set in the possible map - if it's clear, then that's certainly a bug.
However, this will never happen, unless you do something really silly in ->init_cpu_map() such as clearing all possible CPUs, or setting them false. See boot_cpu_init() in init/main.c.
So I don't think we need this check (and I think it should be in the platform code.)
Alteratively, we could do this in the generic SMP code:
if (num_possible_cpus() > NR_CPUS) {
unsigned int nr = 0, cpu;
pr_warning("SMP: number of CPUs greater than configured %u, disabling CPU",
NR_CPUS);
for_each_possible_cpu(cpu) {
if (nr >= NR_CPUS) {
cpu_set_possible(cpu, false);
pr_cont(" %u", cpu);
}
nr++;
}
pr_cont("\n");
}PATCH v4 1/1 ARM: vexpress: add support for multiple core tiles
Hi Russell,
Quoted 16 lines
arch/arm/mach-vexpress/platsmp.c int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) · line 116
Quoted 12 lines
arch/arm/mach-vexpress/platsmp.c +5
-6-/* sanity check */ -if (ncores >NR_CPUS ) { + ct_desc->init_cpu_map (); +if (!num_possible_cpus ()) {printk (KERN_WARNING -"vexpress: no. of cores (%d) greater than configured " -"maximum of %d - clipping\n" , - ncores,NR_CPUS ); - ncores =NR_CPUS ; +"vexpress: no possible CPUs declared, forcing logical " +"CPU 0\n" ); +set_cpu_possible (0 , true);Hmm. The right check is whether the current CPU number is set in the possible map - if it's clear, then that's certainly a bug.
Quoted 6 lines
However, this will never happen, unless you do something really silly in ->init_cpu_map() such as clearing all possible CPUs, or setting them false. See
boot_cpu_init()ininit/main.c.So I don't think we need this check (and I think it should be in the platform code.)
Ok, my initial thought was to lose the check as well. This means that all we do in smp_init_cpus for vexpress is invoke ct_desc->init_cpu_map().
Quoted 17 lines
Alteratively, we could do this in the generic SMP code:
if (num_possible_cpus() > NR_CPUS) { unsigned int nr = 0, cpu; pr_warning("SMP: number of CPUs greater than configured %u, disabling CPU", NR_CPUS); for_each_possible_cpu(cpu) { if (nr >= NR_CPUS) { cpu_set_possible(cpu, false); pr_cont(" %u", cpu); } nr++; } pr_cont("\n"); }
Can num_possible_cpus() be > NR_CPUS? I think the bitmap used to calculate the former is limited by the latter anyway.
Thanks,
Will