linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephan Gerhold <stephan@gerhold.net>
To: Stephen Boyd <sboyd@kernel.org>
Cc: Jeffrey Hugo <jeffrey.l.hugo@gmail.com>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Michael Turquette <mturquette@baylibre.com>,
	MSM <linux-arm-msm@vger.kernel.org>,
	linux-clk@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht,
	Georgi Djakov <georgi.djakov@linaro.org>
Subject: Re: [PATCH] clk: qcom: smd: Disable unused clocks
Date: Fri, 21 Aug 2020 08:48:57 +0200	[thread overview]
Message-ID: <20200821064857.GA905@gerhold.net> (raw)
In-Reply-To: <159796605593.334488.8355244657387381953@swboyd.mtv.corp.google.com>

On Thu, Aug 20, 2020 at 04:27:35PM -0700, Stephen Boyd wrote:
> Quoting Stephan Gerhold (2020-08-18 01:07:38)
> > Hi Jeffrey,
> > 
> > On Mon, Aug 17, 2020 at 08:52:46AM -0600, Jeffrey Hugo wrote:
> > > So essentially, when the clk framework goes through late init, and
> > > decides to turn off clocks that are not being used, it will also turn
> > > off these clocks?
> > > 
> > > I think this is going to break other targets where other subsystems
> > > happen to rely on these sorts of votes from Linux inorder to run/boot
> > > (not saying it's a good thing, just that is how it is and since we
> > > can't change the FW on those....).
> > > 
> > 
> > After thinking about it some more I realized there are definitely some
> > of the clocks we shouldn't disable even when unused, for example the
> > interconnect clocks. With interconnect drivers disabled the system
> > basically locked up entirely once the clock core disabled the clocks.
> 
> The interconnect clks should be moved out of the RPM clk drivers. It's
> over-engineering to have the RPM interconnect drivers talk to the RPM
> clk drivers to change the frequency of interconnects based on a
> calculation in the interconnect driver. It makes sense from a logical
> perspective to express that these are clks, and they have frequencies,
> etc., but when you look closer at it you see that it's nonsense.
> 
> The RPMh interconnect driver should be able to talk directly to the RPM

Note: I'm talking about the clk-smd-rpm (+ SMD RPM interconnect)
drivers here (not RPMh), but I guess the same applies for that as well.

> and turn knobs as it see fit. Nobody else is going to use those clks
> from the RPM clk driver. Any potential consumer is going to go through
> the interconnect layer to change frequencies. So now we've got two
> frameworks interfacing with the same wire protocol and remote processor,
> when we could have only one. And furthermore to the point, the RPM
> interconnect clks are all parented to nothing, so putting them behind
> the clk APIs provides practically zero benefits, like managing the clk
> tree or determining rates down the tree.
> 

That makes sense to me since it would also prevent these clocks from
getting "disabled" when unused.

> Honestly I'd like to see all the various RPM drivers combined into one
> driver that knows what is going on between regulators, interconnects,
> and clks, etc. Carving it up into these different drivers spread across
> the tree helps us review the code and logically split the device into
> pieces, but the flip side is that nobody sees the big picture that a
> call into a framework here boils down to a couple RPM messages sent over
> the wire to the same device.
> 

I'm not sure, most of the RPM drivers are basically pretty much just
long struct definitions for the available regulators, clks,
interconnects, ... of one SoC. Combining this all into one driver would
likely become rather "messy"...

> > For now I fixed this by marking all of DEFINE_CLK_SMD_RPM() as
> > CLK_IGNORE_UNUSED (essentially restoring the current behavior of the
> > driver). For MSM8916 these are exactly the interconnect clocks, but on
> > other platforms there are further clocks that might not need
> > CLK_IGNORE_UNUSED. This could be still optimized later.
> > 
> > > I think this needs to be validated on every single qcom platform using
> > > this driver.
> > > 
> > 
> > After running into the issue above I kind of agree with you. While
> > problems should be limited by marking the "rate" clocks as
> > CLK_IGNORE_UNUSED, it's also possible that one of the platforms requires
> > one of the branch clocks to stay on to boot successfully.
> > 
> > I know for sure that this works properly on MSM8916, so maybe I should
> > make it opt-in and then we add it for each platform after validating it?
> > 
> 
> No! Instead of putting band-aids on this broken mess, please just move
> the interconnect clks out of the clk driver and into the interconnect
> driver.
> 

Hmm, I'm not sure how to implement this in a backwards compatible way.
In particular, clk-smd-rpm supports SoCs that:

  - Have no interconnect driver at all (MSM8998, SDM660, ...)
  - Had the interconnect device nodes added much later than rpmcc
    (MSM8916, MSM8974, ...)
  - Have some clocks that are not covered by the interconnect drivers yet,
    e.g. RPM_SMD_GFX3D_CLK_SRC (Is this even interconnect? Not sure...)

In all those cases they likely (implicitly) rely on rpmcc to keep all
clocks at maximum rate, even if unused. If we were to move the
interconnect clock management to the interconnect drivers, we would
still need to handle the clocks somewhere in all those cases.

How would this work?

Thanks,
Stephan

      reply	other threads:[~2020-08-21  6:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17 14:09 [PATCH] clk: qcom: smd: Disable unused clocks Stephan Gerhold
2020-08-17 14:52 ` Jeffrey Hugo
2020-08-17 15:28   ` Stephan Gerhold
2020-08-17 15:46     ` Jeffrey Hugo
2020-08-17 16:13       ` Stephan Gerhold
2020-08-18  8:07   ` Stephan Gerhold
2020-08-20 23:27     ` Stephen Boyd
2020-08-21  6:48       ` Stephan Gerhold [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200821064857.GA905@gerhold.net \
    --to=stephan@gerhold.net \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=georgi.djakov@linaro.org \
    --cc=jeffrey.l.hugo@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).