ipq806x: switch to linux 4.14
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.9 / 0050-OPP-Allow-notifiers-to-call-dev_pm_opp_get_-voltage-.patch
1 From 4a17bbfcf72c94b37079e39a7c1e1e8653f7fe92 Mon Sep 17 00:00:00 2001
2 From: Stephen Boyd <sboyd@codeaurora.org>
3 Date: Fri, 18 Sep 2015 17:52:07 -0700
4 Subject: [PATCH 50/69] OPP: Allow notifiers to call dev_pm_opp_get_{voltage,
5 freq} RCU-free
6
7 We pass the dev_pm_opp structure to OPP notifiers but the users
8 of the notifier need to surround calls to dev_pm_opp_get_*() with
9 RCU read locks to avoid lockdep warnings. The notifier is already
10 called with the dev_opp's srcu lock held, so it should be safe to
11 assume the devm_pm_opp structure is already protected inside the
12 notifier. Update the lockdep check for this.
13
14 Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
15 Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
16 Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
17 Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
18 ---
19 drivers/base/power/opp/core.c | 19 ++++++++++---------
20 1 file changed, 10 insertions(+), 9 deletions(-)
21
22 --- a/drivers/base/power/opp/core.c
23 +++ b/drivers/base/power/opp/core.c
24 @@ -32,9 +32,10 @@ LIST_HEAD(opp_tables);
25 /* Lock to allow exclusive modification to the device and opp lists */
26 DEFINE_MUTEX(opp_table_lock);
27
28 -#define opp_rcu_lockdep_assert() \
29 +#define opp_rcu_lockdep_assert(s) \
30 do { \
31 RCU_LOCKDEP_WARN(!rcu_read_lock_held() && \
32 + !(s && srcu_read_lock_held(s)) && \
33 !lockdep_is_held(&opp_table_lock), \
34 "Missing rcu_read_lock() or " \
35 "opp_table_lock protection"); \
36 @@ -72,7 +73,7 @@ struct opp_table *_find_opp_table(struct
37 {
38 struct opp_table *opp_table;
39
40 - opp_rcu_lockdep_assert();
41 + opp_rcu_lockdep_assert(NULL);
42
43 if (IS_ERR_OR_NULL(dev)) {
44 pr_err("%s: Invalid parameters\n", __func__);
45 @@ -106,7 +107,7 @@ unsigned long dev_pm_opp_get_voltage(str
46 struct dev_pm_opp *tmp_opp;
47 unsigned long v = 0;
48
49 - opp_rcu_lockdep_assert();
50 + opp_rcu_lockdep_assert(NULL);
51
52 tmp_opp = rcu_dereference(opp);
53 if (IS_ERR_OR_NULL(tmp_opp))
54 @@ -138,7 +139,7 @@ unsigned long dev_pm_opp_get_freq(struct
55 struct dev_pm_opp *tmp_opp;
56 unsigned long f = 0;
57
58 - opp_rcu_lockdep_assert();
59 + opp_rcu_lockdep_assert(NULL);
60
61 tmp_opp = rcu_dereference(opp);
62 if (IS_ERR_OR_NULL(tmp_opp) || !tmp_opp->available)
63 @@ -172,7 +173,7 @@ bool dev_pm_opp_is_turbo(struct dev_pm_o
64 {
65 struct dev_pm_opp *tmp_opp;
66
67 - opp_rcu_lockdep_assert();
68 + opp_rcu_lockdep_assert(NULL);
69
70 tmp_opp = rcu_dereference(opp);
71 if (IS_ERR_OR_NULL(tmp_opp) || !tmp_opp->available) {
72 @@ -300,7 +301,7 @@ struct dev_pm_opp *dev_pm_opp_get_suspen
73 {
74 struct opp_table *opp_table;
75
76 - opp_rcu_lockdep_assert();
77 + opp_rcu_lockdep_assert(NULL);
78
79 opp_table = _find_opp_table(dev);
80 if (IS_ERR(opp_table) || !opp_table->suspend_opp ||
81 @@ -380,7 +381,7 @@ struct dev_pm_opp *dev_pm_opp_find_freq_
82 struct opp_table *opp_table;
83 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
84
85 - opp_rcu_lockdep_assert();
86 + opp_rcu_lockdep_assert(NULL);
87
88 opp_table = _find_opp_table(dev);
89 if (IS_ERR(opp_table)) {
90 @@ -444,7 +445,7 @@ struct dev_pm_opp *dev_pm_opp_find_freq_
91 {
92 struct opp_table *opp_table;
93
94 - opp_rcu_lockdep_assert();
95 + opp_rcu_lockdep_assert(NULL);
96
97 if (!dev || !freq) {
98 dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq);
99 @@ -486,7 +487,7 @@ struct dev_pm_opp *dev_pm_opp_find_freq_
100 struct opp_table *opp_table;
101 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
102
103 - opp_rcu_lockdep_assert();
104 + opp_rcu_lockdep_assert(NULL);
105
106 if (!dev || !freq) {
107 dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq);