linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: ACPI List <linux-acpi@vger.kernel.org>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Prashanth Prakash <pprakash@codeaurora.org>,
	Al Stone <al.stone@linaro.org>,
	Vikas Sajjan <vikas.cha.sajjan@hpe.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ashwin Chaugule <ashwin.chaugule@linaro.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	ALKML <linux-arm-kernel@lists.infradead.org>,
	Sunil <sunil.vl@hpe.com>
Subject: [PATCH v9 4/7] cpuidle: introduce CPU_PM_CPU_IDLE_ENTER macro for ARM{32, 64}
Date: Fri,  8 Jul 2016 18:07:55 +0100	[thread overview]
Message-ID: <1467997678-7107-5-git-send-email-sudeep.holla@arm.com> (raw)
In-Reply-To: <1467997678-7107-1-git-send-email-sudeep.holla@arm.com>

The function arm_enter_idle_state is exactly the same in both generic
ARM{32,64} CPUIdle driver and will be the same even on ARM64 backend
for ACPI processor idle driver. So we can unify it and move it to a
common place by introducing CPU_PM_CPU_IDLE_ENTER macro that can be
used in all places avoiding duplication.

This is in preparation of reuse of the generic cpuidle entry function
for ACPI LPI support on ARM64.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Suggested-by: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/cpuidle/cpuidle-arm.c | 26 ++++++--------------------
 include/linux/cpuidle.h       | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c
index e342565e8715..4ba3d3fe142f 100644
--- a/drivers/cpuidle/cpuidle-arm.c
+++ b/drivers/cpuidle/cpuidle-arm.c
@@ -36,26 +36,12 @@
 static int arm_enter_idle_state(struct cpuidle_device *dev,
 				struct cpuidle_driver *drv, int idx)
 {
-	int ret;
-
-	if (!idx) {
-		cpu_do_idle();
-		return idx;
-	}
-
-	ret = cpu_pm_enter();
-	if (!ret) {
-		/*
-		 * Pass idle state index to cpu_suspend which in turn will
-		 * call the CPU ops suspend protocol with idle index as a
-		 * parameter.
-		 */
-		ret = arm_cpuidle_suspend(idx);
-
-		cpu_pm_exit();
-	}
-
-	return ret ? -1 : idx;
+	/*
+	 * Pass idle state index to arm_cpuidle_suspend which in turn
+	 * will call the CPU ops suspend protocol with idle index as a
+	 * parameter.
+	 */
+	return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, idx);
 }
 
 static struct cpuidle_driver arm_idle_driver = {
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 07b83d32f66c..bb31373c3478 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -252,4 +252,22 @@ static inline int cpuidle_register_governor(struct cpuidle_governor *gov)
 #define CPUIDLE_DRIVER_STATE_START	0
 #endif
 
+#define CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx)	\
+({								\
+	int __ret;						\
+								\
+	if (!idx) {						\
+		cpu_do_idle();					\
+		return idx;					\
+	}							\
+								\
+	__ret = cpu_pm_enter();					\
+	if (!__ret) {						\
+		__ret = low_level_idle_enter(idx);		\
+		cpu_pm_exit();					\
+	}							\
+								\
+	__ret ? -1 : idx;					\
+})
+
 #endif /* _LINUX_CPUIDLE_H */
-- 
2.7.4

  parent reply	other threads:[~2016-07-08 17:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-08 17:07 [PATCH v9 0/7] ACPI / processor_idle: Add ACPI v6.0 LPI support Sudeep Holla
2016-07-08 17:07 ` [PATCH v9 1/7] ACPI / processor_idle: introduce ACPI_PROCESSOR_CSTATE Sudeep Holla
2016-07-08 17:07 ` [PATCH v9 2/7] ACPI / processor_idle: Add support for Low Power Idle(LPI) states Sudeep Holla
2016-07-16  0:32   ` Rafael J. Wysocki
2016-07-18 15:48     ` Sudeep Holla
2016-07-08 17:07 ` [PATCH v9 3/7] arm64: cpuidle: drop __init section marker to arm_cpuidle_init Sudeep Holla
2016-07-12 15:23   ` Catalin Marinas
2016-07-08 17:07 ` Sudeep Holla [this message]
2016-07-08 17:07 ` [PATCH v9 5/7] drivers: firmware: psci: initialise idle states using ACPI LPI Sudeep Holla
2016-07-08 17:07 ` [PATCH v9 6/7] arm64: add support for ACPI Low Power Idle(LPI) Sudeep Holla
2016-07-12 15:22   ` Catalin Marinas
2016-07-08 17:07 ` [PATCH v9 7/7] ACPI : enable ACPI_PROCESSOR_IDLE on ARM64 Sudeep Holla
2016-07-12 11:42 ` [PATCH v9 0/7] ACPI / processor_idle: Add ACPI v6.0 LPI support Sudeep Holla
2016-07-12 12:09   ` Rafael J. Wysocki
2016-07-12 12:59     ` Sudeep Holla
2016-07-14  1:15       ` Rafael J. Wysocki

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=1467997678-7107-5-git-send-email-sudeep.holla@arm.com \
    --to=sudeep.holla@arm.com \
    --cc=al.stone@linaro.org \
    --cc=ashwin.chaugule@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=pprakash@codeaurora.org \
    --cc=rjw@rjwysocki.net \
    --cc=sunil.vl@hpe.com \
    --cc=vikas.cha.sajjan@hpe.com \
    /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).