Re: Locking in the clk API

From: Paul Mundt
Date: Tue Jan 11 2011 - 05:15:30 EST


On Tue, Jan 11, 2011 at 05:44:59PM +0800, Jeremy Kerr wrote:
> So, it sounds like the best approach is to provide an atomic clk_enable. I
> agree with Sascha that the clk_enable and clk_enable_atomic polarity makes the
> most sense, so how about:
>
> int clk_enable(struct clk *clk)
> {
> might_sleep();
>
> [...]
> }
>
> int clk_enable_atomic(struct clk *clk)
> {
> BUG_ON(!(clk->flags & CLK_ATOMIC));
>
> [...]
> }
>
> Paul: even though you mention that the atomic clocks are the usual case, I
> think that this way around illustrates the atomic 'restriction' at the call
> site more clearly. When the drivers don't care about the atomicity,
> clk_enable() is fine. When drivers do need an atomic clock,
> clk_enable_atomic() shows this requirement.
>
No, the sleeping clock case is and always will be a corner case, and I
have no interest in pretending otherwise. On SH we have hundreds of
clocks that are all usable in the atomic context and perhaps less than a
dozen that aren't (and even in those cases much of the PLL negotiation is
handled in hardware so there's never any visibility for the lock-down
from the software side, other architectures also have similar behaviour).

Keep in mind that all users except for the few that you cited were
already quite content with the atomic context use, so this 'restriction'
you speak of is just an artificial limitation introduced by a couple of
new platforms that deviated from what everyone else was already doing.

If you want to go this route, then SH and ARM-based SH-Mobiles will at
least not be making use of the generic struct clk.
--
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/