Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kuldeep Singh" <kuldeep.singh@oss.qualcomm.com>,
	"Abel Vesa" <abelvesa@kernel.org>,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Konrad Dybcio" <konradybcio@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Harshal Dev" <harshal.dev@oss.qualcomm.com>,
	"Eric Biggers" <ebiggers@google.com>,
	"Ulf Hansson" <ulfh@kernel.org>,
	"Bartosz Golaszewski" <brgl@kernel.org>,
	"Martin K. Petersen" <mkp@kernel.org>,
	"Gaurav Kashyap" <quic_gaurkash@quicinc.com>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "Konrad Dybcio" <konrad.dybcio@oss.qualcomm.com>,
	linux-crypto@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 4/6] soc: qcom: ice: Add runtime PM support
Date: Thu, 03 Dec 2026 12:49:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-247785@kernel.org> (raw)
In-Reply-To: <20261203-qcom_ice_pm_enable-v3-4-86f79ce468b5@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] soc: qcom: ice: disabling clocks in qcom_ice_create() breaks
  legacy DT and !PM
- [High] soc: qcom: ice: qcom_ice_create() disables clocks breaking
  legacy sdhci-msm
- [Medium] soc: qcom: ice: qcom_ice_remove() leaks enabled clocks on
  driver unbind
--

commit 8259f425b33ced4a304438e153146ff4e36ea494
Author: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>

soc: qcom: ice: Add runtime PM support

This commit adds runtime PM callbacks to the Qualcomm ICE driver to gate
core_clk and iface_clk when idle, disabling the clocks at the end of
qcom_ice_create() and marking the ICE platform device suspended in
qcom_ice_probe().

> diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
> index beeaa67082062..ea4a79c98b232 100644
> --- a/drivers/soc/qcom/ice.c
> +++ b/drivers/soc/qcom/ice.c

[ ... ]

> @@ -348,14 +367,23 @@ EXPORT_SYMBOL_GPL(qcom_ice_resume);
>  
>  int qcom_ice_suspend(struct qcom_ice *ice)
>  {
> -	clk_disable_unprepare(ice->iface_clk);
> -	clk_disable_unprepare(ice->core_clk);
>  	ice->hwkm_init_complete = false;
> +	qcom_ice_disable_clocks(ice);
>  
>  	return 0;
>  }

[Severity: High]
Can qcom_ice_suspend() underflow the ICE clock counts on first consumer
suspend at this commit, and does disabling clocks in qcom_ice_create()
break legacy sdhci-msm targets?

At this commit, qcom_ice_create() disables core_clk and iface_clk before
returning, while of_qcom_ice_get() has no runtime PM device links yet.
Dedicated-DT consumers call qcom_ice_enable() during probe while ICE is
unclocked, and consumers call qcom_ice_suspend() on first suspend.

This underflows CCF prepare/enable counts and breaks git bisect, though
commit "ice: Link storage consumers for runtime PM" resolves the
bisectability issue later in the series.

On legacy sdhci-msm DT targets, sdhci_msm_probe() never acquires or
enables the "ice" clock (GCC_SDCC1_ICE_CORE_CLK), and of_qcom_ice_get()
returns directly from qcom_ice_create() without runtime PM ops or a device
link.

Disabling core_clk in qcom_ice_create() therefore leaves ICE unclocked
when sdhci_msm_cqe_enable() -> sdhci_msm_ice_enable() -> qcom_ice_enable()
accesses ICE registers, risking bus errors or BIST timeouts even at the
end of the series.

[ ... ]

> @@ -599,25 +628,31 @@ static struct qcom_ice *qcom_ice_create(struct device *dev,
>  	 * Legacy DT binding uses different clk names for each consumer,
>  	 * so lets try those first. If none of those are a match, it means
>  	 * the we only have one clock and it is part of the dedicated DT node.
> -	 * Also, enable the clock before we check what HW version the driver
> -	 * supports.
>  	 */
> -	engine->core_clk = devm_clk_get_optional_enabled(dev, "ice_core_clk");
> +	engine->core_clk = devm_clk_get_optional(dev, "ice_core_clk");
>  	if (!engine->core_clk)
> -		engine->core_clk = devm_clk_get_optional_enabled(dev, "ice");
> +		engine->core_clk = devm_clk_get_optional(dev, "ice");
>  	if (!engine->core_clk)
> -		engine->core_clk = devm_clk_get_optional_enabled(dev, "core");
> +		engine->core_clk = devm_clk_get_optional(dev, "core");
>  	if (!engine->core_clk)
> -		engine->core_clk = devm_clk_get_enabled(dev, NULL);
> +		engine->core_clk = devm_clk_get(dev, NULL);
>  	if (IS_ERR(engine->core_clk))
>  		return ERR_CAST(engine->core_clk);
>  
> -	engine->iface_clk = devm_clk_get_optional_enabled(dev, "iface");
> +	engine->iface_clk = devm_clk_get_optional(dev, "iface");
>  	if (IS_ERR(engine->iface_clk))
>  		return ERR_CAST(engine->iface_clk);
>  
> -	if (!qcom_ice_check_supported(engine))
> +	err = qcom_ice_enable_clocks(engine);
> +	if (err)
> +		return ERR_PTR(err);
> +
> +	if (!qcom_ice_check_supported(engine)) {
> +		qcom_ice_disable_clocks(engine);
>  		return ERR_PTR(-EOPNOTSUPP);
> +	}
> +
> +	qcom_ice_disable_clocks(engine);

[Severity: High]
Does unconditionally disabling core_clk and iface_clk at the end of
qcom_ice_create() leave ICE unclocked on legacy DT bindings and when
CONFIG_PM is disabled?

When CONFIG_PM is disabled on dedicated ICE DT platforms, pm_ptr() drops
qcom_ice_pm_ops and runtime PM helpers compile to no-ops, so
qcom_ice_enable_clocks() is never called again.

On legacy sdhci-msm DT platforms, of_qcom_ice_get() returns directly from
qcom_ice_create() with no runtime PM ops or device link, and
sdhci_msm_probe() never enables the ice clock.

In both cases, qcom_ice_enable() accesses ICE MMIO registers with core_clk
disabled, risking SError crashes, NOC bus hangs during boot, or BIST
timeouts.  Only disabling the clocks in qcom_ice_probe() when CONFIG_PM is
enabled would keep legacy DT and !PM targets clocked.

[ ... ]

> @@ -771,6 +807,15 @@ static int qcom_ice_probe(struct platform_device *pdev)
>  		return PTR_ERR(engine);
>  	}
>  
> +	platform_set_drvdata(pdev, engine);
> +	pm_runtime_set_suspended(&pdev->dev);
> +
> +	err = devm_pm_runtime_enable(&pdev->dev);
> +	if (err) {
> +		xa_store(&ice_handles, phandle, ERR_PTR(err), GFP_KERNEL);
> +		return err;
> +	}

[Severity: Medium]
Can unbinding qcom-ice while it is runtime-active leak prepared and
enabled reference counts on core_clk and iface_clk?

Replacing devm_clk_get*_enabled() with devm_clk_get*() removes automatic
clk_disable_unprepare() teardown on unbind.  If the device is active at
unbind time (for example after power/control is set to on via
pm_runtime_forbid()), __device_release_driver() leaves it runtime-active.

qcom_ice_remove() only clears the xarray entry, and
devm_pm_runtime_enable()'s cleanup only calls pm_runtime_disable() without
suspending the device, leaving the clocks prepared and enabled when devres
puts them.

Consumer unbind paths like sdhci_msm_remove() also leave ICE active via
pm_runtime_get_sync() before pm_runtime_disable().  Because the link uses
DL_FLAG_AUTOREMOVE_SUPPLIER rather than DL_FLAG_AUTOREMOVE_CONSUMER,
unbinding the consumer does not drop the link, leaving ICE clocks enabled.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-qcom_ice_pm_enable-v3-0-86f79ce468b5@oss.qualcomm.com?part=4

  reply	other threads:[~2026-12-03 12:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 12:22 [PATCH v3 0/6] ICE: Enable runtime PM support and fixes Kuldeep Singh
2026-12-03 12:22 ` [PATCH v3 1/6] soc: qcom: ice: Fix clock unwind behaviour Kuldeep Singh
2026-12-03 12:22 ` [PATCH v3 2/6] soc: qcom: ice: Wait for HWKM BIST to complete Kuldeep Singh
2026-12-03 12:22 ` [PATCH v3 3/6] soc: qcom: ice: Fix error path on resume failures Kuldeep Singh
2026-12-03 12:41   ` sashiko-bot
2026-12-03 12:22 ` [PATCH v3 4/6] soc: qcom: ice: Add runtime PM support Kuldeep Singh
2026-12-03 12:49   ` sashiko-bot [this message]
2026-12-03 12:22 ` [PATCH v3 5/6] ice: Link storage consumers for runtime PM Kuldeep Singh
2026-12-03 12:53   ` sashiko-bot
2026-12-03 12:22 ` [PATCH v3 6/6] soc: qcom: ice: Drop exported resume and suspend APIs Kuldeep Singh
2026-12-03 12:53   ` sashiko-bot

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-247785@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=abelvesa@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=andersson@kernel.org \
    --cc=brgl@kernel.org \
    --cc=ebiggers@google.com \
    --cc=harshal.dev@oss.qualcomm.com \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=konradybcio@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=quic_gaurkash@quicinc.com \
    --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