Re: [PATCH 0/2] Link consumer with clock driver

From: Stephen Boyd
Date: Fri Nov 30 2018 - 04:25:01 EST


Quoting Miquel Raynal (2018-11-22 13:22:10)
> Hello,
>
> While working on suspend to RAM feature, I ran into troubles multiple
> times when clocks where not suspending/resuming at the desired time. I
> had a look at the core and I think the same logic as in the
> regulator's core may be applied here to (very easily) fix this issue:
> using device links.

Thanks! I've wanted to add device links to the clk framework for a while
now but haven't gotten around to it. Can you expand on the scenario that
you've run into where you need this?

>
> The only additional change I had to do was to always (when available)
> populate the device entry of the core clock structure so that it could
> be used later. This is the purpose of patch 1. Patch 2 actually adds
> support for device links.

That's fine. We should do it into clk_core all the time for other
reasons too.

>
> As I am not used to hack into the clock subsystem I might have missed
> something big preventing such change but so far I could not see
> anything wrong with it. As this touches core code, I am of course
> entirely open to suggestions.
>

Two questions:

1) Do device links work if we make a loop between devices? I'm thinking
of the case where we have two clock controllers that provide clks to
each other and could potentially register some clks and then clk_get()
the ones they depend on. I suspect loops don't work and so we need to
be aware of this and somehow prevent it.

2) Do we need to link clk consumers to anything besides the device
providing the clk they get from clk_get()? Put another way, do we need
to make links through the clk tree and any potential parent clks of
whatever the device is using at the time. Would clk tree changing
topology because some new parent is chosen need to affect
suspend/resume ordering? Or would that all need to be handled by clk
framework figuring out the ordering of the tree at suspend/resume time
and suspending clock controller drivers in the right order?