[PATCH 04/11] watchdog: ftwdt010: Add clock support

Linus Walleij linus.walleij at linaro.org
Tue Oct 10 12:51:26 PDT 2017


On Sun, Aug 27, 2017 at 7:06 PM, Guenter Roeck <linux at roeck-us.net> wrote:
> On Thu, Aug 24, 2017 at 10:32:22PM +0200, Linus Walleij wrote:
>> On Mon, Aug 14, 2017 at 6:05 PM, Guenter Roeck <linux at roeck-us.net> wrote:
>>
>> >> +     gwdt->pclk = devm_clk_get(dev, "PCLK");
>> >> +     if (!IS_ERR(gwdt->pclk)) {
>> >
>> > devm_clk_get() can return NULL (if the clock subsystem is not enabled).
>>
>> That is fine I think? Because if the clock subsysten is not enabled
>> all the clk_prepare() etc becomes stubs as well and the driver
>> is happy. I think this is intended.
>
> If I understand your comment below correctly, the driver won't work
> without clock subsystem because the clock frequency would in that case
> be 0. Why not catch that situation here, or even better make the driver
> depends on the clock subsystem ?

OK fair enough I can do that.

I think Aspeed is merging its clock driver this kernel cycle
so all variant SoCs actually have clocks.

>> The driver strictly needs this frequency
>> so we cannot really work without it and it needs to fail
>> over here.
>>
> Repeating from above, doesn't that mean that the driver depends
> on the clock subsystem ? Or am I missong some context ?

Usually in the kernel, it is acceptable to let stub clocks
kick in when compiling out the clock subsystem.

I think people assume that in this state, all clocks are simply
turned on and at nominal speed, all over the place. So it
usually doesn't matter that it gets compiled out.

But in a sense that is simplistic and as this driver shows
we really do depend on the clocks to run some business
like timers, so in practice it is a bad idea. Clocksources
definately cannot live without their clocks for example.
So I think strictly requireing it is OK.

>> > Note that I would
>> > resist replacing all the devm_ functions with non-devm equivalents just
>> > because the clock subsystem doesn't provide the necessary API functions.
>>
>> I've seen people do this for this reason though :/
>>
> Yes, but that doesn't make it better.

Stephen Boyd <sboyd at codeaurora.org> wrote:

> I'd still prefer we just disable clks on clk_put(),

Which means that devm_clk_get() will do the job
implicitly already.

> but Russell
> said we needed to fix all non-common clk implementations of the
> clk API to do that and then I forgot about the topic (so
> anti-climatic). I'm pretty much OK with us merging the temporary
> solution.

I guess that means the watchdog-local hack that
Guenther suggested.

But I'm not in any hurry. Instead of solving the simple problem,
why not solve the supercomplicated problem.

So the task is to look over all non generic clock implementations
and make them conform to disabling the clocks on clk_put().
No big deal. (Famous last words.)

How many local clock implementations can there be?
I will look into it.

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list