Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1504647

[PATCH V2 2/8] PM / OPP: Don't use OPP structure outside of rcu protected section

From Viresh Kumar <viresh.kumar@linaro.org>
Newsgroups linux.kernel
Subject [PATCH V2 2/8] PM / OPP: Don't use OPP structure outside of rcu protected section
Date 2016-10-20 10:50 +0200
Message-ID <suhd0-5ak-27@gated-at.bofh.it> (permalink)
References <suhcZ-5ak-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The OPP structure must not be used out of the rcu protected section.
Cache the values to be used in separate variables instead.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/base/power/opp/core.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index 4c7c6da7a989..056527a3fb4e 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -584,6 +584,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 	struct clk *clk;
 	unsigned long freq, old_freq;
 	unsigned long u_volt, u_volt_min, u_volt_max;
+	unsigned long old_u_volt, old_u_volt_min, old_u_volt_max;
 	int ret;
 
 	if (unlikely(!target_freq)) {
@@ -633,6 +634,14 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 		return ret;
 	}
 
+	if (IS_ERR(old_opp)) {
+		old_u_volt = 0;
+	} else {
+		old_u_volt = old_opp->u_volt;
+		old_u_volt_min = old_opp->u_volt_min;
+		old_u_volt_max = old_opp->u_volt_max;
+	}
+
 	u_volt = opp->u_volt;
 	u_volt_min = opp->u_volt_min;
 	u_volt_max = opp->u_volt_max;
@@ -677,9 +686,10 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 			__func__, old_freq);
 restore_voltage:
 	/* This shouldn't harm even if the voltages weren't updated earlier */
-	if (!IS_ERR(old_opp))
-		_set_opp_voltage(dev, reg, old_opp->u_volt,
-				 old_opp->u_volt_min, old_opp->u_volt_max);
+	if (old_u_volt) {
+		_set_opp_voltage(dev, reg, old_u_volt, old_u_volt_min,
+				 old_u_volt_max);
+	}
 
 	return ret;
 }
-- 
2.7.1.410.g6faf27b

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V2 0/8] PM / OPP: Multiple regulator support Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-20 10:50 +0200
  [PATCH V2 4/8] PM / OPP: Pass struct dev_pm_opp_supply to _set_opp_voltage() Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-20 10:50 +0200
    Re: [PATCH V2 4/8] PM / OPP: Pass struct dev_pm_opp_supply to  _set_opp_voltage() Stephen Boyd <sboyd@codeaurora.org> - 2016-10-25 01:20 +0200
      Re: [PATCH V2 4/8] PM / OPP: Pass struct dev_pm_opp_supply to  _set_opp_voltage() Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-25 05:50 +0200
        Re: [PATCH V2 4/8] PM / OPP: Pass struct dev_pm_opp_supply to  _set_opp_voltage() Stephen Boyd <sboyd@codeaurora.org> - 2016-10-25 22:30 +0200
          Re: [PATCH V2 4/8] PM / OPP: Pass struct dev_pm_opp_supply to  _set_opp_voltage() Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-26 05:40 +0200
  [PATCH V2 2/8] PM / OPP: Don't use OPP structure outside of rcu protected section Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-20 10:50 +0200
    Re: [PATCH V2 2/8] PM / OPP: Don't use OPP structure outside of rcu  protected section Stephen Boyd <sboyd@codeaurora.org> - 2016-10-25 01:00 +0200
      Re: [PATCH V2 2/8] PM / OPP: Don't use OPP structure outside of rcu  protected section Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-25 05:40 +0200
  [PATCH V2 6/8] PM / OPP: Separate out _generic_opp_set_rate() Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-20 10:50 +0200
    Re: [PATCH V2 6/8] PM / OPP: Separate out _generic_opp_set_rate() Stephen Boyd <sboyd@codeaurora.org> - 2016-10-25 21:00 +0200
      Re: [PATCH V2 6/8] PM / OPP: Separate out _generic_opp_set_rate() Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-26 08:10 +0200
  [PATCH V2 7/8] PM / OPP: Allow platform specific custom opp_set_rate() callbacks Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-20 10:50 +0200
    Re: [PATCH V2 7/8] PM / OPP: Allow platform specific custom  opp_set_rate() callbacks Stephen Boyd <sboyd@codeaurora.org> - 2016-10-25 21:10 +0200
      Re: [PATCH V2 7/8] PM / OPP: Allow platform specific custom  opp_set_rate() callbacks Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-26 08:10 +0200
  [PATCH V2 1/8] PM / OPP: Reword binding supporting multiple regulators per device Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-20 11:00 +0200
    Re: [PATCH V2 1/8] PM / OPP: Reword binding supporting multiple  regulators per device Stephen Boyd <sboyd@codeaurora.org> - 2016-10-25 00:50 +0200
  Re: [PATCH V2 0/8] PM / OPP: Multiple regulator support "Rafael J. Wysocki" <rafael@kernel.org> - 2016-10-21 15:40 +0200
    Re: [PATCH V2 0/8] PM / OPP: Multiple regulator support Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-21 17:50 +0200
      Re: [PATCH V2 0/8] PM / OPP: Multiple regulator support Dave Gerlach <d-gerlach@ti.com> - 2016-10-24 03:10 +0200
        Re: [PATCH V2 0/8] PM / OPP: Multiple regulator support Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-24 06:30 +0200
          Re: [PATCH V2 0/8] PM / OPP: Multiple regulator support Dave Gerlach <d-gerlach@ti.com> - 2016-10-25 23:20 +0200
            Re: [PATCH V2 0/8] PM / OPP: Multiple regulator support Viresh Kumar <viresh.kumar@linaro.org> - 2016-10-26 05:30 +0200

csiph-web