Re: [PATCH v2 1/4] [RFC] clk: new locking scheme for reentrancy

From: Shawn Guo
Date: Tue Sep 04 2012 - 10:25:04 EST


On Wed, Aug 15, 2012 at 04:43:31PM -0700, Mike Turquette wrote:
> +void __clk_unprepare(struct clk *clk, struct clk *top)
> +{
> if (clk->ops->unprepare)
> clk->ops->unprepare(clk->hw);
>
> - __clk_unprepare(clk->parent);
> + if (clk != top)
> + __clk_unprepare(clk->parent, top);
> +}

The __clk_unprepare does not match the __clk_prepare below in terms of
if we should call clk->ops->prepare/unprepare on top clock.

I have to change __clk_unprepare to something like the below to get
the series work on imx6q.

void __clk_unprepare(struct clk *clk, struct clk *top)
{
+ if (clk == top)
+ return;
+
if (clk->ops->unprepare)
clk->ops->unprepare(clk->hw);

- if (clk != top)
- __clk_unprepare(clk->parent, top);
+ __clk_unprepare(clk->parent, top);
}

> +int __clk_prepare(struct clk *clk, struct clk *top)
> +{
> + int ret = 0;
> +
> + if (clk != top) {
> + ret = __clk_prepare(clk->parent, top);
> if (ret)
> return ret;
>
> if (clk->ops->prepare) {
> ret = clk->ops->prepare(clk->hw);
> if (ret) {
> - __clk_unprepare(clk->parent);
> + /* this is safe since clk != top */
> + __clk_unprepare(clk->parent, top);
> return ret;
> }
> }
> }
>
> - clk->prepare_count++;
> -
> return 0;
> }

--
Regards,
Shawn
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/