Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Abhinaba Rakshit" <abhinaba.rakshit@oss.qualcomm.com>,
	"Abel Vesa" <abelvesa@kernel.org>,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Konrad Dybcio" <konradybcio@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <mkp@kernel.org>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"Ulf Hansson" <ulfh@kernel.org>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Neeraj Soni" <neeraj.soni@oss.qualcomm.com>,
	"Harshal Dev" <harshal.dev@oss.qualcomm.com>,
	"Kuldeep Singh" <kuldeep.singh@oss.qualcomm.com>
Cc: linux-crypto@vger.kernel.org, linux-scsi@vger.kernel.org,
	devicetree@vger.kernel.org,
	"Abel Vesa" <abel.vesa@oss.qualcomm.com>
Subject: Re: [PATCH v13 2/6] ufs: host: Add ICE clock scaling during UFS clock changes
Date: Thu, 12 Nov 2026 22:56:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-211928@kernel.org> (raw)
In-Reply-To: <20261113-enable-ice-clock-scaling-v13-2-258dc817bd63@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] ufs: ufs-qcom: inverted ICE clock rounding in
  ufs_qcom_clk_scale_notify()
- [Medium] ufs: ufs-qcom: ICE clock scaling skipped when HBA is inactive
  on reset
- [Medium] ufs: ufs-qcom: broken clock rollback on error in
  ufs_qcom_clk_scale_notify()
--

commit 1e3a20c6222c6ad3d20e8e58d3a121e1fa7488c1
Author: Abhinaba Rakshit <abhinaba.rakshit@oss.qualcomm.com>

ufs: host: Add ICE clock scaling during UFS clock changes

This commit adds Inline Crypto Engine (ICE) clock scaling to
ufs_qcom_clk_scale_notify() so the ICE clock scales alongside the UFS
controller clock.

> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 6afb8498b8c26..5019803a6aba4 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
[ ... ]
> @@ -1987,6 +2002,12 @@ static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, bool scale_up,
>  			return err;
>  		}
>  
> +		err = ufs_qcom_ice_scale_clk(host, target_freq, !scale_up);
> +		if (err && err != -EOPNOTSUPP) {
> +			ufshcd_uic_hibern8_exit(hba);
> +			return err;
> +		}
> +
>  		ufs_qcom_icc_update_bw(host);
>  		ufshcd_uic_hibern8_exit(hba);
>  	}

[Severity: High]
Is the round_ceil argument (!scale_up) inverted in this
ufs_qcom_ice_scale_clk() call?

qcom_ice_scale_clk() calls dev_pm_opp_find_freq_ceil() when round_ceil
is true and dev_pm_opp_find_freq_floor() when round_ceil is false, while
target_freq is the concrete UFS core_clk frequency in Hz.  On SoCs where
ICE OPP rates are higher than the corresponding UFS core_clk rates for
the same voltage corners (for example on QCS8300 or SM8550, where UFS
core_clk OPPs are 75/150/300 MHz and ICE OPPs are 100/201.5/403 MHz),
passing round_ceil = false during scale_up rounds 300 MHz down to
201.5 MHz, so the ICE clock never reaches its 403 MHz nominal OPP.
Scaling up to an intermediate OPP such as 150 MHz also picks 100 MHz
while scaling down to 150 MHz picks 201.5 MHz, and scaling up to a
frequency below the minimum ICE OPP (such as 75 MHz on SM8550) fails with
-ERANGE and aborts UFS clock scaling.

[Severity: Medium]
Does placing ufs_qcom_ice_scale_clk() after the !ufshcd_is_hba_active()
early return in ufs_qcom_clk_scale_notify() skip ICE clock scaling during
host reset and restore?

ufshcd_host_reset_and_restore() stops the HBA before scaling the clocks
back to maximum:

drivers/ufs/core/ufshcd.c:ufshcd_host_reset_and_restore() {
    ...
	ufshcd_hba_stop(hba);
	hba->silence_err_logs = true;
	ufshcd_complete_requests(hba, true);
	hba->silence_err_logs = false;

	/* scale up clocks to max frequency before full reinitialization */
	if (ufshcd_is_clkscaling_supported(hba))
		ufshcd_scale_clks(hba, ULONG_MAX, true);
    ...
}

Because ufshcd_is_hba_active(hba) is false at that point,
ufs_qcom_clk_scale_notify() returns 0 immediately to avoid sending UIC
Hibern8 commands.  Unlike the UFS timers, UniPro clock control and
interconnect bandwidth, the ICE clock is not reconfigured during the
subsequent ufshcd_hba_enable() and link startup, leaving the ICE clock at
its previous lower OPP while the UFS controller runs at maximum
frequency.

[Severity: Medium]
If ufs_qcom_ice_scale_clk() returns an error here, does the error path
leave the UFS timer and UniPro clock control registers out of sync with
the reverted clock rate?

By the time ufs_qcom_ice_scale_clk() runs in POST_CHANGE,
ufs_qcom_clk_scale_up_pre_change() or
ufs_qcom_clk_scale_down_post_change() has already programmed
REG_UFS_SYS1CLK_1US, DME_VS_CORE_CLK_CTRL and PA_VS_CORE_CLK_40NS_CYCLES
for target_freq.  On error, ufs_qcom_clk_scale_notify() exits Hibern8 and
returns err, causing ufshcd_scale_clks() to roll the UFS clocks back to
previous_freq while the link is active and without restoring those
hardware registers to match previous_freq.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261113-enable-ice-clock-scaling-v13-0-258dc817bd63@oss.qualcomm.com?part=2

  reply	other threads:[~2026-11-12 22:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 22:38 [PATCH v13 0/6] Enable ICE clock scaling Abhinaba Rakshit
2026-11-12 22:38 ` [PATCH v13 1/6] soc: qcom: ice: Add OPP-based clock scaling support for ICE Abhinaba Rakshit
2026-11-12 23:09   ` sashiko-bot
2026-11-12 22:38 ` [PATCH v13 2/6] ufs: host: Add ICE clock scaling during UFS clock changes Abhinaba Rakshit
2026-11-12 22:56   ` sashiko-bot [this message]
2026-11-12 22:38 ` [PATCH v13 3/6] mmc: sdhci-msm: Set ICE clk to TURBO at sdhci ICE init Abhinaba Rakshit
2026-11-12 23:04   ` sashiko-bot
2026-11-12 22:38 ` [PATCH v13 4/6] arm64: dts: qcom: kodiak: Add OPP-table for ICE UFS and ICE SDHC nodes Abhinaba Rakshit
2026-11-12 22:38 ` [PATCH v13 5/6] arm64: dts: qcom: monaco: " Abhinaba Rakshit
2026-11-12 22:38 ` [PATCH v13 6/6] arm64: dts: qcom: lemans: Add OPP-table for ICE UFS device node Abhinaba Rakshit

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-211928@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=abel.vesa@oss.qualcomm.com \
    --cc=abelvesa@kernel.org \
    --cc=abhinaba.rakshit@oss.qualcomm.com \
    --cc=adrian.hunter@intel.com \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=harshal.dev@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuldeep.singh@oss.qualcomm.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=mkp@kernel.org \
    --cc=neeraj.soni@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=ulfh@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