linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lina Iyer <ilina@codeaurora.org>
To: rjw@rjwysocki.net, ulf.hansson@linaro.org
Cc: linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	Lina Iyer <ilina@codeaurora.org>
Subject: [PATCH v6 1/3] PM / Domains: add domain feature flag for next wakeup
Date: Mon, 30 Nov 2020 15:50:37 -0700	[thread overview]
Message-ID: <20201130225039.15981-2-ilina@codeaurora.org> (raw)
In-Reply-To: <20201130225039.15981-1-ilina@codeaurora.org>

PM domains may support entering multiple power down states when the
component devices and sub-domains are suspended. Also, they may specify
the residency value for an idle state, only after which the idle state
may provide power benefits. If the domain does not specify the residency
for any of its idle states, the governor's choice is much simplified.

Let's make this optional with the use of a PM domain feature flag.

Signed-off-by: Lina Iyer <ilina@codeaurora.org>
---
Changes in v6:
	- New patch based on discussions on v5 of the series
---
 drivers/base/power/domain.c | 18 ++++++++++++++++++
 include/linux/pm_domain.h   | 28 ++++++++++++++++++++++------
 2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 1b0c9ccbbe1f..1e6c0bf1c945 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1748,6 +1748,24 @@ int dev_pm_genpd_remove_notifier(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(dev_pm_genpd_remove_notifier);
 
+/**
+ * genpd_enable_next_wakeup - Enable genpd gov to use next_wakeup
+ *
+ * @genpd: The genpd to be updated
+ * @enable: Enable/disable genpd gov to use next wakeup
+ */
+void genpd_enable_next_wakeup(struct generic_pm_domain *genpd, bool enable)
+{
+	genpd_lock(genpd);
+	if (enable)
+		genpd->flags |= GENPD_FLAG_GOV_NEXT_WAKEUP;
+	else
+		genpd->flags &= ~GENPD_FLAG_GOV_NEXT_WAKEUP;
+	genpd->next_wakeup = KTIME_MAX;
+	genpd_unlock(genpd);
+}
+EXPORT_SYMBOL_GPL(genpd_enable_next_wakeup);
+
 static int genpd_add_subdomain(struct generic_pm_domain *genpd,
 			       struct generic_pm_domain *subdomain)
 {
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 2ca919ae8d36..1f359bd19f77 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -55,13 +55,19 @@
  *
  * GENPD_FLAG_RPM_ALWAYS_ON:	Instructs genpd to always keep the PM domain
  *				powered on except for system suspend.
+ *
+ * GENPD_FLAG_GOV_NEXT_WAKEUP:	Enable the genpd governor to consider its
+ *				components' next wakeup when  determining the
+ *				optimal idle state. This is setup only if the
+ *				domain's idle state specifies a residency.
  */
-#define GENPD_FLAG_PM_CLK	 (1U << 0)
-#define GENPD_FLAG_IRQ_SAFE	 (1U << 1)
-#define GENPD_FLAG_ALWAYS_ON	 (1U << 2)
-#define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3)
-#define GENPD_FLAG_CPU_DOMAIN	 (1U << 4)
-#define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5)
+#define GENPD_FLAG_PM_CLK	   (1U << 0)
+#define GENPD_FLAG_IRQ_SAFE	   (1U << 1)
+#define GENPD_FLAG_ALWAYS_ON	   (1U << 2)
+#define GENPD_FLAG_ACTIVE_WAKEUP   (1U << 3)
+#define GENPD_FLAG_CPU_DOMAIN	   (1U << 4)
+#define GENPD_FLAG_RPM_ALWAYS_ON   (1U << 5)
+#define GENPD_FLAG_GOV_NEXT_WAKEUP (1U << 6)
 
 enum gpd_status {
 	GENPD_STATE_ON = 0,	/* PM domain is on */
@@ -205,6 +211,11 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev)
 	return to_gpd_data(dev->power.subsys_data->domain_data);
 }
 
+static inline bool genpd_may_use_next_wakeup(struct generic_pm_domain *genpd)
+{
+	return genpd->flags & GENPD_FLAG_GOV_NEXT_WAKEUP;
+}
+
 int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev);
 int pm_genpd_remove_device(struct device *dev);
 int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
@@ -217,6 +228,7 @@ int pm_genpd_remove(struct generic_pm_domain *genpd);
 int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state);
 int dev_pm_genpd_add_notifier(struct device *dev, struct notifier_block *nb);
 int dev_pm_genpd_remove_notifier(struct device *dev);
+void genpd_enable_next_wakeup(struct generic_pm_domain *genpd, bool enable);
 
 extern struct dev_power_governor simple_qos_governor;
 extern struct dev_power_governor pm_domain_always_on_gov;
@@ -275,6 +287,10 @@ static inline int dev_pm_genpd_remove_notifier(struct device *dev)
 	return -EOPNOTSUPP;
 }
 
+static void genpd_enable_next_wakeup(struct generic_pm_domain *genpd,
+				     bool enable)
+{ }
+
 #define simple_qos_governor		(*(struct dev_power_governor *)(NULL))
 #define pm_domain_always_on_gov		(*(struct dev_power_governor *)(NULL))
 #endif
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


  reply	other threads:[~2020-11-30 22:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 22:50 [PATCH v6 0/3] Better domain idle from device wakeup patterns Lina Iyer
2020-11-30 22:50 ` Lina Iyer [this message]
2020-12-22 13:06   ` [PATCH v6 1/3] PM / Domains: add domain feature flag for next wakeup Ulf Hansson
2021-01-04 15:54     ` Lina Iyer
2020-11-30 22:50 ` [PATCH v6 2/3] PM / domains: inform PM domain of a device's " Lina Iyer
2020-12-22 13:09   ` Ulf Hansson
2021-01-04 15:43     ` Lina Iyer
2021-01-08 10:07       ` Ulf Hansson
2020-11-30 22:50 ` [PATCH v6 3/3] PM / Domains: use device's next wakeup to determine domain idle state Lina Iyer
2020-12-22 14:41   ` Ulf Hansson
2020-12-08 17:26 ` [PATCH v6 0/3] Better domain idle from device wakeup patterns Rafael J. Wysocki
2020-12-09 10:36   ` Ulf Hansson
2020-12-09 15:18     ` Lina Iyer

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=20201130225039.15981-2-ilina@codeaurora.org \
    --to=ilina@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=ulf.hansson@linaro.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).