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-next>] [day] [month] [year] [list]
Message-Id: <20200212075529.156756-1-drinkcat@chromium.org>
Date:   Wed, 12 Feb 2020 15:55:29 +0800
From:   Nicolas Boichat <drinkcat@...omium.org>
To:     Viresh Kumar <vireshk@...nel.org>
Cc:     Nishanth Menon <nm@...com>, Stephen Boyd <sboyd@...nel.org>,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] PM / OPP: Add support for multiple regulators

The OPP table can contain multiple voltages and regulators, and
implementing that logic does not add a lot of code or complexity,
so let's modify _generic_set_opp_regulator to support that use
case.

Signed-off-by: Nicolas Boichat <drinkcat@...omium.org>

---

This is required to add panfrost support for the Bifrost GPU
in MT8183, see this patch:
https://patchwork.kernel.org/patch/11369821/

 drivers/opp/core.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index ba43e6a3dc0aeed..ea4a12a8932014f 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -650,6 +650,24 @@ static int _set_opp_voltage(struct device *dev, struct regulator *reg,
 	return ret;
 }
 
+/*
+ * Set multiple voltages. The caller is responsible for restoring all the
+ * voltages if the function fails.
+ */
+static int _set_opp_voltages(struct device *dev, struct regulator **regs,
+			struct dev_pm_opp_supply *supplies, int count)
+{
+	int i, ret;
+
+	for (i = 0; i < count; i++) {
+		ret = _set_opp_voltage(dev, regs[i], &supplies[i]);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
 static inline int _generic_set_opp_clk_only(struct device *dev, struct clk *clk,
 					    unsigned long freq)
 {
@@ -671,18 +689,13 @@ static int _generic_set_opp_regulator(const struct opp_table *opp_table,
 				      struct dev_pm_opp_supply *old_supply,
 				      struct dev_pm_opp_supply *new_supply)
 {
-	struct regulator *reg = opp_table->regulators[0];
+	struct regulator **regs = opp_table->regulators;
+	int count = opp_table->regulator_count;
 	int ret;
 
-	/* This function only supports single regulator per device */
-	if (WARN_ON(opp_table->regulator_count > 1)) {
-		dev_err(dev, "multiple regulators are not supported\n");
-		return -EINVAL;
-	}
-
 	/* Scaling up? Scale voltage before frequency */
 	if (freq >= old_freq) {
-		ret = _set_opp_voltage(dev, reg, new_supply);
+		ret = _set_opp_voltages(dev, regs, new_supply, count);
 		if (ret)
 			goto restore_voltage;
 	}
@@ -694,7 +707,7 @@ static int _generic_set_opp_regulator(const struct opp_table *opp_table,
 
 	/* Scaling down? Scale voltage after frequency */
 	if (freq < old_freq) {
-		ret = _set_opp_voltage(dev, reg, new_supply);
+		ret = _set_opp_voltages(dev, regs, new_supply, count);
 		if (ret)
 			goto restore_freq;
 	}
@@ -708,7 +721,7 @@ static int _generic_set_opp_regulator(const struct opp_table *opp_table,
 restore_voltage:
 	/* This shouldn't harm even if the voltages weren't updated earlier */
 	if (old_supply)
-		_set_opp_voltage(dev, reg, old_supply);
+		_set_opp_voltages(dev, regs, old_supply, count);
 
 	return ret;
 }
-- 
2.25.0.225.g125e21ebc7-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ