From: Abel Vesa <abel.vesa@linaro.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Kevin Hilman <khilman@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>, Pavel Machek <pavel@ucw.cz>,
Len Brown <len.brown@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bjorn Andersson <andersson@kernel.org>,
Andy Gross <agross@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Mike Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Saravana Kannan <saravanak@google.com>
Cc: linux-pm@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
Doug Anderson <dianders@chromium.org>,
Matthias Kaehlcke <mka@chromium.org>
Subject: [PATCH v3 1/4] PM: domains: Allow power off queuing from providers
Date: Mon, 27 Mar 2023 22:38:26 +0300 [thread overview]
Message-ID: <20230327193829.3756640-2-abel.vesa@linaro.org> (raw)
In-Reply-To: <20230327193829.3756640-1-abel.vesa@linaro.org>
In some cases, the providers might choose to refuse powering off some
domains until all of the consumers have had a chance to probe, that is,
until sync state callback has been called. Such providers might choose
to disable such domains on their own, from the sync state callback. So,
in order to do that, they need a way to queue up a power off request.
Since the generic genpd already has such API, make that available to
those providers.
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/base/power/domain.c | 18 ++++++++++--------
include/linux/pm_domain.h | 4 ++++
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 32084e38b73d..209b8152e948 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -643,16 +643,18 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed)
}
/**
- * genpd_queue_power_off_work - Queue up the execution of genpd_power_off().
+ * pm_genpd_queue_power_off - Queue up the execution of genpd_power_off().
* @genpd: PM domain to power off.
*
* Queue up the execution of genpd_power_off() unless it's already been done
- * before.
+ * before. The sole purpose of this being exported is to allow the providers
+ * to disable the unused domains from their sync_state callback.
*/
-static void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
+void pm_genpd_queue_power_off(struct generic_pm_domain *genpd)
{
queue_work(pm_wq, &genpd->power_off_work);
}
+EXPORT_SYMBOL_GPL(pm_genpd_queue_power_off);
/**
* genpd_power_off - Remove power from a given PM domain.
@@ -1096,7 +1098,7 @@ static int __init genpd_power_off_unused(void)
mutex_lock(&gpd_list_lock);
list_for_each_entry(genpd, &gpd_list, gpd_list_node)
- genpd_queue_power_off_work(genpd);
+ pm_genpd_queue_power_off(genpd);
mutex_unlock(&gpd_list_lock);
@@ -1431,7 +1433,7 @@ static void genpd_complete(struct device *dev)
genpd->prepared_count--;
if (!genpd->prepared_count)
- genpd_queue_power_off_work(genpd);
+ pm_genpd_queue_power_off(genpd);
genpd_unlock(genpd);
}
@@ -2703,7 +2705,7 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
}
/* Check if PM domain can be powered off after removing this device. */
- genpd_queue_power_off_work(pd);
+ pm_genpd_queue_power_off(pd);
/* Unregister the device if it was created by genpd. */
if (dev->bus == &genpd_bus_type)
@@ -2718,7 +2720,7 @@ static void genpd_dev_pm_sync(struct device *dev)
if (IS_ERR(pd))
return;
- genpd_queue_power_off_work(pd);
+ pm_genpd_queue_power_off(pd);
}
static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
@@ -2879,7 +2881,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
}
pm_runtime_enable(virt_dev);
- genpd_queue_power_off_work(dev_to_genpd(virt_dev));
+ pm_genpd_queue_power_off(dev_to_genpd(virt_dev));
return virt_dev;
}
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index f776fb93eaa0..b7991bf98e1c 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -231,6 +231,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
int pm_genpd_init(struct generic_pm_domain *genpd,
struct dev_power_governor *gov, bool is_off);
int pm_genpd_remove(struct generic_pm_domain *genpd);
+void pm_genpd_queue_power_off(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);
@@ -278,6 +279,9 @@ static inline int pm_genpd_remove(struct generic_pm_domain *genpd)
return -EOPNOTSUPP;
}
+static inline void pm_genpd_queue_power_off(struct generic_pm_domain *genpd)
+{ }
+
static inline int dev_pm_genpd_set_performance_state(struct device *dev,
unsigned int state)
{
--
2.34.1
next prev parent reply other threads:[~2023-03-27 19:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 19:38 [PATCH v3 0/4] Allow genpd providers to power off domains on sync state Abel Vesa
2023-03-27 19:38 ` Abel Vesa [this message]
2023-03-27 19:38 ` [PATCH v3 2/4] soc: qcom: rpmhpd: Do proper power off when state synced Abel Vesa
2023-04-11 3:06 ` Bjorn Andersson
2023-03-27 19:38 ` [PATCH v3 3/4] clk: qcom: gdsc: Avoid actual power off until sync state Abel Vesa
2023-03-27 19:38 ` [PATCH v3 4/4] clk: qcom: Add sync state callback to all providers Abel Vesa
2023-03-28 0:17 ` [PATCH v3 0/4] Allow genpd providers to power off domains on sync state Saravana Kannan
2023-03-30 11:27 ` Abel Vesa
2023-03-30 19:50 ` Saravana Kannan
2023-03-31 4:59 ` Abel Vesa
2023-04-05 14:11 ` Ulf Hansson
2023-04-06 9:26 ` Abel Vesa
2023-04-06 10:59 ` Ulf Hansson
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=20230327193829.3756640-2-abel.vesa@linaro.org \
--to=abel.vesa@linaro.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=khilman@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=len.brown@intel.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mka@chromium.org \
--cc=mturquette@baylibre.com \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=saravanak@google.com \
--cc=sboyd@kernel.org \
--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