Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218AbbGaJ7J (ORCPT ); Fri, 31 Jul 2015 05:59:09 -0400 Received: from mail-by2on0103.outbound.protection.outlook.com ([207.46.100.103]:64615 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751478AbbGaJ7H (ORCPT ); Fri, 31 Jul 2015 05:59:07 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; feescale.com; dkim=none (message not signed) header.d=none; From: To: CC: , Tang Yuantian , Chenhui Zhao , Tang Yuantian Subject: [PATCH 2/3] PowerPC/mpc85xx: Add hotplug support on E5500 and E500MC cores Date: Fri, 31 Jul 2015 17:20:43 +0800 Message-ID: <1438334444-31919-2-git-send-email-b29983@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1438334444-31919-1-git-send-email-b29983@freescale.com> References: <1438334444-31919-1-git-send-email-b29983@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD023;1:24fiMB232VHAaDjlS1G6UKGLZeeUo70B5UWOPsMTLQef8Gny5cCBbhpAVyxElnKnzoEreU3Qj+zSnhhhufupzosyxTKFAyVbh2/+Csa9jy+duB7mtjrZgsgjTLVNXShtMP6dQKH9mC8cHq9QQ89G8uLyOORNdhVStgfAhQiQk0Isd3HJ4xtDaIegdNrHIWsUi6KL7c+9+zj5xKNEzxLl8fUSLDGGnyr0L2fl6c33ihoX/3lR/mFyPepQ97LN8NARXSBW0ab1wmGvffgWprrAGANX17InH9EDfvXFMiSDG9/3e97Fv0skRH8C6u1auuPIo8rFYjHnjseUHB7a4/CpTA== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(50466002)(87936001)(50986999)(76176999)(92566002)(85426001)(47776003)(62966003)(46102003)(77096005)(50226001)(77156002)(104016003)(229853001)(33646002)(48376002)(2351001)(2950100001)(575784001)(19580405001)(19580395003)(6806004)(189998001)(2371004)(110136002)(86152002)(5001960100002)(106466001)(4001450100002)(105606002)(36756003);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR03MB301;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB301;2:a0tdtUB4BaFXAk23r7e/66L4cZYiiVKGx5gRz0icqQyapVUqFhx/kpD+y2jXKHUXHTJl5QlKd7NIm9ZZtRB7ogrLSEKiNBS8VpJ5wpfSqV7duEoRF8+/29IZMF+yjj4UkYCdGS8S0mrOs6xuG5bLXGnshQCvfC53tCkQnzWMEIM=;3:UtZvIgTy1Xvz0ZmsaWDeb16oBdqL4f6QeWdxiUo8tCfYdraYxquzNw2JNzbh1kCOzcmxGP2it1vtTEreWcufoE+RzlIdEXWwWa4XQZdJInxFoD3Rl/vkNa0VMcDNy+9ICFpYR/d1jUW5iRqLWCc8px9ymITn+N7xlg/o4a0Sc6z1t4ximWAipZHWmFD8XLTVZB/x0/KiaZGSFDlQnraRr54zSQc4TFUqf9xhC09l7OA=;25:sVfpgwqzqlJwRL5IsxTME8SCrDCogobzj+UrZVUZyiZRp+/TVHZoMQUb2NrriuRtvSKmbfDZOMEFeqI+dgb+MDhb+9tHvUxU59FicXx2N5+1uKC/OO2f0Nidk5aoY3UkWSVxG2tTtubnHc4Tw9BHChxEom1G3E7khgLZE24sCnrvsEvTO6xyl2JiibyTvRZ+MwTSKbgrtWO94MySfnbaDqKRLWTgq3mDJuiVh4N+Ov0RtiIXlm7cYNkDcOaT8vrM/IhKyimItN2J4FY9duXrpw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB301; X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB301;20:8ILyaNn+DdU/dL28AmNawfUkxLt1aSlwUmTzMGh92hzZQz2BuGKQwL4RJ7Oh3EEvjaz+ywVjNGy72KfxhvJF0zkazlDq8sE7U4SyDJ2i4BzPo/8cnEHFZ6NMwNDrl14rVsMLOUCQw42CPODugvlHFjKkdhBdRnJ/0Xq4nnVDqafnqpZ1Aj0Hpwm/4IM8+AMQI4C6eKeyRvc8Al5zfj8j4U7fNIobgx9jmhShSFTw5v7zN037aGg+wc6R8ub3VY2IWNEWJvmTmckSHoHaz0v359lx4P9trkH0DqVWZOa53a4r4teYZ0wF9uH/6DGGFYZawwzVesYAnr7gR8bgYxrzuakr56CP8+91M0tBNhBDhTQ=;4:ZX9bkkg8KY3heN6DrBidFrcXNmN+vR3EhaqXDvWPqlDpsCVpI8/lOSkBwrr+yv0HvdnpSeK6J/rAMo7RVEjpmFVdNyNjJ1bSsN5hPz6JgXYYsF4J9DR/nPys5EP8QYpQVyYROoidjSHsVPnqj1m48g3tgIo+owetQF+lBEwh63ljYK2lJlolGW33bYGkmA4xE0Anl1itKiSMH+XI0AsXqjIegACqxZ2ylEda4dYVz0qB7SSB/omtQx6flEKRtJCR7Pw1hhytVgNUZDQdl+YVuPXsBtj7OGYUxOClg9Qtw+Q= DM2PR03MB301: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:DM2PR03MB301;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB301; X-Forefront-PRVS: 0654257CF5 X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB301;23:pvQ0CpZPv2NUHnIjOiGDbf8ESOL8Ttd6DSK6ig6UIV1bDeEtK9rVXIvVExCLot1tb0si1CHXrkNyUhZFYZgGOPIy752hldYJqZTssNoo2iiMy/o0sVtAS8bd2cybJv3th0mhgqtP6WBffI7tGMjN0g5d7SLmoX8oIE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tNESejDliALwokFU=;20:fqF2NTD/0So7DfarmasEy4xyK5YwbYO0gW3+oqhKMBGYcLFIn2QSFc1+XkmwojGKt6H3NEgjffuJIDsskgAy9Q== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2015 09:25:52.8650 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB301 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5141 Lines: 184 From: Tang Yuantian Freescale E500MC and E5500 core-based platforms, like P4080, T1040, support disabling/enabling CPU dynamically. This patch adds this feature on those platforms. Signed-off-by: Chenhui Zhao Signed-off-by: Tang Yuantian --- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/smp.h | 1 + arch/powerpc/kernel/smp.c | 5 +++++ arch/powerpc/platforms/85xx/smp.c | 39 ++++++++++++++++++++++++++++++++------- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 5ef2711..dd9e252 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -386,7 +386,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/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index 825663c..bf37d17 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h @@ -67,6 +67,7 @@ void generic_cpu_die(unsigned int cpu); void generic_set_cpu_dead(unsigned int cpu); void generic_set_cpu_up(unsigned int cpu); int generic_check_cpu_restart(unsigned int cpu); +int generic_check_cpu_dead(unsigned int cpu); #endif #ifdef CONFIG_PPC64 diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index ec9ec20..2cca27a 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -454,6 +454,11 @@ int generic_check_cpu_restart(unsigned int cpu) return per_cpu(cpu_state, cpu) == CPU_UP_PREPARE; } +int generic_check_cpu_dead(unsigned int cpu) +{ + return per_cpu(cpu_state, cpu) == CPU_DEAD; +} + static bool secondaries_inhibited(void) { return kvm_hv_mode_active(); diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 6811a5b..7f0dadb 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -42,6 +42,7 @@ struct epapr_spin_table { u32 pir; }; +#ifdef CONFIG_HOTPLUG_CPU static u64 timebase; static int tb_req; static int tb_valid; @@ -111,7 +112,7 @@ static void mpc85xx_take_timebase(void) local_irq_restore(flags); } -#ifdef CONFIG_HOTPLUG_CPU +#ifndef CONFIG_PPC_E500MC static void e500_cpu_idle(void) { u32 tmp; @@ -127,6 +128,7 @@ static void e500_cpu_idle(void) mtmsr(tmp); isync(); } +#endif static void qoriq_cpu_dying(void) { @@ -144,11 +146,30 @@ static void qoriq_cpu_dying(void) generic_set_cpu_dead(cpu); +#ifndef CONFIG_PPC_E500MC e500_cpu_idle(); +#endif while (1) ; } + +static void qoriq_real_cpu_die(unsigned int cpu) +{ + int i; + + for (i = 0; i < 50000; i++) { + if (generic_check_cpu_dead(cpu)) { + qoriq_pm_ops->cpu_die(cpu); +#ifdef CONFIG_PPC64 + paca[cpu].cpu_start = 0; +#endif + return; + } + udelay(10); + } + pr_err("%s: CPU%d didn't die...\n", __func__, cpu); +} #endif static inline void flush_spin_table(void *spin_table) @@ -246,11 +267,7 @@ 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); - if (system_state == SYSTEM_RUNNING) { /* * To keep it compatible with old boot program which uses @@ -263,6 +280,7 @@ static int smp_85xx_kick_cpu(int nr) out_be32(&spin_table->addr_l, 0); flush_spin_table(spin_table); + qoriq_pm_ops->cpu_up(nr); /* * We don't set the BPTR register here since it already points * to the boot page properly. @@ -286,7 +304,12 @@ static int smp_85xx_kick_cpu(int nr) /* clear the acknowledge status */ __secondary_hold_acknowledge = -1; } + + /* Corresponding to generic_set_cpu_dead() */ + generic_set_cpu_up(nr); #endif + +#ifdef CONFIG_PPC32 flush_spin_table(spin_table); out_be32(&spin_table->pir, hw_cpu); out_be32(&spin_table->addr_l, __pa(__early_start)); @@ -300,7 +323,6 @@ static int smp_85xx_kick_cpu(int nr) ret = -ENOENT; goto out; } -out: #else smp_generic_kick_cpu(nr); @@ -311,6 +333,9 @@ out: flush_spin_table(spin_table); #endif +#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PPC32) +out: +#endif local_irq_restore(flags); if (ioremappable) @@ -324,7 +349,7 @@ struct smp_ops_t smp_85xx_ops = { .cpu_bootable = smp_generic_cpu_bootable, #ifdef CONFIG_HOTPLUG_CPU .cpu_disable = generic_cpu_disable, - .cpu_die = generic_cpu_die, + .cpu_die = qoriq_real_cpu_die, #endif #if defined(CONFIG_KEXEC) || defined(CONFIG_HOTPLUG_CPU) .give_timebase = mpc85xx_give_timebase, -- 2.1.0.27.g96db324 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/