Re: [PATCH 4/9] powerpc/85xx: support CPU hotplug for e500mc and e5500
On Tue, Mar 11, 2014 at 06:48:13PM -0500, Scott Wood wrote: > On Fri, 2014-03-07 at 12:58 +0800, Chenhui Zhao wrote: > > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > > index ac2621a..f3f4401 100644 > > --- a/arch/powerpc/kernel/smp.c > > +++ b/arch/powerpc/kernel/smp.c > > @@ -405,8 +405,12 @@ void generic_cpu_die(unsigned int cpu) > > > > for (i = 0; i < 100; i++) { > > smp_rmb(); > > - if (per_cpu(cpu_state, cpu) == CPU_DEAD) > > + if (per_cpu(cpu_state, cpu) == CPU_DEAD) { > > +#ifdef CONFIG_PPC64 > > + paca[cpu].cpu_start = 0; > > +#endif > > Why wasn't this needed by previous ppc64 machines? If not clear, cpu can't start in the case of cpu hotpolug. The function pseries_cpu_die() in arch/powerpc/platforms/pseries/hotplug-cpu.c also clears the flag. > > > diff --git a/arch/powerpc/platforms/85xx/smp.c > > b/arch/powerpc/platforms/85xx/smp.c > > index 2e5911e..0047883 100644 > > --- a/arch/powerpc/platforms/85xx/smp.c > > +++ b/arch/powerpc/platforms/85xx/smp.c > > @@ -19,6 +19,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -46,6 +47,17 @@ static u64 timebase; > > static int tb_req; > > static int tb_valid; > > > > +#ifdef CONFIG_PPC_E500MC > > +/* specify the cpu PM state when cpu dies, PH15/NAP is the default */ > > +int qoriq_cpu_die_state = E500_PM_PH15; > > +#endif > > static? Is there any way to modify this other than modifying source > code? > > BTW, QorIQ doesn't imply an e500mc derivative. Will support e500, but for now these code support e500mc derivative in advance. Supposed qoriq_cpu_die_state can be changed by platform init code if the default value is not proper for a specific platform. > > > @@ -125,6 +138,34 @@ static void mpc85xx_take_timebase(void) > > } > > > > #ifdef CONFIG_HOTPLUG_CPU > > +#ifdef CONFIG_PPC_E500MC > > +static void qoriq_cpu_die(void) > > +{ > > + unsigned int cpu = smp_processor_id(); > > + > > + local_irq_disable(); > > +#ifdef CONFIG_PPC64 > > + __hard_irq_disable(); > > +#endif > > Why this instead of one call to hard_irq_disable() (no leading > underscores)? > > -Scott hard_irq_disable() will clear soft_enabled again. local_irq_disable() has cleared it. Will use hard_irq_disable() to replace these lines. local_irq_disable(); #ifdef CONFIG_PPC64 __hard_irq_disable(); #endif -Chenhui -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/9] powerpc/85xx: support CPU hotplug for e500mc and e5500
On Fri, 2014-03-07 at 12:58 +0800, Chenhui Zhao wrote: > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index ac2621a..f3f4401 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -405,8 +405,12 @@ void generic_cpu_die(unsigned int cpu) > > for (i = 0; i < 100; i++) { > smp_rmb(); > - if (per_cpu(cpu_state, cpu) == CPU_DEAD) > + if (per_cpu(cpu_state, cpu) == CPU_DEAD) { > +#ifdef CONFIG_PPC64 > + paca[cpu].cpu_start = 0; > +#endif Why wasn't this needed by previous ppc64 machines? > diff --git a/arch/powerpc/platforms/85xx/smp.c > b/arch/powerpc/platforms/85xx/smp.c > index 2e5911e..0047883 100644 > --- a/arch/powerpc/platforms/85xx/smp.c > +++ b/arch/powerpc/platforms/85xx/smp.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -46,6 +47,17 @@ static u64 timebase; > static int tb_req; > static int tb_valid; > > +#ifdef CONFIG_PPC_E500MC > +/* specify the cpu PM state when cpu dies, PH15/NAP is the default */ > +int qoriq_cpu_die_state = E500_PM_PH15; > +#endif static? Is there any way to modify this other than modifying source code? BTW, QorIQ doesn't imply an e500mc derivative. > @@ -125,6 +138,34 @@ static void mpc85xx_take_timebase(void) > } > > #ifdef CONFIG_HOTPLUG_CPU > +#ifdef CONFIG_PPC_E500MC > +static void qoriq_cpu_die(void) > +{ > + unsigned int cpu = smp_processor_id(); > + > + local_irq_disable(); > +#ifdef CONFIG_PPC64 > + __hard_irq_disable(); > +#endif Why this instead of one call to hard_irq_disable() (no leading underscores)? -Scott -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/9] powerpc/85xx: support CPU hotplug for e500mc and e5500
On Fri, 2014-03-07 at 12:58 +0800, Chenhui Zhao wrote: diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index ac2621a..f3f4401 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -405,8 +405,12 @@ void generic_cpu_die(unsigned int cpu) for (i = 0; i 100; i++) { smp_rmb(); - if (per_cpu(cpu_state, cpu) == CPU_DEAD) + if (per_cpu(cpu_state, cpu) == CPU_DEAD) { +#ifdef CONFIG_PPC64 + paca[cpu].cpu_start = 0; +#endif Why wasn't this needed by previous ppc64 machines? diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 2e5911e..0047883 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -19,6 +19,7 @@ #include linux/kexec.h #include linux/highmem.h #include linux/cpu.h +#include linux/smp.h #include asm/machdep.h #include asm/pgtable.h @@ -46,6 +47,17 @@ static u64 timebase; static int tb_req; static int tb_valid; +#ifdef CONFIG_PPC_E500MC +/* specify the cpu PM state when cpu dies, PH15/NAP is the default */ +int qoriq_cpu_die_state = E500_PM_PH15; +#endif static? Is there any way to modify this other than modifying source code? BTW, QorIQ doesn't imply an e500mc derivative. @@ -125,6 +138,34 @@ static void mpc85xx_take_timebase(void) } #ifdef CONFIG_HOTPLUG_CPU +#ifdef CONFIG_PPC_E500MC +static void qoriq_cpu_die(void) +{ + unsigned int cpu = smp_processor_id(); + + local_irq_disable(); +#ifdef CONFIG_PPC64 + __hard_irq_disable(); +#endif Why this instead of one call to hard_irq_disable() (no leading underscores)? -Scott -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/9] powerpc/85xx: support CPU hotplug for e500mc and e5500
On Tue, Mar 11, 2014 at 06:48:13PM -0500, Scott Wood wrote: On Fri, 2014-03-07 at 12:58 +0800, Chenhui Zhao wrote: diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index ac2621a..f3f4401 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -405,8 +405,12 @@ void generic_cpu_die(unsigned int cpu) for (i = 0; i 100; i++) { smp_rmb(); - if (per_cpu(cpu_state, cpu) == CPU_DEAD) + if (per_cpu(cpu_state, cpu) == CPU_DEAD) { +#ifdef CONFIG_PPC64 + paca[cpu].cpu_start = 0; +#endif Why wasn't this needed by previous ppc64 machines? If not clear, cpu can't start in the case of cpu hotpolug. The function pseries_cpu_die() in arch/powerpc/platforms/pseries/hotplug-cpu.c also clears the flag. diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 2e5911e..0047883 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -19,6 +19,7 @@ #include linux/kexec.h #include linux/highmem.h #include linux/cpu.h +#include linux/smp.h #include asm/machdep.h #include asm/pgtable.h @@ -46,6 +47,17 @@ static u64 timebase; static int tb_req; static int tb_valid; +#ifdef CONFIG_PPC_E500MC +/* specify the cpu PM state when cpu dies, PH15/NAP is the default */ +int qoriq_cpu_die_state = E500_PM_PH15; +#endif static? Is there any way to modify this other than modifying source code? BTW, QorIQ doesn't imply an e500mc derivative. Will support e500, but for now these code support e500mc derivative in advance. Supposed qoriq_cpu_die_state can be changed by platform init code if the default value is not proper for a specific platform. @@ -125,6 +138,34 @@ static void mpc85xx_take_timebase(void) } #ifdef CONFIG_HOTPLUG_CPU +#ifdef CONFIG_PPC_E500MC +static void qoriq_cpu_die(void) +{ + unsigned int cpu = smp_processor_id(); + + local_irq_disable(); +#ifdef CONFIG_PPC64 + __hard_irq_disable(); +#endif Why this instead of one call to hard_irq_disable() (no leading underscores)? -Scott hard_irq_disable() will clear soft_enabled again. local_irq_disable() has cleared it. Will use hard_irq_disable() to replace these lines. local_irq_disable(); #ifdef CONFIG_PPC64 __hard_irq_disable(); #endif -Chenhui -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/9] powerpc/85xx: support CPU hotplug for e500mc and e5500
Implemented CPU hotplug on e500mc and e5500. On e5500 both 32-bit and 64-bit modes can work. Used some callback functions implemented in RCPM driver. Signed-off-by: Chenhui Zhao --- arch/powerpc/Kconfig |2 +- arch/powerpc/kernel/smp.c |6 ++- arch/powerpc/mm/tlb_nohash.c |6 ++- arch/powerpc/platforms/85xx/smp.c | 94 ++--- 4 files changed, 87 insertions(+), 21 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index a5e5d2e..05f6323 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -362,7 +362,7 @@ config SWIOTLB config HOTPLUG_CPU bool "Support for enabling/disabling CPUs" depends on SMP && (PPC_PSERIES || \ - PPC_PMAC || PPC_POWERNV || (PPC_85xx && !PPC_E500MC)) + PPC_PMAC || PPC_POWERNV || FSL_SOC_BOOKE) ---help--- Say Y here to be able to disable and re-enable individual CPUs at runtime on SMP machines. diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index ac2621a..f3f4401 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -405,8 +405,12 @@ void generic_cpu_die(unsigned int cpu) for (i = 0; i < 100; i++) { smp_rmb(); - if (per_cpu(cpu_state, cpu) == CPU_DEAD) + if (per_cpu(cpu_state, cpu) == CPU_DEAD) { +#ifdef CONFIG_PPC64 + paca[cpu].cpu_start = 0; +#endif return; + } msleep(100); } printk(KERN_ERR "CPU%d didn't die...\n", cpu); diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c index b37a58e..d24e06c 100644 --- a/arch/powerpc/mm/tlb_nohash.c +++ b/arch/powerpc/mm/tlb_nohash.c @@ -648,8 +648,10 @@ static void __early_init_mmu(int boot_cpu) num_cams = (mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) / 4; linear_map_top = map_mem_in_cams(linear_map_top, num_cams); - /* limit memory so we dont have linear faults */ - memblock_enforce_memory_limit(linear_map_top); + if (boot_cpu) { + /* limit memory so we dont have linear faults */ + memblock_enforce_memory_limit(linear_map_top); + } if (book3e_htw_mode == PPC_HTW_NONE) { patch_exception(0x1c0, exc_data_tlb_miss_bolted_book3e); diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 2e5911e..0047883 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -46,6 +47,17 @@ static u64 timebase; static int tb_req; static int tb_valid; +#ifdef CONFIG_PPC_E500MC +/* specify the cpu PM state when cpu dies, PH15/NAP is the default */ +int qoriq_cpu_die_state = E500_PM_PH15; +#endif + +#ifdef CONFIG_PPC_E500MC +static void mpc85xx_timebase_freeze(int freeze) +{ + qoriq_pm_ops->freeze_time_base(freeze); +} +#else static void mpc85xx_timebase_freeze(int freeze) { uint32_t mask; @@ -58,6 +70,7 @@ static void mpc85xx_timebase_freeze(int freeze) in_be32(>devdisr); } +#endif static void mpc85xx_give_timebase(void) { @@ -125,6 +138,34 @@ static void mpc85xx_take_timebase(void) } #ifdef CONFIG_HOTPLUG_CPU +#ifdef CONFIG_PPC_E500MC +static void qoriq_cpu_die(void) +{ + unsigned int cpu = smp_processor_id(); + + local_irq_disable(); +#ifdef CONFIG_PPC64 + __hard_irq_disable(); +#endif + idle_task_exit(); + + if (qoriq_pm_ops->irq_mask) + qoriq_pm_ops->irq_mask(cpu); + + mtspr(SPRN_TCR, 0); + mtspr(SPRN_TSR, mfspr(SPRN_TSR)); + + generic_set_cpu_dead(cpu); + + if (cur_cpu_spec && cur_cpu_spec->cpu_flush_caches) + cur_cpu_spec->cpu_flush_caches(); + + qoriq_pm_ops->cpu_enter_state(cpu, qoriq_cpu_die_state); + + while (1) + ; +} +#else static void smp_85xx_mach_cpu_die(void) { unsigned int cpu = smp_processor_id(); @@ -155,6 +196,7 @@ static void smp_85xx_mach_cpu_die(void) ; } #endif +#endif static inline void flush_spin_table(void *spin_table) { @@ -208,11 +250,8 @@ static int smp_85xx_kick_cpu(int nr) spin_table = phys_to_virt(*cpu_rel_addr); local_irq_save(flags); -#ifdef CONFIG_PPC32 -#ifdef CONFIG_HOTPLUG_CPU - /* Corresponding to generic_set_cpu_dead() */ - generic_set_cpu_up(nr); +#ifdef CONFIG_HOTPLUG_CPU if (system_state == SYSTEM_RUNNING) { /* * To keep it compatible with old boot program which uses @@ -225,6 +264,12 @@ static int smp_85xx_kick_cpu(int nr) out_be32(_table->addr_l, 0); flush_spin_table(spin_table); +#ifdef CONFIG_PPC_E500MC + /* Due to an erratum, wake the core
[PATCH 4/9] powerpc/85xx: support CPU hotplug for e500mc and e5500
Implemented CPU hotplug on e500mc and e5500. On e5500 both 32-bit and 64-bit modes can work. Used some callback functions implemented in RCPM driver. Signed-off-by: Chenhui Zhao chenhui.z...@freescale.com --- arch/powerpc/Kconfig |2 +- arch/powerpc/kernel/smp.c |6 ++- arch/powerpc/mm/tlb_nohash.c |6 ++- arch/powerpc/platforms/85xx/smp.c | 94 ++--- 4 files changed, 87 insertions(+), 21 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index a5e5d2e..05f6323 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -362,7 +362,7 @@ config SWIOTLB config HOTPLUG_CPU bool Support for enabling/disabling CPUs depends on SMP (PPC_PSERIES || \ - PPC_PMAC || PPC_POWERNV || (PPC_85xx !PPC_E500MC)) + PPC_PMAC || PPC_POWERNV || FSL_SOC_BOOKE) ---help--- Say Y here to be able to disable and re-enable individual CPUs at runtime on SMP machines. diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index ac2621a..f3f4401 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -405,8 +405,12 @@ void generic_cpu_die(unsigned int cpu) for (i = 0; i 100; i++) { smp_rmb(); - if (per_cpu(cpu_state, cpu) == CPU_DEAD) + if (per_cpu(cpu_state, cpu) == CPU_DEAD) { +#ifdef CONFIG_PPC64 + paca[cpu].cpu_start = 0; +#endif return; + } msleep(100); } printk(KERN_ERR CPU%d didn't die...\n, cpu); diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c index b37a58e..d24e06c 100644 --- a/arch/powerpc/mm/tlb_nohash.c +++ b/arch/powerpc/mm/tlb_nohash.c @@ -648,8 +648,10 @@ static void __early_init_mmu(int boot_cpu) num_cams = (mfspr(SPRN_TLB1CFG) TLBnCFG_N_ENTRY) / 4; linear_map_top = map_mem_in_cams(linear_map_top, num_cams); - /* limit memory so we dont have linear faults */ - memblock_enforce_memory_limit(linear_map_top); + if (boot_cpu) { + /* limit memory so we dont have linear faults */ + memblock_enforce_memory_limit(linear_map_top); + } if (book3e_htw_mode == PPC_HTW_NONE) { patch_exception(0x1c0, exc_data_tlb_miss_bolted_book3e); diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 2e5911e..0047883 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -19,6 +19,7 @@ #include linux/kexec.h #include linux/highmem.h #include linux/cpu.h +#include linux/smp.h #include asm/machdep.h #include asm/pgtable.h @@ -46,6 +47,17 @@ static u64 timebase; static int tb_req; static int tb_valid; +#ifdef CONFIG_PPC_E500MC +/* specify the cpu PM state when cpu dies, PH15/NAP is the default */ +int qoriq_cpu_die_state = E500_PM_PH15; +#endif + +#ifdef CONFIG_PPC_E500MC +static void mpc85xx_timebase_freeze(int freeze) +{ + qoriq_pm_ops-freeze_time_base(freeze); +} +#else static void mpc85xx_timebase_freeze(int freeze) { uint32_t mask; @@ -58,6 +70,7 @@ static void mpc85xx_timebase_freeze(int freeze) in_be32(guts-devdisr); } +#endif static void mpc85xx_give_timebase(void) { @@ -125,6 +138,34 @@ static void mpc85xx_take_timebase(void) } #ifdef CONFIG_HOTPLUG_CPU +#ifdef CONFIG_PPC_E500MC +static void qoriq_cpu_die(void) +{ + unsigned int cpu = smp_processor_id(); + + local_irq_disable(); +#ifdef CONFIG_PPC64 + __hard_irq_disable(); +#endif + idle_task_exit(); + + if (qoriq_pm_ops-irq_mask) + qoriq_pm_ops-irq_mask(cpu); + + mtspr(SPRN_TCR, 0); + mtspr(SPRN_TSR, mfspr(SPRN_TSR)); + + generic_set_cpu_dead(cpu); + + if (cur_cpu_spec cur_cpu_spec-cpu_flush_caches) + cur_cpu_spec-cpu_flush_caches(); + + qoriq_pm_ops-cpu_enter_state(cpu, qoriq_cpu_die_state); + + while (1) + ; +} +#else static void smp_85xx_mach_cpu_die(void) { unsigned int cpu = smp_processor_id(); @@ -155,6 +196,7 @@ static void smp_85xx_mach_cpu_die(void) ; } #endif +#endif static inline void flush_spin_table(void *spin_table) { @@ -208,11 +250,8 @@ static int smp_85xx_kick_cpu(int nr) spin_table = phys_to_virt(*cpu_rel_addr); local_irq_save(flags); -#ifdef CONFIG_PPC32 -#ifdef CONFIG_HOTPLUG_CPU - /* Corresponding to generic_set_cpu_dead() */ - generic_set_cpu_up(nr); +#ifdef CONFIG_HOTPLUG_CPU if (system_state == SYSTEM_RUNNING) { /* * To keep it compatible with old boot program which uses @@ -225,6 +264,12 @@ static int smp_85xx_kick_cpu(int nr) out_be32(spin_table-addr_l, 0);