From patchwork Mon Jul 22 15:37:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 2831437 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 66C559F243 for ; Mon, 22 Jul 2013 15:43:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 260FB201EE for ; Mon, 22 Jul 2013 15:43:42 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B8B1F2020F for ; Mon, 22 Jul 2013 15:43:36 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1IE1-0007Ag-U0; Mon, 22 Jul 2013 15:40:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1ID6-00079X-NX; Mon, 22 Jul 2013 15:39:40 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1ID4-00076g-O7 for linux-arm-kernel@lists.infradead.org; Mon, 22 Jul 2013 15:39:39 +0000 Received: from e106331-lin.cambridge.arm.com (e106331-lin.cambridge.arm.com [10.1.205.41]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id r6MFbZkn007531; Mon, 22 Jul 2013 16:39:18 +0100 (BST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCHv2 5/5] arm64: add PSCI CPU_OFF-based hotplug support Date: Mon, 22 Jul 2013 16:37:34 +0100 Message-Id: <1374507454-4573-6-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.8.1.1 In-Reply-To: <1374507454-4573-1-git-send-email-mark.rutland@arm.com> References: <1374507454-4573-1-git-send-email-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130722_113939_050032_367DE653 X-CRM114-Status: GOOD ( 14.42 ) X-Spam-Score: -8.4 (--------) Cc: Mark Rutland , Lorenzo.Pieralisi@arm.com, graeme.gregory@linaro.org, nico@linaro.org, Marc.Zyngier@arm.com, Catalin.Marinas@arm.com, sboyd@codeaurora.org, santosh.shilimkar@ti.com, hanjun.guo@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for using PSCI CPU_OFF calls for CPU hotplug. With this code it is possible to hot unplug CPUs with "psci" as their boot-method, as long as there's an appropriate cpu_off function id specified in the psci node. Signed-off-by: Mark Rutland --- arch/arm64/kernel/smp_psci.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/arm64/kernel/smp_psci.c b/arch/arm64/kernel/smp_psci.c index 20499bc..06123de 100644 --- a/arch/arm64/kernel/smp_psci.c +++ b/arch/arm64/kernel/smp_psci.c @@ -47,9 +47,39 @@ static int smp_psci_cpu_boot(unsigned int cpu) return err; } +#ifdef CONFIG_HOTPLUG_CPU +static int smp_psci_cpu_disable(unsigned int cpu) +{ + /* Fail early if we don't have CPU_OFF support */ + if (!psci_ops.cpu_off) + return -EOPNOTSUPP; + return 0; +} + +static void smp_psci_cpu_die(unsigned int cpu) +{ + int ret; + /* + * There are no known implementations of PSCI actually using the + * power state field, pass a sensible default for now. + */ + struct psci_power_state state = { + .type = PSCI_POWER_STATE_TYPE_POWER_DOWN, + }; + + ret = psci_ops.cpu_off(state); + + pr_crit("psci: unable to power off CPU%u (%d)", cpu, ret); +} +#endif + const struct smp_operations smp_psci_ops = { .name = "psci", .cpu_init = smp_psci_cpu_init, .cpu_prepare = smp_psci_cpu_prepare, .cpu_boot = smp_psci_cpu_boot, +#ifdef CONFIG_HOTPLUG_CPU + .cpu_disable = smp_psci_cpu_disable, + .cpu_die = smp_psci_cpu_die, +#endif };