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]
Date:   Thu,  2 Sep 2021 12:16:34 +0200
From:   Ulf Hansson <ulf.hansson@...aro.org>
To:     "Rafael J . Wysocki" <rjw@...ysocki.net>,
        Viresh Kumar <viresh.kumar@...aro.org>,
        Dmitry Osipenko <digetx@...il.com>, linux-pm@...r.kernel.org
Cc:     Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
        Jonathan Hunter <jonathanh@...dia.com>,
        Thierry Reding <thierry.reding@...il.com>,
        Rajendra Nayak <rnayak@...eaurora.org>,
        Stephan Gerhold <stephan@...hold.net>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Ulf Hansson <ulf.hansson@...aro.org>
Subject: [PATCH 3/3] PM: domains: Add a ->dev_get_performance_state() callback to genpd

Hardware may be preprogrammed to a specific performance state, which may
not be zero initially during boot. This may lead to that genpd's current
performance state becomes inconsistent with the state of the hardware. To
deal with this, the driver for a device that is being attached to its
genpd, need to request an initial performance state vote, which is
typically done by calling some of the OPP APIs while probing.

In some cases this would lead to boilerplate code in the drivers. Let's
make it possible to avoid this, by adding a new optional callback to genpd
and invoke it per device during the attach process. In this way, the genpd
provider driver can inform genpd about the initial performance state that
is needed for the device.

Signed-off-by: Ulf Hansson <ulf.hansson@...aro.org>
---
 drivers/base/power/domain.c | 8 +++++---
 include/linux/pm_domain.h   | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 800adf831cae..1a6f3538af8d 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2640,13 +2640,15 @@ static void genpd_dev_pm_sync(struct device *dev)
 	genpd_queue_power_off_work(pd);
 }
 
-static int genpd_get_default_performance_state(struct device *dev,
+static int genpd_get_default_performance_state(struct generic_pm_domain *genpd,
+					       struct device *dev,
 					       unsigned int index)
 {
 	int pstate = of_get_required_opp_performance_state(dev->of_node, index);
 
 	if (pstate == -ENODEV || pstate == -EOPNOTSUPP)
-		return 0;
+		pstate = genpd->dev_get_performance_state ?
+			 genpd->dev_get_performance_state(genpd, dev) : 0;
 
 	return pstate;
 }
@@ -2701,7 +2703,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
 	}
 
 	/* Set the default performance state */
-	pstate = genpd_get_default_performance_state(dev, index);
+	pstate = genpd_get_default_performance_state(pd, dev, index);
 	if (pstate < 0) {
 		ret = pstate;
 		goto err;
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 21a0577305ef..da694489a05a 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -131,6 +131,8 @@ struct generic_pm_domain {
 	struct opp_table *opp_table;	/* OPP table of the genpd */
 	unsigned int (*opp_to_performance_state)(struct generic_pm_domain *genpd,
 						 struct dev_pm_opp *opp);
+	int (*dev_get_performance_state)(struct generic_pm_domain *genpd,
+					 struct device *dev);
 	int (*set_performance_state)(struct generic_pm_domain *genpd,
 				     unsigned int state);
 	struct gpd_dev_ops dev_ops;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ