From patchwork Mon Jul 20 08:12:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tang yuantian X-Patchwork-Id: 497599 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E052E140778 for ; Mon, 20 Jul 2015 18:33:31 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id C46861A2C54 for ; Mon, 20 Jul 2015 18:33:31 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0105.outbound.protection.outlook.com [65.55.169.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id DEAEF1A094B for ; Mon, 20 Jul 2015 18:32:34 +1000 (AEST) Received: from BY2PR03CA002.namprd03.prod.outlook.com (10.255.93.19) by BY2PR03MB393.namprd03.prod.outlook.com (10.141.141.12) with Microsoft SMTP Server (TLS) id 15.1.225.13; Mon, 20 Jul 2015 08:17:47 +0000 Received: from BN1BFFO11FD029.protection.gbl (10.255.93.4) by BY2PR03CA002.outlook.office365.com (10.255.93.19) with Microsoft SMTP Server (TLS) id 15.1.219.17 via Frontend Transport; Mon, 20 Jul 2015 08:17:46 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD029.mail.protection.outlook.com (10.58.144.92) with Microsoft SMTP Server (TLS) id 15.1.213.8 via Frontend Transport; Mon, 20 Jul 2015 08:17:46 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t6K8Hhhr014563; Mon, 20 Jul 2015 01:17:44 -0700 From: To: Subject: [PATCH] PowerPC: Add CPU hot plug feature to RCPM driver Date: Mon, 20 Jul 2015 16:12:51 +0800 Message-ID: <1437379971-26938-1-git-send-email-b29983@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD029; 1:MWlm+J06q0rrVGybSQ9lBgiEgapSwdbF76x4T6dfWfh4N0FU3gamoqgCgUIApjOMl98gehqHh5HqxoSAj1XYQyw/0q9DT29HX8ipm/UGvGHZ0dbjX47yDdycyiE/LzxrVwpHfz8sHduenJ13ZDTc0l6umdage2UkUwPiTO2/NP7zAzYULZqgs+aAIcmWQn18MxfGpHogkKvLjXMTXYTu6OwkXdM0gcgez3QOhK+P2mFIF8rACAuJowXFY/Sw+4tm0u25W29Zj/Nq7K6IxTJyM14vA2F/KtPjMKtNeBkGZz0QH7qViJZf5wmI4ryhsV51tWOB6Zdeoi0CP5fvfQbKXSCpEvcfl109uEyOs41UaGN3WKJNFaN/usdCWiNF41hc8aL3yRvNjo+mkWwsCgmfEVwhIH+6/QQ/kKHk4i0TIgL78lZ4OwWZr9o5bmvZWguE X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(4001450100002)(48376002)(50226001)(19580395003)(6806004)(19580405001)(50986999)(86152002)(50466002)(87936001)(85426001)(450100001)(62966003)(77156002)(47776003)(77096005)(92566002)(104016003)(46102003)(5001920100001)(106466001)(107886002)(5001960100002)(110136002)(189998001)(33646002)(2371004)(2351001)(229853001)(105606002)(5003940100001)(36756003)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB393; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB393; 2:z/nXmqIoO6FtY3ueelOVBPfFtSNKqLzDU7iVua9EKzr8lBbFsBUNcq+Ou2QR0DgLIEeSw8lB66w9z21bXF/6BJgSP6YhgCuO5I4jsJkGGtURUukRIqKSWNDZjOLPbbrpWITw0D79v1nFBjLnqZelno3UFlB/PxsosgI45iT6BfM=; 3:seAeETNoSdiGY8pqim3E1nOPSr8l6WCrIekIR6jMU+uI2S2kwNBGEEm39h8pd+IHywG7AWnGYpPAHZXNlzsUtG9OueNK2En39DRFcjtK0JAT68cr+yI9CDSVhEPUEGGJvdP17K9UlEN1OMUMKA5Dyx7iNB0Ydci0oe4LIG1ekf2ZbJX+3Zq9iJUFLzNBcNVazXrxka325qNalNg/T9OG7+evLZacFG8zhL1BPwfR0+8=; 25:2rZGRH0TGn4rrwTQHSnhNRfqhlQHkNrDTHAaG2QS9IxDLz9lWN47l7s2pkGufozLDhYRarGzJSvbECualYsMCCeDSEfWDPIk1NiaywfoBz7dvHe1zJOtf0UAh/dLeRBtVB+NWXddUGiEG0nknTSHWC8m+45Yn76Eyb/coeWjiuvkGim7tiqIrpUWLU5sClb/YOFQdMA/xI+qg2roeL8BJNX/eg/IQNAVTFLeJxfyvTNrZVVs32612kGyXLG366kP4T/+Rwde2ji7uD165q2qMg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB393; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB393; 20:s4hgha7hE0mkxeNEmFf7Bcy+Bm+mj25NiF9Beu+CSJEd/3jtSNMcJukB505uDx9I0u/8UQlU9okdHMWnMA/LT5qLkxZ2OQySbRYfwSYqvrOclYhqW5RoyZztX97lsPGAUarsuZdDYPajZR+L2R8CPOTNl87HK7dOtf2v+Z6YoYMwV+1HtMdDccJT+3ykA1K15h1PUJBCT1QLUDncSDKFkB0Ag0H8udoby+ceZgHDDnR41y2jKUoXari5Q72oc1RLEhSF0+Eo925c89kqcSDEdQ2NsS/Paa4rTbpX+Q3tY0vM4m+vU8cvDROVlBr9s5VeWX9TW+I46ZbGOG9HQZP008WXGdgf9tKQpm2SJzD6sBs=; 4:Tn4RbwwvwBMhXeAiFvZyT3+LtAm44/4wSZlU3OuWv71B4s22Ang5J1Bgq3bD6F5Gm66RiRiROfhNOOPP/a4o6qw3j/EIlEo+yOZEItSnQAbv1KK1pZxGH/KVOMTiEfuMNLh/s/Ht//pOYbpqQ7dvGQNt1gYeVBjXnbZ9y7rQeNKg4+OVEfmQrLB+E9YGtiOHbuywMujESdcjxfW2uxj60bSXhCAepA+9nUu6VN5OaEYnUmVUTul1s1S6vGWGRTPcUV3DsYf3EG2xcW9csag+b6jDPLHsamfbja9N26UtC2Q= BY2PR03MB393: 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:BY2PR03MB393; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB393; X-Forefront-PRVS: 0643BDA83C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB393; 23:NmZi47xh0vUnUG3GE1hn6OOvLxThb26fc/cqugPyeQ?= =?us-ascii?Q?WMogWae5EzKNypbyNleN47ekbarZedGgll+lgro6ljdj1GbJb0k7aQgChhhX?= =?us-ascii?Q?dyDd+tonA48yGpIGkcHmEycm+wkyG4TSc3EHPHsAwcMJvVu91/oZ78ar6szM?= =?us-ascii?Q?tgx3dYT8nD25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= X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB393; 5:iIEZeag/pj2rkmXZN8tLW0/jqjT9FNSC2aEIExHGnPib8UhSqG24kh0MiuALbx2gOUbpKppi3fxSqwTcwCt6RcNGtLX29rXHZ+lUnErjDQ/2yta5HRTHsrCZpSMUg6NfVlPlaFODeGbxv3Tg0FprdA==; 24:r1ArkU6fkuvqWvbQt9ayafdZbeXXHBPKNYmpZVqXkZmUF34TY9lNhBftm8hN6cakzoVYFBlHIymNehHJcT/q+Rq5Rw2cPwW45d4BcKWT3MA=; 20:ZxodEIW7jw/LUdGZzWKPJ1Qpo9vEtulCHLGgzol8HWHzGPYv4ozay47GSD2HesVq+jGJbkcIv+k0PIWL5MRh7A== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2015 08:17:46.5208 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB393 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tang Yuantian , linuxppc-dev@lists.ozlabs.org, Chenhui Zhao Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Tang Yuantian PowerPC E500MC serial SoCs, like T2080 T1040 and T4240, use RCPM to manage power consumption. This patch adds hot plug feature to RCPM driver. Signed-off-by: Chenhui Zhao Signed-off-by: Tang Yuantian --- arch/powerpc/include/asm/fsl_pm.h | 2 ++ arch/powerpc/sysdev/fsl_rcpm.c | 56 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/arch/powerpc/include/asm/fsl_pm.h b/arch/powerpc/include/asm/fsl_pm.h index 4b09f09..0b03b03 100644 --- a/arch/powerpc/include/asm/fsl_pm.h +++ b/arch/powerpc/include/asm/fsl_pm.h @@ -33,6 +33,8 @@ struct fsl_pm_ops { void (*irq_unmask)(int cpu); void (*cpu_enter_state)(int cpu, int state); void (*cpu_exit_state)(int cpu, int state); + void (*cpu_up)(int cpu); + void (*cpu_die)(int cpu); int (*plat_enter_sleep)(void); void (*freeze_time_base)(bool freeze); diff --git a/arch/powerpc/sysdev/fsl_rcpm.c b/arch/powerpc/sysdev/fsl_rcpm.c index 4bd2d64..acf3f94 100644 --- a/arch/powerpc/sysdev/fsl_rcpm.c +++ b/arch/powerpc/sysdev/fsl_rcpm.c @@ -128,6 +128,46 @@ static void rcpm_v2_cpu_enter_state(int cpu, int state) } } +static void rcpm_v1_cpu_die(int cpu) +{ + rcpm_v1_cpu_enter_state(cpu, E500_PM_PH15); +} + +static void qoriq_disable_thread(void *info) +{ + int hw_cpu = get_hard_smp_processor_id(*(const int *)info); + int thread = cpu_thread_in_core(hw_cpu); + + mtspr(SPRN_TENC, TEN_THREAD(thread)); +} + +static void rcpm_v2_cpu_die(int cpu) +{ + int primary; + + if (threads_per_core == 1) { + rcpm_v2_cpu_enter_state(cpu, E500_PM_PH20); + return; + } + + primary = cpu_first_thread_sibling(cpu); + if (cpu_is_offline(primary) && cpu_is_offline(primary + 1)) { + /* when two threads are all offline, put core in PH20 */ + rcpm_v2_cpu_enter_state(cpu, E500_PM_PH20); + } else { + /* + * When one thread is offline, disable the thread + * by running qoriq_disable_thread() on the other thread. + */ + if (cpu_online(primary)) + smp_call_function_single(primary, + qoriq_disable_thread, &cpu, 1); + else + smp_call_function_single(primary + 1, + qoriq_disable_thread, &cpu, 1); + } +} + static void rcpm_v1_cpu_exit_state(int cpu, int state) { int hw_cpu = get_hard_smp_processor_id(cpu); @@ -146,6 +186,12 @@ static void rcpm_v1_cpu_exit_state(int cpu, int state) } } +static void rcpm_v1_cpu_up(int cpu) +{ + rcpm_v1_cpu_exit_state(cpu, E500_PM_PH15); + rcpm_v1_irq_unmask(cpu); +} + static void rcpm_v2_cpu_exit_state(int cpu, int state) { int hw_cpu = get_hard_smp_processor_id(cpu); @@ -169,6 +215,12 @@ static void rcpm_v2_cpu_exit_state(int cpu, int state) } } +static void rcpm_v2_cpu_up(int cpu) +{ + rcpm_v2_cpu_exit_state(cpu, E500_PM_PH20); + rcpm_v2_irq_unmask(cpu); +} + static int rcpm_v1_plat_enter_state(int state) { u32 *pmcsr_reg = &rcpm_v1_regs->powmgtcsr; @@ -275,6 +327,8 @@ static const struct fsl_pm_ops qoriq_rcpm_v1_ops = { .irq_unmask = rcpm_v1_irq_unmask, .cpu_enter_state = rcpm_v1_cpu_enter_state, .cpu_exit_state = rcpm_v1_cpu_exit_state, + .cpu_up = rcpm_v1_cpu_up, + .cpu_die = rcpm_v1_cpu_die, .plat_enter_sleep = rcpm_v1_plat_enter_sleep, .set_ip_power = rcpm_v1_set_ip_power, .freeze_time_base = rcpm_v1_freeze_time_base, @@ -286,6 +340,8 @@ static const struct fsl_pm_ops qoriq_rcpm_v2_ops = { .irq_unmask = rcpm_v2_irq_unmask, .cpu_enter_state = rcpm_v2_cpu_enter_state, .cpu_exit_state = rcpm_v2_cpu_exit_state, + .cpu_up = rcpm_v2_cpu_up, + .cpu_die = rcpm_v2_cpu_die, .plat_enter_sleep = rcpm_v2_plat_enter_sleep, .set_ip_power = rcpm_v2_set_ip_power, .freeze_time_base = rcpm_v2_freeze_time_base,