lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230327193829.3756640-2-abel.vesa@linaro.org>
Date:   Mon, 27 Mar 2023 22:38:26 +0300
From:   Abel Vesa <abel.vesa@...aro.org>
To:     "Rafael J. Wysocki" <rafael@...nel.org>,
        Kevin Hilman <khilman@...nel.org>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Pavel Machek <pavel@....cz>, Len Brown <len.brown@...el.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Bjorn Andersson <andersson@...nel.org>,
        Andy Gross <agross@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        Mike Turquette <mturquette@...libre.com>,
        Stephen Boyd <sboyd@...nel.org>,
        Saravana Kannan <saravanak@...gle.com>
Cc:     linux-pm@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-arm-msm@...r.kernel.org, linux-clk@...r.kernel.org,
        Doug Anderson <dianders@...omium.org>,
        Matthias Kaehlcke <mka@...omium.org>
Subject: [PATCH v3 1/4] PM: domains: Allow power off queuing from providers

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@...aro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@...aro.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ