All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Konrad Dybcio" <konradybcio@kernel.org>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH RFC 10/16] clk: qcom: clk-alpha-pll: Vote for the PLL calibration frequency
Date: Wed, 14 Oct 2026 12:34:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-171285@kernel.org> (raw)
In-Reply-To: <20261014-topic-qc_clk_dvfs-v1-10-3041b788e9f7@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] clk: qcom: dvfs: qcom_clk_dvfs_prepare_rate() unwinds to 0 on failure, dropping votes
- [High] clk: qcom: alpha-pll: disable failure during calibration drops DVFS votes while PLL runs
--

commit 27077f9ef026973ca3f8e723a45854a856554ed2
Author: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: clk: qcom: clk-alpha-pll: Vote for the PLL calibration frequency

This commit updates Lucid EVO PLL initialization to safely handle higher
calibration frequencies. It temporarily raises the DVFS vote to the
calibration rate during preparation and restores the nominal rate once
complete.

> diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c
> index 5dc6b1adc9298..f6e73e2fbe768 100644
> --- a/drivers/clk/qcom/clk-alpha-pll.c
> +++ b/drivers/clk/qcom/clk-alpha-pll.c
[ ... ]
> @@ -2628,12 +2648,9 @@ static int _alpha_pll_lucid_evo_prepare(struct clk_hw *hw, bool reset)
>  		return -EINVAL;
>  
>  	ret = alpha_pll_lucid_evo_enable(hw);
> -	if (ret)
> -		return ret;
> -
> -	_alpha_pll_lucid_evo_disable(hw, reset);
> +	cleanup_ret = alpha_pll_lucid_evo_disable_checked(hw, reset);
>  
> -	return 0;
> +	return ret ?: cleanup_ret;
>  }

[Severity: High]
Is it safe to propagate the disable error here if it results in dropping the 
DVFS votes while the PLL is still running?

If alpha_pll_lucid_evo_enable() succeeds but alpha_pll_lucid_evo_disable_checked()
fails (e.g., due to a regmap write failure), the error is propagated up to
alpha_pll_lucid_evo_dvfs_prepare(). 

The error handler there unconditionally calls qcom_clk_dvfs_unprepare() via the
err_unprepare label, resetting all DVFS votes to 0. Because the hardware disable
failed, the PLL is left physically enabled and actively running without the
necessary voltage votes.

[ ... ]
> @@ -2641,21 +2658,69 @@ static void alpha_pll_lucid_evo_disable(struct clk_hw *hw)
>  	_alpha_pll_lucid_evo_disable(hw, false);
>  }
>  
> -static int alpha_pll_lucid_evo_prepare(struct clk_hw *hw)
> +/*
> + * Calibration runs at CAL_L * parent_rate, which may exceed the operating rate
> + * covered by the normal DVFS vote. Raise the vote temporarily to keep the
> + * hardware in-spec during that step.
> + */
> +static int alpha_pll_lucid_evo_dvfs_prepare(struct clk_hw *hw, bool reset)
>  {
[ ... ]
> +	ret = _alpha_pll_lucid_evo_prepare(hw, reset);
> +	if (ret)
> +		goto err_unprepare;
> +
> +	if (cal_rate > rate && qcom_clk_dvfs_prepare_rate(hw, rate))
> +		pr_warn("%s: failed to drop calibration DVFS vote\n",
> +			clk_hw_get_name(hw));
>  
> +	return 0;

[Severity: High]
Can ignoring the error from qcom_clk_dvfs_prepare_rate() here leave the unwound
power domains without voltage votes?

When down-voting from cal_rate to rate, if qcom_clk_dvfs_prepare_rate() fails
midway, its unwind path resets the successfully updated domains to 0:

drivers/clk/qcom/clk-dvfs.c:qcom_clk_dvfs_prepare_rate() {
	...
unwind:
	while (i--) {
		unsigned int pd_index = clock->data->pd_indices[i];

		qcom_clk_dvfs_replace_vote(&clock->rail_voters[pd_index],
					   &clock->votes[i], 0);
	}
	return ret;
}

Since the warning is caught but the error is deliberately ignored (returning 0),
the clock prepares and operates at the target rate but with missing DVFS votes
(vote = 0) on the unwound domains, which risks hardware brownouts or system
crashes.

> +
> +err_unprepare:
> +	qcom_clk_dvfs_unprepare(hw);
>  	return ret;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014-topic-qc_clk_dvfs-v1-0-3041b788e9f7@oss.qualcomm.com?part=10

  reply	other threads:[~2026-10-14 12:34 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 12:19 [RFC PATCH 00/16] Centralize the ownership of power rail votes for Qualcomm clocks Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 01/16] clk: Propagate rate programming failures Konrad Dybcio
2026-10-14 12:35   ` sashiko-bot
2026-10-14 13:25   ` Dmitry Baryshkov
2026-10-14 12:19 ` [PATCH RFC 02/16] clk: Acquire resources for clock transitions Konrad Dybcio
2026-10-14 12:40   ` sashiko-bot
2026-10-14 12:19 ` [PATCH RFC 03/16] OPP: Retry failed default single-clock transitions Konrad Dybcio
2026-10-14 12:34   ` sashiko-bot
2026-10-14 13:35   ` Dmitry Baryshkov
2026-10-14 16:14     ` Konrad Dybcio
2026-10-14 16:32       ` Dmitry Baryshkov
2026-10-14 12:19 ` [PATCH RFC 04/16] pmdomain: core: Support named indexed virtual attachments Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 05/16] pmdomain: core: Support subdomains without pstate propagation Konrad Dybcio
2026-10-14 12:41   ` sashiko-bot
2026-10-14 12:19 ` [PATCH RFC 06/16] pmdomain: core: Support indexed power-domain attachment lists Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 07/16] clk: qcom: Add clock-owned GenPD DVFS aggregation Konrad Dybcio
2026-10-14 12:35   ` sashiko-bot
2026-10-14 14:36   ` Dmitry Baryshkov
2026-10-14 15:26     ` Konrad Dybcio
2026-10-14 16:30       ` Dmitry Baryshkov
2026-10-14 16:45         ` Konrad Dybcio
2026-10-14 17:31           ` Dmitry Baryshkov
2026-10-14 12:19 ` [PATCH RFC 08/16] clk: qcom: dvfs: Add debugfs Konrad Dybcio
2026-10-14 12:37   ` sashiko-bot
2026-10-14 12:19 ` [PATCH RFC 09/16] clk: qcom: clk-alpha-pll: Add DVFS (un)prepare Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 10/16] clk: qcom: clk-alpha-pll: Vote for the PLL calibration frequency Konrad Dybcio
2026-10-14 12:34   ` sashiko-bot [this message]
2026-10-14 12:19 ` [PATCH RFC 11/16] clk: qcom: gdsc: Make GDSC parenting optional Konrad Dybcio
2026-10-14 12:30   ` sashiko-bot
2026-10-14 14:17   ` Dmitry Baryshkov
2026-10-14 14:20     ` Konrad Dybcio
2026-10-14 14:34       ` Dmitry Baryshkov
2026-10-14 14:36         ` Konrad Dybcio
2026-10-14 12:19 ` [PATCH RFC 12/16] clk: qcom: gdsc: Link required power domains Konrad Dybcio
2026-10-14 12:32   ` sashiko-bot
2026-10-14 12:19 ` [PATCH DNM RFC 13/16] arm64: dts: qcom: sm8650: Describe clock controller power rails Konrad Dybcio
2026-10-14 12:41   ` sashiko-bot
2026-10-14 14:19   ` Dmitry Baryshkov
2026-10-14 14:20     ` Konrad Dybcio
2026-10-14 14:33       ` Dmitry Baryshkov
2026-10-14 14:36         ` Konrad Dybcio
2026-10-14 15:01           ` Dmitry Baryshkov
2026-10-14 15:23             ` Konrad Dybcio
2026-10-14 12:19 ` [PATCH DNM RFC 14/16] clk: qcom: Enable clk-dvfs on SM8650 Konrad Dybcio
2026-10-14 12:36   ` sashiko-bot
2026-10-14 14:40   ` Dmitry Baryshkov
2026-10-14 15:22     ` Konrad Dybcio
2026-10-14 16:35       ` Dmitry Baryshkov
2026-10-14 16:42         ` Konrad Dybcio
2026-10-14 12:19 ` [PATCH DNM RFC 15/16] arm64: dts: qcom: sm8650: Drop required-opps Konrad Dybcio
2026-10-14 12:39   ` sashiko-bot
2026-10-14 14:23   ` Dmitry Baryshkov
2026-10-14 14:33     ` Konrad Dybcio
2026-10-14 12:19 ` [PATCH DNM RFC 16/16] pmdomain: qcom: rpmhpd: Stop forwarding MMCX pstate to CX Konrad Dybcio
2026-10-14 12:37   ` sashiko-bot
2026-10-14 14:37 ` [RFC PATCH 00/16] Centralize the ownership of power rail votes for Qualcomm clocks Dmitry Baryshkov
2026-10-14 16:19   ` 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=sashiko-outbox-171285@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.