Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752564AbbGaJlv (ORCPT ); Fri, 31 Jul 2015 05:41:51 -0400 Received: from mail-by2on0144.outbound.protection.outlook.com ([207.46.100.144]:56251 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751101AbbGaJlr (ORCPT ); Fri, 31 Jul 2015 05:41:47 -0400 X-Greylist: delayed 956 seconds by postgrey-1.27 at vger.kernel.org; Fri, 31 Jul 2015 05:41:47 EDT 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 3/3] PowerPC/mpc85xx: Add hotplug support on E6500 cores Date: Fri, 31 Jul 2015 17:20:44 +0800 Message-ID: <1438334444-31919-3-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;BN1AFFO11FD040;1:pf8s9m9bNPH6BGiHJJmw+mnJauVbUgM8U2gFNbF+N8rfHQFiwi4wd95/2YxQEGovECve+A5hKymaHfC+7d4EmLGWxPRwUkLw3CNOXinzSnOuqgJ63UnqqLrqAuzzvzOd2vifQgwjODxiiIOQYWwMq+21AiSUt8v20iDPNGXwmYGKoe05mYYjeRBtjQP5RzzGQ31Uf51vNihzaxkaHfmqNil36cGF30uANMoc09eFZkhjz1cJtJda9fWsgnhau4wFV8ccPBjhKpCQbIeqSQMVe4QnMi2CPHkxiPasjFFgIhPg3wCiQOsQonHQ79w607w0ZbinQBhWRATrBispCLduZA== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(62966003)(2950100001)(48376002)(47776003)(33646002)(46102003)(85426001)(4001450100002)(575784001)(77156002)(50466002)(19580395003)(92566002)(87936001)(36756003)(19580405001)(50226001)(110136002)(86152002)(5001960100002)(6806004)(104016003)(2371004)(2351001)(229853001)(106466001)(189998001)(50986999)(105606002)(76176999)(77096005);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR03MB1479;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1479;2:QopXMwilZ8NzTrOduxTXL2tLwvgR/vwwkS447VtjL5CteDqJxQllMONtE6GbrIOMwlnYEMCJqHaxT3rrJA3lF50g6JtVt/9h8sC7urFI0gA4YQoB4bMcMhrLZYsHJAG75EZn8oSKm1tHq0IqN6jIUKOuwnDYkU+xoiV207kmyEI=;3:AeLJ1jVl0PLJEi0z6V5TAevYGN18r24a19ucrBS31MXW5jL4HRa7AfOwBkQRCAjV5q7M4fpQB4VG56YB2gfYRLotLVkSyKmmqiL/43iWDJF4BqGjuk5q2g46AKAmPtIXaDaV+C7dTdd7z98hf6Tt4u5DBihE2c1E/2rHaY0AqHCElYOqxfw0uSK9pfUBMMZ04AZMVAQBMN0/kKPglEPM8n+JI+c1T9tcyMKYpzpKqWM=;25:KHQHLyRdghRl8DfPU7/9Wn8nlPpOuyhgFMEQbsu3XOK64ReImmb+3FJc/U0qOer2DNND4aToD7gzHYZitMm3/Bu2FJFiUnFiPTEqq8gwluf8sm2D0LB8/sedGgpTPkDX0b0DPila3vn0xOBvNsJHC+Z6h97B9uQH/Nzp90vMWI7DpCMaKSPxNKmGu/WIsqa5jxnPYJyoYGFjgQT8PXSG0zX/QciDCPZL7Uq+UHlu1CC5qbEy/t2mParErzZnhrpJ X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1479; X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1479;20:+SUPEpes5iBJ2AOd9Q35meeVxlLrhDlASymGvA4vvTo/21Ze6dcDNvOlHepLu5xkoqACUwQepWQ2dMkHUNS3D7ipHvA+ifaYTVl7czEkCAIYRpj8eA2WQ4egFfacsptGVXx4ZPJIwxmIvveFLEfXqc2f/lSHCalEg0LtoVNrcYjsm5AssHD2iXHUUXJ62kfJALfAka89/DlsVY3D6vfcJUAthL0wAu9hOnW6HClKpHStHl02Qv7DL0cmwA+pI3GKPnusTCzdJPjbJcBVNH3l9y4sG1lUCyGv31yepFrI+RZJadCjJtH7W9RAHsz9rpg7tJcTyFMd2L4LUPfLxbwolwtsujCgrDMeXu4NbLuG1jM=;4:MsXFNHL3asq5fvYSLeQrx1AiMUajm46/KgdZmBgrIscTLbt5KBMOHdyZpPFAGfWgBPD6DZjYG20X/McYtzL5KN3pWo5DuiMcRZ+OmQ8LDYU5/kd6csfW+bcakxFulsr8BGiw2JfIjaFTHuIE8wAcxwGOyyt3+Zscy7KbDMUTle4GOkIinsQ88NEUNTolQUr8qar0halPvEjeiKP2ObCueZGtD94XPcSCuovsMde2TUzPcayIEYdYJjv3lxlC+7CNjLQhQmA1P1/CFbHfTCO1mSNtSZt+cYM78WbW/oxO2mg= BN3PR03MB1479: 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:BN3PR03MB1479;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1479; X-Forefront-PRVS: 0654257CF5 X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1479;23:Q68fhxruocSH6OOuoZj6KHJUDUetIdG5HGdq/lECwclMsrap+r5bwwYGipHjWJpnpp2w8CAd3xR/vvMmlSFyMAcOWyWDwRk7pM92eY7Tvti8M5A19mjzB8ixnWYun8m0MJTdhkKURgTrDIfB7AVsMI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gbcNbjf5QOQASwi44vFG3X6EW5D3bEEd+cI=;20:gfTxkpHxAgQqTyGa5yCs4Fuly//gDXdHre0DvJbZuq/bPk3KaSscnZavyyFVClvYYrmsv3ZtzzXxea2WrPBosA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2015 09:25:56.6036 (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: BN3PR03MB1479 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4766 Lines: 153 From: Tang Yuantian Freescale E6500 core-based platforms, like t4240, 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/include/asm/smp.h | 1 + arch/powerpc/kernel/head_64.S | 10 +++++-- arch/powerpc/platforms/85xx/smp.c | 63 ++++++++++++++++++++++++++------------- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index bf37d17..c7bd27d 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h @@ -198,6 +198,7 @@ extern void generic_secondary_thread_init(void); extern unsigned long __secondary_hold_spinloop; extern unsigned long __secondary_hold_acknowledge; extern char __secondary_hold; +extern unsigned int booting_cpu_hwid; extern void __early_start(void); #endif /* __ASSEMBLY__ */ diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S index d48125d..c47544d 100644 --- a/arch/powerpc/kernel/head_64.S +++ b/arch/powerpc/kernel/head_64.S @@ -181,6 +181,10 @@ exception_marker: #endif #ifdef CONFIG_PPC_BOOK3E + .globl booting_cpu_hwid +booting_cpu_hwid: + .long 0x0 + .align 3 _GLOBAL(fsl_secondary_thread_init) /* Enable branch prediction */ lis r3,BUCSR_INIT@h @@ -197,8 +201,10 @@ _GLOBAL(fsl_secondary_thread_init) * but the low bit right by two bits so that the cpu numbering is * continuous. */ - mfspr r3, SPRN_PIR - rlwimi r3, r3, 30, 2, 30 + bl 10f +10: mflr r22 + addi r22,r22,(booting_cpu_hwid - 10b) + lwz r3,0(r22) mtspr SPRN_PIR, r3 #endif diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 7f0dadb..8652a49 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -189,15 +189,22 @@ static inline u32 read_spin_table_addr_l(void *spin_table) static void wake_hw_thread(void *info) { void fsl_secondary_thread_init(void); - unsigned long imsr1, inia1; + unsigned long imsr, inia; int nr = *(const int *)info; - - imsr1 = MSR_KERNEL; - inia1 = *(unsigned long *)fsl_secondary_thread_init; - - mttmr(TMRN_IMSR1, imsr1); - mttmr(TMRN_INIA1, inia1); - mtspr(SPRN_TENS, TEN_THREAD(1)); + int hw_cpu = get_hard_smp_processor_id(nr); + int thread_idx = cpu_thread_in_core(hw_cpu); + + booting_cpu_hwid = (u32)hw_cpu; + imsr = MSR_KERNEL; + inia = *(unsigned long *)fsl_secondary_thread_init; + if (thread_idx == 0) { + mttmr(TMRN_IMSR0, imsr); + mttmr(TMRN_INIA0, inia); + } else { + mttmr(TMRN_IMSR1, imsr); + mttmr(TMRN_INIA1, inia); + } + mtspr(SPRN_TENS, TEN_THREAD(thread_idx)); smp_generic_kick_cpu(nr); } @@ -219,27 +226,43 @@ static int smp_85xx_kick_cpu(int nr) pr_debug("smp_85xx_kick_cpu: kick CPU #%d\n", nr); #ifdef CONFIG_PPC64 - /* Threads don't use the spin table */ - if (cpu_thread_in_core(nr) != 0) { + if (threads_per_core > 1) { int primary = cpu_first_thread_sibling(nr); if (WARN_ON_ONCE(!cpu_has_feature(CPU_FTR_SMT))) return -ENOENT; - if (cpu_thread_in_core(nr) != 1) { - pr_err("%s: cpu %d: invalid hw thread %d\n", - __func__, nr, cpu_thread_in_core(nr)); - return -ENOENT; + /* + * If either one of threads in the same core is online, + * use the online one to start the other. + */ + if (cpu_online(primary) || cpu_online(primary + 1)) { + qoriq_pm_ops->cpu_up(nr); + if (cpu_online(primary)) + smp_call_function_single(primary, + wake_hw_thread, &nr, 1); + else + smp_call_function_single(primary + 1, + wake_hw_thread, &nr, 1); + return 0; } - if (!cpu_online(primary)) { - pr_err("%s: cpu %d: primary %d not online\n", - __func__, nr, primary); - return -ENOENT; + /* + * If both threads are offline, reset core to start. + * When core is up, Thread 0 always gets up first, + * so bind the current logical cpu with Thread 0. + */ + if (hw_cpu != cpu_first_thread_sibling(hw_cpu)) { + int hw_cpu1, hw_cpu2; + + hw_cpu1 = get_hard_smp_processor_id(primary); + hw_cpu2 = get_hard_smp_processor_id(primary + 1); + set_hard_smp_processor_id(primary, hw_cpu2); + set_hard_smp_processor_id(primary + 1, hw_cpu1); + /* get new physical cpu id */ + hw_cpu = get_hard_smp_processor_id(nr); } - smp_call_function_single(primary, wake_hw_thread, &nr, 0); - return 0; } #endif -- 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/