linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 5/5] arm64: add PSCI CPU_OFF-based hotplug support
Date: Wed, 14 Aug 2013 17:20:28 +0100	[thread overview]
Message-ID: <1376497228-20543-6-git-send-email-mark.rutland@arm.com> (raw)
In-Reply-To: <1376497228-20543-1-git-send-email-mark.rutland@arm.com>

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 <mark.rutland@arm.com>
---
 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..e9e5890 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)\n", 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
 };
-- 
1.8.1.1

  parent reply	other threads:[~2013-08-14 16:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14 16:20 [PATCHv3 0/5] arm64: initial CPU hotplug support Mark Rutland
2013-08-14 16:20 ` [PATCHv3 1/5] arm64: reorganise smp_enable_ops Mark Rutland
2013-08-14 17:46   ` Nicolas Pitre
2013-08-14 18:01   ` Santosh Shilimkar
2013-08-14 16:20 ` [PATCHv3 2/5] arm64: factor out spin-table boot method Mark Rutland
2013-08-14 17:51   ` Nicolas Pitre
2013-08-30 13:44     ` Catalin Marinas
2013-08-14 18:12   ` Santosh Shilimkar
2013-08-14 18:21     ` Nicolas Pitre
2013-08-14 19:17       ` Santosh Shilimkar
2013-08-14 19:21   ` Olof Johansson
2013-08-14 20:20     ` Nicolas Pitre
2013-08-14 16:20 ` [PATCHv3 3/5] arm64: read enable-method for CPU0 Mark Rutland
2013-08-14 17:51   ` Nicolas Pitre
2013-08-14 18:15   ` Santosh Shilimkar
2013-08-14 18:22     ` Nicolas Pitre
2013-08-14 19:02       ` Santosh Shilimkar
2013-08-14 16:20 ` [PATCHv3 4/5] arm64: add CPU_HOTPLUG infrastructure Mark Rutland
2013-08-14 17:53   ` Nicolas Pitre
2013-08-14 19:24   ` Santosh Shilimkar
2013-08-14 16:20 ` Mark Rutland [this message]
2013-08-14 17:54   ` [PATCHv3 5/5] arm64: add PSCI CPU_OFF-based hotplug support Nicolas Pitre
2013-08-14 18:05 ` [PATCHv3 0/5] arm64: initial CPU " Nicolas Pitre
2013-08-30 16:39 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376497228-20543-6-git-send-email-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).