linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Andy Gross <agross@kernel.org>,
	Anusha Rao <quic_anusha@quicinc.com>,
	Bjorn Andersson <andersson@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Devi Priya <quic_devipriy@quicinc.com>,
	Gokul Sriram Palanisamy <quic_gokulsri@quicinc.com>,
	Jassi Brar <jassisinghbrar@gmail.com>,
	Kathiravan Thirumoorthy <quic_kathirav@quicinc.com>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Rob Herring <robh+dt@kernel.org>,
	Sricharan Ramabadhran <quic_srichara@quicinc.com>,
	Varadarajan Narayanan <quic_varada@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 01/11] clk: qcom: ipq8074: drop the CLK_SET_RATE_PARENT flag from PLL clocks
Date: Thu, 19 Oct 2023 15:08:41 -0700	[thread overview]
Message-ID: <4f4803d538c6727990cda8f2e4fd7397.sboyd@kernel.org> (raw)
In-Reply-To: <76b652c8-041c-49d6-9804-2781fe2ccfe3@linaro.org>

Quoting Konrad Dybcio (2023-10-19 04:22:33)
> 
> 
> On 10/19/23 02:16, Stephen Boyd wrote:
> > Quoting Konrad Dybcio (2023-09-15 05:19:56)
> >> On 14.09.2023 08:59, Kathiravan Thirumoorthy wrote:
> >>> GPLL, NSS crypto PLL clock rates are fixed and shouldn't be scaled based
> >>> on the request from dependent clocks. Doing so will result in the
> >>> unexpected behaviour. So drop the CLK_SET_RATE_PARENT flag from the PLL
> >>> clocks.
> >>>
> >>> Cc: stable@vger.kernel.org
> >>> Fixes: b8e7e519625f ("clk: qcom: ipq8074: add remaining PLL’s")
> >>> Signed-off-by: Kathiravan Thirumoorthy <quic_kathirav@quicinc.com>
> >>> ---
> >> Stephen, do you think there should be some sort of error
> >> or at least warning thrown when SET_RATE_PARENT is used with
> >> RO ops?
> >>
> > 
> > Sure? How would that be implemented?
> drivers/clk/clk.c : static void clk_change_rate()
> 
> if (!skip_set_rate && core->ops->set_rate)
>         core->ops->set_rate(core->hw, core->new_rate, best_parent_rate);
> 
> ->
> 
> if (!skip_set_rate) {
>         if (core->ops->set_rate)
>                 core->ops->set_rate(core->hw, core->new_rate,
>                                     best_parent_rate);
>         else
>                 pr_err("bad idea");
> }
> 

CLK_SET_RATE_PARENT means that "calling clk_set_rate() on this clk will
propagate up to the parent". Changing the rate of the parent could
change the rate of this clk to be the same frequency as the parent if
this clk doesn't have a set_rate clk op, or it could be that this clk
has a fixed divider so during the determine_rate() callback it
calculated what rate the parent should be to achieve the requested rate
in clk_set_rate().

It really matters what determine_rate() returns for a clk and if after
changing rates that rate is actually achieved. I suppose if the
determine_rate() callback returns some rate, and then we recalc rates
and notice that the rate determined earlier doesn't match we're
concerned. So far in the last decade we've never cared about this though
and I'm hesitant to start adding that check. I believe some qcom clk
drivers take a shortcut and round the rate in frequency tables so
whatever is returned in determine_rate() doesn't match what
recalc_rate() calculates.

It would be interesting to get rid of the CLK_SET_RATE_PARENT check in
clk_calc_new_rates() and simply always call clk_calc_new_rates() on the
parent if the parent->rate doesn't match what determine_rate thought it
should be. The framework currently calls the rounding clk op for a clk
and gets back the parent rate that the clk requires to achieve that rate
and then it blindly trusts that the parent rate is going to be achieved.
If the CLK_SET_RATE_PARENT flag is set it calls clk_calc_new_rates()
recursively on the parent, but then it doesn't check that the parent
rate is what was requested. That's mostly there to figure out if the
parent also needs to change rate, i.e. calculating the 'top' clk in a
rate change. Note that this also calls determine_rate again on the
parent, once from the child clk's determine_rate clk op and once from
the framework.

I wouldn't be surprised if some driver is relying on this behavior where
the rate isn't checked after being set. Maybe when we extend struct
clk_rate_request to have a linked list that allows a clk to build up a
chain of rate requests we can also enforce more things like matching
rates on recalc. Then any drivers that are relying on this behavior will
have to opt in to a different method of changing rates and notice that
things aren't working.

  reply	other threads:[~2023-10-19 22:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14  6:59 [PATCH v2 00/11] Add GPLL0 as clock provider for the Qualcomm's IPQ mailbox controller Kathiravan Thirumoorthy
2023-09-14  6:59 ` [PATCH v2 01/11] clk: qcom: ipq8074: drop the CLK_SET_RATE_PARENT flag from PLL clocks Kathiravan Thirumoorthy
2023-09-15 12:19   ` Konrad Dybcio
2023-10-19  0:16     ` Stephen Boyd
2023-10-19 11:22       ` Konrad Dybcio
2023-10-19 22:08         ` Stephen Boyd [this message]
2023-09-14  6:59 ` [PATCH v2 02/11] clk: qcom: ipq6018: " Kathiravan Thirumoorthy
2023-09-27 11:32   ` Konrad Dybcio
2023-09-14  6:59 ` [PATCH v2 03/11] clk: qcom: ipq5018: drop the CLK_SET_RATE_PARENT flag from GPLL clocks Kathiravan Thirumoorthy
2023-09-27 11:32   ` Konrad Dybcio
2023-09-14  6:59 ` [PATCH v2 04/11] clk: qcom: ipq9574: " Kathiravan Thirumoorthy
2023-09-27 11:32   ` Konrad Dybcio
2023-09-14  6:59 ` [PATCH v2 05/11] clk: qcom: ipq5332: " Kathiravan Thirumoorthy
2023-09-27 11:33   ` Konrad Dybcio
2023-09-14  6:59 ` [PATCH v2 06/11] dt-bindings: mailbox: qcom: add one more clock provider for IPQ mailbox Kathiravan Thirumoorthy
2023-09-14  6:59 ` [PATCH v2 07/11] clk: qcom: apss-ipq6018: add the GPLL0 clock also as clock provider Kathiravan Thirumoorthy
2023-09-14  6:59 ` [PATCH v2 08/11] arm64: dts: qcom: ipq8074: include the GPLL0 as clock provider for mailbox Kathiravan Thirumoorthy
2023-09-27 11:33   ` Konrad Dybcio
2023-09-27 12:12     ` Kathiravan Thirumoorthy
2023-09-14  6:59 ` [PATCH v2 09/11] arm64: dts: qcom: ipq6018: " Kathiravan Thirumoorthy
2023-09-27 11:33   ` Konrad Dybcio
2023-09-14  7:00 ` [PATCH v2 10/11] arm64: dts: qcom: ipq9574: " Kathiravan Thirumoorthy
2023-09-27 11:33   ` Konrad Dybcio
2023-09-14  7:00 ` [PATCH v2 11/11] arm64: dts: qcom: ipq5332: " Kathiravan Thirumoorthy
2023-09-27 11:33   ` Konrad Dybcio
2023-10-18 14:08 ` [PATCH v2 00/11] Add GPLL0 as clock provider for the Qualcomm's IPQ mailbox controller Kathiravan Thirumoorthy
2023-10-22 15:50 ` (subset) " Bjorn Andersson

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=4f4803d538c6727990cda8f2e4fd7397.sboyd@kernel.org \
    --to=sboyd@kernel.org \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=quic_anusha@quicinc.com \
    --cc=quic_devipriy@quicinc.com \
    --cc=quic_gokulsri@quicinc.com \
    --cc=quic_kathirav@quicinc.com \
    --cc=quic_srichara@quicinc.com \
    --cc=quic_varada@quicinc.com \
    --cc=robh+dt@kernel.org \
    --cc=stable@vger.kernel.org \
    /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).