PM / OPP: Assert RCU lock in exported functions
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Fri, 9 Jan 2015 08:27:57 +0000 (09:27 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 23 Jan 2015 21:32:38 +0000 (22:32 +0100)
Add lockdep asserts for holding the RCU lock when calling
dev_pm_opp_get_freq() and dev_pm_opp_get_voltage() to aid in detecting
RCU misuses.

These are called often after dev_pm_opp_find_freq_ceil/exact() which
already asserts for RCU lock. However one could make an error by
releasing lock too early - just after dev_pm_opp_find_freq_ceil().

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/opp.c

index 1d20e095569cfb8ba7bbc25aa312cd9aa154b673..15bf29974c312a83fbf18c3a78b4b00f5d858cd5 100644 (file)
@@ -169,6 +169,8 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
        struct dev_pm_opp *tmp_opp;
        unsigned long v = 0;
 
+       opp_rcu_lockdep_assert();
+
        tmp_opp = rcu_dereference(opp);
        if (unlikely(IS_ERR_OR_NULL(tmp_opp)) || !tmp_opp->available)
                pr_err("%s: Invalid parameters\n", __func__);
@@ -199,6 +201,8 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
        struct dev_pm_opp *tmp_opp;
        unsigned long f = 0;
 
+       opp_rcu_lockdep_assert();
+
        tmp_opp = rcu_dereference(opp);
        if (unlikely(IS_ERR_OR_NULL(tmp_opp)) || !tmp_opp->available)
                pr_err("%s: Invalid parameters\n", __func__);