All of lore.kernel.org
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 5/5] arm64: add PSCI CPU_OFF-based hotplug support
Date: Wed, 10 Jul 2013 23:16:00 +0100	[thread overview]
Message-ID: <1373494560-25011-1-git-send-email-mark.rutland@arm.com> (raw)
In-Reply-To: <1373494279-24712-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 24dbad9..d536f3e 100644
--- a/arch/arm64/kernel/smp_psci.c
+++ b/arch/arm64/kernel/smp_psci.c
@@ -47,9 +47,39 @@ static int __cpuinit smp_psci_cpu_boot(unsigned int cpu)
 	return err;
 }
 
+#ifdef CONFIG_HOTPLUG_CPU
+static int __cpuinit 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 __cpuinit 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_warn("psci: unable to power off CPU%u (%d)", cpu, ret);
+}
+#endif
+
 const struct smp_operations smp_psci_ops __cpuinitconst = {
 	.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.7.9.5

  parent reply	other threads:[~2013-07-10 22:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10 22:11 [RFC PATCH 0/5] arm64: initial CPU_HOTPLUG support Mark Rutland
2013-07-10 22:13 ` [RFC PATCH 1/5] arm64: reorganise smp_enable_ops Mark Rutland
2013-07-10 22:15 ` [RFC PATCH 2/5] arm64: factor out spin-table boot method Mark Rutland
2013-07-10 22:15 ` [RFC PATCH 3/5] arm64: read enable-method for CPU0 Mark Rutland
2013-07-10 22:15 ` [RFC PATCH 4/5] arm64: add CPU_HOTPLUG infrastructure Mark Rutland
2013-07-10 23:59   ` Russell King - ARM Linux
2013-07-11  9:33   ` Stephen Boyd
2013-07-11 11:10     ` Mark Rutland
2013-07-10 22:16 ` Mark Rutland [this message]
2013-07-11 15:10 ` [RFC PATCH 0/5] arm64: initial CPU_HOTPLUG support Hanjun Guo
2013-07-11 16:34   ` Mark Rutland
2013-07-19 11:09     ` Hanjun Guo
2013-07-15 10:47 ` Mark Rutland
2013-07-15 13:25   ` Paul Gortmaker
2013-07-15 13:45     ` Mark Rutland

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=1373494560-25011-1-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.