2015-02-25 19:41:15

by Mike Turquette

[permalink] [raw]
Subject: Re: [PATCH] clk: Use lockdep asserts to find missing hold of prepare_lock

Quoting Krzysztof Kozlowski (2015-01-09 00:28:10)
> Add lockdep asserts for holding the prepare_lock to all functions
> marking this as a requirement in description. Add this to private and
> exported functions so all locking misuse could be detected during
> debugging.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Applied.

Thanks,
Mike

> ---
> drivers/clk/clk.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index f4963b7d4e17..cdbfaa34ace4 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -432,6 +432,8 @@ static void clk_unprepare_unused_subtree(struct clk *clk)
> {
> struct clk *child;
>
> + lockdep_assert_held(&prepare_lock);
> +
> if (!clk)
> return;
>
> @@ -458,6 +460,8 @@ static void clk_disable_unused_subtree(struct clk *clk)
> struct clk *child;
> unsigned long flags;
>
> + lockdep_assert_held(&prepare_lock);
> +
> if (!clk)
> goto out;
>
> @@ -947,6 +951,8 @@ unsigned long __clk_round_rate(struct clk *clk, unsigned long rate)
> struct clk *parent;
> struct clk_hw *parent_hw;
>
> + lockdep_assert_held(&prepare_lock);
> +
> if (!clk)
> return 0;
>
> @@ -1040,6 +1046,8 @@ static void __clk_recalc_accuracies(struct clk *clk)
> unsigned long parent_accuracy = 0;
> struct clk *child;
>
> + lockdep_assert_held(&prepare_lock);
> +
> if (clk->parent)
> parent_accuracy = clk->parent->accuracy;
>
> @@ -1104,6 +1112,8 @@ static void __clk_recalc_rates(struct clk *clk, unsigned long msg)
> unsigned long parent_rate = 0;
> struct clk *child;
>
> + lockdep_assert_held(&prepare_lock);
> +
> old_rate = clk->rate;
>
> if (clk->parent)
> @@ -1297,6 +1307,8 @@ static int __clk_speculate_rates(struct clk *clk, unsigned long parent_rate)
> unsigned long new_rate;
> int ret = NOTIFY_DONE;
>
> + lockdep_assert_held(&prepare_lock);
> +
> new_rate = clk_recalc(clk, parent_rate);
>
> /* abort rate change if a driver returns NOTIFY_BAD or NOTIFY_STOP */
> @@ -2110,6 +2122,8 @@ static void __clk_release(struct kref *ref)
> struct clk *clk = container_of(ref, struct clk, ref);
> int i = clk->num_parents;
>
> + lockdep_assert_held(&prepare_lock);
> +
> kfree(clk->parents);
> while (--i >= 0)
> kfree(clk->parent_names[i]);
> --
> 1.9.1
>