diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2016-12-01 05:58:16 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-06 04:40:15 -0500 |
commit | 7ac62bcde2d417777a40ced09d958f99ed9009c9 (patch) | |
tree | 30b5565f43a43507ec972fee2aca2a6cbffb6e99 | |
parent | c7a8a0ac8fee26d3c20402da306a17bcbbbb367b (diff) |
PM / OPP: Don't use OPP structure outside of rcu protected section
commit dc39d06fcd7a4a82d72eae7b71e94e888b96d29e upstream.
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>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Tested-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/base/power/opp/core.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 2824d3a5e9f0..6441dfda489f 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) | |||
584 | struct clk *clk; | 584 | struct clk *clk; |
585 | unsigned long freq, old_freq; | 585 | unsigned long freq, old_freq; |
586 | unsigned long u_volt, u_volt_min, u_volt_max; | 586 | unsigned long u_volt, u_volt_min, u_volt_max; |
587 | unsigned long old_u_volt, old_u_volt_min, old_u_volt_max; | ||
587 | int ret; | 588 | int ret; |
588 | 589 | ||
589 | if (unlikely(!target_freq)) { | 590 | if (unlikely(!target_freq)) { |
@@ -633,6 +634,14 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) | |||
633 | return ret; | 634 | return ret; |
634 | } | 635 | } |
635 | 636 | ||
637 | if (IS_ERR(old_opp)) { | ||
638 | old_u_volt = 0; | ||
639 | } else { | ||
640 | old_u_volt = old_opp->u_volt; | ||
641 | old_u_volt_min = old_opp->u_volt_min; | ||
642 | old_u_volt_max = old_opp->u_volt_max; | ||
643 | } | ||
644 | |||
636 | u_volt = opp->u_volt; | 645 | u_volt = opp->u_volt; |
637 | u_volt_min = opp->u_volt_min; | 646 | u_volt_min = opp->u_volt_min; |
638 | u_volt_max = opp->u_volt_max; | 647 | u_volt_max = opp->u_volt_max; |
@@ -677,9 +686,10 @@ restore_freq: | |||
677 | __func__, old_freq); | 686 | __func__, old_freq); |
678 | restore_voltage: | 687 | restore_voltage: |
679 | /* This shouldn't harm even if the voltages weren't updated earlier */ | 688 | /* This shouldn't harm even if the voltages weren't updated earlier */ |
680 | if (!IS_ERR(old_opp)) | 689 | if (old_u_volt) { |
681 | _set_opp_voltage(dev, reg, old_opp->u_volt, | 690 | _set_opp_voltage(dev, reg, old_u_volt, old_u_volt_min, |
682 | old_opp->u_volt_min, old_opp->u_volt_max); | 691 | old_u_volt_max); |
692 | } | ||
683 | 693 | ||
684 | return ret; | 694 | return ret; |
685 | } | 695 | } |