linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: zhang.lyra@gmail.com
To: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>
Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Chunyan Zhang <chunyan.zhang@unisoc.com>
Subject: [RFC PATCH v1 1/2] cpuidle: allow idle state to be found as deepest state for s2idle only
Date: Mon, 13 Apr 2020 15:00:13 +0800	[thread overview]
Message-ID: <20200413070014.12960-2-zhang.lyra@gmail.com> (raw)
In-Reply-To: <20200413070014.12960-1-zhang.lyra@gmail.com>

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

Add a new flag CPUIDLE_FLAG_S2IDLE to allow c-state to be found as
deepest state for s2idle only, so that users can add a new c-state
for using s2idle and don't worry disturbing other use cases such as
play_idle() which probably don't want to enter into so much deep
idle state since devices are not suspended for that kind of cases.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
 drivers/cpuidle/cpuidle.c        | 3 ++-
 drivers/cpuidle/dt_idle_states.c | 3 +++
 include/linux/cpuidle.h          | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index de81298051b3..bb61f0c271d2 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -89,7 +89,8 @@ static int find_deepest_state(struct cpuidle_driver *drv,
 		    s->exit_latency_ns <= latency_req ||
 		    s->exit_latency_ns > max_latency_ns ||
 		    (s->flags & forbidden_flags) ||
-		    (s2idle && !s->enter_s2idle))
+		    (s2idle && !s->enter_s2idle) ||
+		    (!s2idle && (s->flags & CPUIDLE_FLAG_S2ILDE)))
 			continue;
 
 		latency_req = s->exit_latency_ns;
diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c
index 252f2a9686a6..530db2726c05 100644
--- a/drivers/cpuidle/dt_idle_states.c
+++ b/drivers/cpuidle/dt_idle_states.c
@@ -80,6 +80,9 @@ static int init_state_node(struct cpuidle_state *idle_state,
 	idle_state->flags = 0;
 	if (of_property_read_bool(state_node, "local-timer-stop"))
 		idle_state->flags |= CPUIDLE_FLAG_TIMER_STOP;
+
+	if (of_property_read_bool(state_node, "for-s2idle-only"))
+		idle_state->flags |= CPUIDLE_FLAG_S2ILDE;
 	/*
 	 * TODO:
 	 *	replace with kstrdup and pointer assignment when name
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index ec2ef63771f0..08da701f74cd 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -78,6 +78,7 @@ struct cpuidle_state {
 #define CPUIDLE_FLAG_TIMER_STOP BIT(2) /* timer is stopped on this state */
 #define CPUIDLE_FLAG_UNUSABLE	BIT(3) /* avoid using this state */
 #define CPUIDLE_FLAG_OFF	BIT(4) /* disable this state by default */
+#define CPUIDLE_FLAG_S2ILDE	BIT(5) /* state is used for s2idle only */
 
 struct cpuidle_device_kobj;
 struct cpuidle_state_kobj;
-- 
2.20.1


  reply	other threads:[~2020-04-13  7:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-13  7:00 [RFC PATCH v1 0/2] allow idle state to be found as deepest state for s2idle only zhang.lyra
2020-04-13  7:00 ` zhang.lyra [this message]
2020-04-20  9:36   ` [RFC PATCH v1 1/2] cpuidle: " Chunyan Zhang
2020-04-20 11:42   ` Mark Rutland
2020-04-21  7:31     ` Chunyan Zhang
2020-04-13  7:00 ` [RFC PATCH v1 2/2] dt-bindings: arm: Add description to the new property for-s2idle-only zhang.lyra
2020-04-20 11:44   ` 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=20200413070014.12960-2-zhang.lyra@gmail.com \
    --to=zhang.lyra@gmail.com \
    --cc=chunyan.zhang@unisoc.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.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).