From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Konrad Dybcio <konrad.dybcio@linaro.org>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
devicetree@vger.kernel.org, Shawn Guo <shawn.guo@linaro.org>,
Taniya Das <quic_tdas@quicinc.com>
Subject: Re: [PATCH RFT v2 09/14] clk: qcom: smd-rpm: Add support for keepalive votes
Date: Thu, 9 Mar 2023 02:54:36 +0200 [thread overview]
Message-ID: <091c0851-6f07-c7bc-0a40-b6910c33ab4f@linaro.org> (raw)
In-Reply-To: <20230303-topic-rpmcc_sleep-v2-9-ae80a325fe94@linaro.org>
On 08/03/2023 23:35, Konrad Dybcio wrote:
> Some bus clock should always have a minimum (19.2 MHz) vote cast on
> them, otherwise the platform will fall apart, hang and reboot.
>
> Add support for specifying which clocks should be kept alive and
> always keep a vote on XO_A to make sure the clock tree doesn't
> collapse. This removes the need to keep a maximum vote that was
> previously guaranteed by clk_smd_rpm_handoff.
>
> This commit is a combination of existing (not-exactly-upstream) work
> by Taniya Das, Shawn Guo and myself.
>
> Co-developed-by: Shawn Guo <shawn.guo@linaro.org>
> Co-developed-by: Taniya Das <quic_tdas@quicinc.com>
> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
> drivers/clk/qcom/clk-smd-rpm.c | 29 +++++++++++++++++++++++++++--
> 1 file changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
> index eb7781e5c8c1..d89918f9ae60 100644
> --- a/drivers/clk/qcom/clk-smd-rpm.c
> +++ b/drivers/clk/qcom/clk-smd-rpm.c
> @@ -45,15 +45,17 @@
> }, \
> }; \
> __DEFINE_CLK_SMD_RPM_AO_PREFIX(_prefix, _name, _active, type, \
> - r_id, key, ao_flags)
> + r_id, key, ao_flags, false)
>
> #define __DEFINE_CLK_SMD_RPM_AO_PREFIX(_prefix, _name, _active, \
> - type, r_id, key, ao_flags) \
> + type, r_id, key, ao_flags, \
> + _keep_alive) \
> static struct clk_smd_rpm clk_smd_rpm_##_prefix##_active = { \
> .rpm_res_type = (type), \
> .rpm_clk_id = (r_id), \
> .active_only = true, \
> .rpm_key = (key), \
> + .keep_alive = (_keep_alive), \
> .peer = &clk_smd_rpm_##_prefix##_name, \
> .rate = INT_MAX, \
> .hw.init = &(struct clk_init_data){ \
> @@ -170,6 +172,7 @@ struct clk_smd_rpm {
> const bool active_only;
> bool enabled;
> bool branch;
> + bool keep_alive;
> struct clk_smd_rpm *peer;
> struct clk_hw hw;
> unsigned long rate;
> @@ -198,11 +201,16 @@ static int clk_smd_rpm_handoff(struct clk_smd_rpm *r)
> .value = cpu_to_le32(r->branch ? 1 : INT_MAX),
> };
>
> + /* Set up keepalive clocks with a minimum bus rate */
> + if (r->keep_alive)
> + req.value = cpu_to_le32(19200); /* 19.2 MHz */
Should this be set to cpu_to_le32(max(19200, ...)) ?
> +
> ret = qcom_rpm_smd_write(r->rpm, QCOM_SMD_RPM_ACTIVE_STATE,
> r->rpm_res_type, r->rpm_clk_id, &req,
> sizeof(req));
> if (ret)
> return ret;
> +
> ret = qcom_rpm_smd_write(r->rpm, QCOM_SMD_RPM_SLEEP_STATE,
> r->rpm_res_type, r->rpm_clk_id, &req,
> sizeof(req));
> @@ -438,12 +446,29 @@ static int clk_smd_rpm_is_enabled(struct clk_hw *hw)
> return r->enabled;
> }
>
> +static int clk_smd_rpm_determine_rate(struct clk_hw *hw,
> + struct clk_rate_request *req)
> +{
> + struct clk_smd_rpm *r = to_clk_smd_rpm(hw);
> +
> + /*
> + * RPM resolves the rates internally. All we have to do on the kernel
> + * side is ensure that we don't accidentally put down the keepalive
> + * clocks, which could happen if they received a vote below 19.2 MHz.
> + */
> + if (r->keep_alive)
> + req->rate = max(req->rate, 19200000UL);
> +
> + return 0;
> +}
> +
> static const struct clk_ops clk_smd_rpm_ops = {
> .prepare = clk_smd_rpm_prepare,
> .unprepare = clk_smd_rpm_unprepare,
> .set_rate = clk_smd_rpm_set_rate,
> .round_rate = clk_smd_rpm_round_rate,
> .recalc_rate = clk_smd_rpm_recalc_rate,
> + .determine_rate = clk_smd_rpm_determine_rate,
> .is_enabled = clk_smd_rpm_is_enabled,
> .is_prepared = clk_smd_rpm_is_enabled,
> };
>
--
With best wishes
Dmitry
next prev parent reply other threads:[~2023-03-09 0:54 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 21:35 [PATCH RFT v2 00/14] SMD RPMCC sleep preparations Konrad Dybcio
2023-03-08 21:35 ` [PATCH RFT v2 01/14] dt-bindings: clock: qcom,rpmcc: Add a way to enable unused clock cleanup Konrad Dybcio
2023-03-16 22:58 ` Rob Herring
2023-03-17 0:31 ` Konrad Dybcio
2023-03-17 18:20 ` Stephen Boyd
2023-04-06 14:44 ` Konrad Dybcio
2023-04-07 20:17 ` Konrad Dybcio
2023-04-11 21:34 ` Konrad Dybcio
2023-03-22 3:23 ` Bjorn Andersson
2023-04-17 19:05 ` Stephan Gerhold
2023-04-18 0:19 ` Stephen Boyd
2023-04-18 10:33 ` Konrad Dybcio
2023-04-19 11:31 ` Konrad Dybcio
2023-04-19 14:00 ` Stephan Gerhold
2023-04-19 21:08 ` Konrad Dybcio
2023-04-20 8:28 ` Manivannan Sadhasivam
2023-03-08 21:35 ` [PATCH RFT v2 02/14] clk: qcom: smd-rpm: Add .is_enabled hook Konrad Dybcio
2023-03-09 0:47 ` Dmitry Baryshkov
2023-03-22 3:02 ` Bjorn Andersson
2023-04-06 14:43 ` Konrad Dybcio
2023-03-08 21:35 ` [PATCH RFT v2 03/14] clk: qcom: smd-rpm: Add .is_prepared hook Konrad Dybcio
2023-03-09 0:48 ` Dmitry Baryshkov
2023-03-08 21:35 ` [PATCH RFT v2 04/14] clk: qcom: smd-rpm_ Make __DEFINE_CLK_SMD_RPM_BRANCH_PREFIX accept flags Konrad Dybcio
2023-03-09 0:48 ` Dmitry Baryshkov
2023-03-08 21:35 ` [PATCH RFT v2 05/14] clk: qcom: smd-rpm: Make DEFINE_CLK_SMD_RPM_BRANCH_A " Konrad Dybcio
2023-03-09 0:49 ` Dmitry Baryshkov
2023-03-08 21:35 ` [PATCH RFT v2 06/14] clk: qcom: smd-rpm: Make BI_TCXO_AO critical Konrad Dybcio
2023-03-09 0:49 ` Dmitry Baryshkov
2023-03-08 21:35 ` [PATCH RFT v2 07/14] clk: qcom: smd-rpm: Make __DEFINE_CLK_SMD_RPM_PREFIX accept flags Konrad Dybcio
2023-03-09 0:50 ` Dmitry Baryshkov
2023-03-08 21:35 ` [PATCH RFT v2 08/14] clk: qcom: smd-rpm: Separate out a macro for defining an AO clock Konrad Dybcio
2023-03-09 0:50 ` Dmitry Baryshkov
2023-03-08 21:35 ` [PATCH RFT v2 09/14] clk: qcom: smd-rpm: Add support for keepalive votes Konrad Dybcio
2023-03-09 0:54 ` Dmitry Baryshkov [this message]
2023-03-09 1:22 ` Konrad Dybcio
2023-03-08 21:35 ` [PATCH RFT v2 10/14] clk: qcom: smd-rpm: Introduce DEFINE_CLK_SMD_RPM_BUS_KEEPALIVE Konrad Dybcio
2023-03-09 1:25 ` Dmitry Baryshkov
2023-03-08 21:35 ` [PATCH RFT v2 11/14] clk: qcom: smd-rpm: Hook up PCNoC_0 keep_alive Konrad Dybcio
2023-03-09 1:25 ` Dmitry Baryshkov
2023-03-22 3:19 ` Bjorn Andersson
2023-03-22 8:05 ` Konrad Dybcio
2023-03-08 21:35 ` [PATCH RFT v2 12/14] clk: qcom: smd-rpm: Hook up CNoC_1 and SNoC_2 keep_alive Konrad Dybcio
2023-03-09 1:25 ` Dmitry Baryshkov
2023-03-08 21:35 ` [PATCH RFT v2 13/14] clk: qcom: smd-rpm: Mark clock enabled in clk_smd_rpm_handoff() Konrad Dybcio
2023-03-08 21:35 ` [PATCH RFT v2 14/14] arm64: dts: qcom: msm8996: Enable rpmcc unused clk disablement Konrad Dybcio
2023-04-20 1:50 ` [PATCH RFT v2 00/14] SMD RPMCC sleep preparations Konrad Dybcio
2023-04-20 7:56 ` Stephan Gerhold
2023-04-20 9:36 ` Konrad Dybcio
2023-04-20 10:04 ` Stephan Gerhold
2023-04-20 10:20 ` Konrad Dybcio
2023-04-20 15:57 ` Konrad Dybcio
2023-04-25 19:35 ` Stephen Boyd
2023-04-26 9:40 ` Konrad Dybcio
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=091c0851-6f07-c7bc-0a40-b6910c33ab4f@linaro.org \
--to=dmitry.baryshkov@linaro.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=krzysztof.kozlowski@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_tdas@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=shawn.guo@linaro.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).