* [PATCH v3 1/6] soc: qcom: ice: Fix clock unwind behaviour
2026-12-03 12:22 [PATCH v3 0/6] ICE: Enable runtime PM support and fixes Kuldeep Singh
@ 2026-12-03 12:22 ` Kuldeep Singh
2026-12-03 12:22 ` [PATCH v3 2/6] soc: qcom: ice: Wait for HWKM BIST to complete Kuldeep Singh
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Kuldeep Singh @ 2026-12-03 12:22 UTC (permalink / raw)
To: Abel Vesa, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
Harshal Dev, Eric Biggers, Ulf Hansson, Bartosz Golaszewski,
Martin K. Petersen, Gaurav Kashyap, Adrian Hunter,
James E.J. Bottomley
Cc: Kuldeep Singh, Konrad Dybcio, linux-arm-msm, linux-crypto,
linux-mmc, linux-scsi
If enabling the optional "iface" clock fails after the "core" clock has
already been enabled, the core clock is left prepared and enabled which
is wrong.
Disable the core clock on the iface clock failure path to keep clock
prepare/enable count in balance.
Fixes: 0d5dc5818191 ("soc: qcom: ice: Allow explicit votes on 'iface' clock for ICE")
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/soc/qcom/ice.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
index f9ac45505908..65114fd76f77 100644
--- a/drivers/soc/qcom/ice.c
+++ b/drivers/soc/qcom/ice.c
@@ -324,6 +324,7 @@ int qcom_ice_resume(struct qcom_ice *ice)
err = clk_prepare_enable(ice->iface_clk);
if (err) {
dev_err(dev, "Failed to enable iface clock: %d\n", err);
+ clk_disable_unprepare(ice->core_clk);
return err;
}
qcom_ice_hwkm_init(ice);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v3 2/6] soc: qcom: ice: Wait for HWKM BIST to complete
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 ` Kuldeep Singh
2026-12-03 12:22 ` [PATCH v3 3/6] soc: qcom: ice: Fix error path on resume failures Kuldeep Singh
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Kuldeep Singh @ 2026-12-03 12:22 UTC (permalink / raw)
To: Abel Vesa, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
Harshal Dev, Eric Biggers, Ulf Hansson, Bartosz Golaszewski,
Martin K. Petersen, Gaurav Kashyap, Adrian Hunter,
James E.J. Bottomley
Cc: Kuldeep Singh, Konrad Dybcio, linux-arm-msm, linux-crypto,
linux-mmc, linux-scsi
qcom_ice_wait_bist_status() waits for the ICE BIST to complete, but
checks the HWKM BIST status only once. The HWKM BIST may still be in
progress at that point, causing a spurious "HWKM self-test error"
message.
Use readl_poll_timeout() to wait for the expected HWKM completion status
before reporting a self-test error.
Fixes: 7cc6e0c34b21 ("scsi: soc: qcom: ice: Add HWKM support to the ICE driver")
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/soc/qcom/ice.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
index 65114fd76f77..50211e428a0b 100644
--- a/drivers/soc/qcom/ice.c
+++ b/drivers/soc/qcom/ice.c
@@ -229,6 +229,7 @@ static void qcom_ice_optimization_enable(struct qcom_ice *ice)
*/
static int qcom_ice_wait_bist_status(struct qcom_ice *ice)
{
+ u32 hwkm_status;
u32 regval;
int err;
@@ -240,19 +241,24 @@ static int qcom_ice_wait_bist_status(struct qcom_ice *ice)
return err;
}
- if (ice->use_hwkm &&
- qcom_ice_readl(ice, QCOM_ICE_REG_HWKM_TZ_KM_STATUS) !=
- (QCOM_ICE_HWKM_KT_CLEAR_DONE |
- QCOM_ICE_HWKM_BOOT_CMD_LIST0_DONE |
- QCOM_ICE_HWKM_BOOT_CMD_LIST1_DONE |
- QCOM_ICE_HWKM_CRYPTO_BIST_DONE(ice->hwkm_version) |
- QCOM_ICE_HWKM_BIST_DONE(ice->hwkm_version))) {
- dev_err(ice->dev, "HWKM self-test error!\n");
+ if (!ice->use_hwkm)
+ return 0;
+
+ hwkm_status = QCOM_ICE_HWKM_KT_CLEAR_DONE |
+ QCOM_ICE_HWKM_BOOT_CMD_LIST0_DONE |
+ QCOM_ICE_HWKM_BOOT_CMD_LIST1_DONE |
+ QCOM_ICE_HWKM_CRYPTO_BIST_DONE(ice->hwkm_version) |
+ QCOM_ICE_HWKM_BIST_DONE(ice->hwkm_version);
+ err = readl_poll_timeout(ice->base + QCOM_ICE_REG_HWKM_TZ_KM_STATUS,
+ regval, regval == hwkm_status, 50, 5000);
+ if (err) {
+ dev_err(ice->dev, "HWKM self-test error, status=0x%x\n", regval);
/*
* Too late to revoke use_hwkm here, as it was already
* propagated up the stack into the crypto capabilities.
*/
}
+
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v3 3/6] soc: qcom: ice: Fix error path on resume failures
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 ` 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
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Kuldeep Singh @ 2026-12-03 12:22 UTC (permalink / raw)
To: Abel Vesa, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
Harshal Dev, Eric Biggers, Ulf Hansson, Bartosz Golaszewski,
Martin K. Petersen, Gaurav Kashyap, Adrian Hunter,
James E.J. Bottomley
Cc: Kuldeep Singh, Konrad Dybcio, linux-arm-msm, linux-crypto,
linux-mmc, linux-scsi
The ICE clocks are enabled before initializing HWKM and waiting for the
BIST status during ICE resume. If waiting for the BIST status fails, the
error is propagated directly while leaving the clocks on and
hwkm_init_complete flag enabled.
As a fix, disable ICE clocks and clear hwkm_init_complete before
returning error to the consumer.
Fixes: 2afbf43a4aec ("soc: qcom: Make the Qualcomm UFS/SDCC ICE a dedicated driver")
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/soc/qcom/ice.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
index 50211e428a0b..beeaa6708206 100644
--- a/drivers/soc/qcom/ice.c
+++ b/drivers/soc/qcom/ice.c
@@ -334,7 +334,15 @@ int qcom_ice_resume(struct qcom_ice *ice)
return err;
}
qcom_ice_hwkm_init(ice);
- return qcom_ice_wait_bist_status(ice);
+
+ err = qcom_ice_wait_bist_status(ice);
+ if (err) {
+ ice->hwkm_init_complete = false;
+ qcom_ice_disable_clocks(ice);
+ return err;
+ }
+
+ return 0;
}
EXPORT_SYMBOL_GPL(qcom_ice_resume);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v3 3/6] soc: qcom: ice: Fix error path on resume failures
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
0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-12-03 12:41 UTC (permalink / raw)
To: Kuldeep Singh, Abel Vesa, Bjorn Andersson, Konrad Dybcio,
Manivannan Sadhasivam, Harshal Dev, Eric Biggers, Ulf Hansson,
Bartosz Golaszewski, Martin K. Petersen, Gaurav Kashyap,
Adrian Hunter, James E.J. Bottomley
Cc: Konrad Dybcio, linux-crypto, linux-scsi
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] soc: qcom: ice: qcom_ice_resume() calls undefined
qcom_ice_disable_clocks()
--
commit e8071bd70a663f6d3e50121a0fc79388cdc3f52b
Author: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
soc: qcom: ice: Fix error path on resume failures
This commit updates qcom_ice_resume() to clear ice->hwkm_init_complete and
disable the ICE clocks when qcom_ice_wait_bist_status() returns an error.
> diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
> index 50211e428a0b3..beeaa67082062 100644
> --- a/drivers/soc/qcom/ice.c
> +++ b/drivers/soc/qcom/ice.c
> @@ -334,7 +334,15 @@ int qcom_ice_resume(struct qcom_ice *ice)
> return err;
> }
> qcom_ice_hwkm_init(ice);
> - return qcom_ice_wait_bist_status(ice);
> +
> + err = qcom_ice_wait_bist_status(ice);
> + if (err) {
> + ice->hwkm_init_complete = false;
> + qcom_ice_disable_clocks(ice);
> + return err;
> + }
[Severity: High]
Does this fail to compile because qcom_ice_disable_clocks() is not defined
yet?
At this commit, qcom_ice_disable_clocks() is neither declared nor defined
anywhere in the tree, which breaks builds with
CONFIG_QCOM_INLINE_CRYPTO_ENGINE enabled and breaks git bisect. The helper
is only introduced later in the series by commit "soc: qcom: ice: Add runtime
PM support".
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-qcom_ice_pm_enable-v3-0-86f79ce468b5@oss.qualcomm.com?part=3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 4/6] soc: qcom: ice: Add runtime PM support
2026-12-03 12:22 [PATCH v3 0/6] ICE: Enable runtime PM support and fixes Kuldeep Singh
` (2 preceding siblings ...)
2026-12-03 12:22 ` [PATCH v3 3/6] soc: qcom: ice: Fix error path on resume failures Kuldeep Singh
@ 2026-12-03 12:22 ` Kuldeep Singh
2026-12-03 12:49 ` sashiko-bot
2026-12-03 12:22 ` [PATCH v3 5/6] ice: Link storage consumers for runtime PM Kuldeep Singh
2026-12-03 12:22 ` [PATCH v3 6/6] soc: qcom: ice: Drop exported resume and suspend APIs Kuldeep Singh
5 siblings, 1 reply; 11+ messages in thread
From: Kuldeep Singh @ 2026-12-03 12:22 UTC (permalink / raw)
To: Abel Vesa, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
Harshal Dev, Eric Biggers, Ulf Hansson, Bartosz Golaszewski,
Martin K. Petersen, Gaurav Kashyap, Adrian Hunter,
James E.J. Bottomley
Cc: Kuldeep Singh, Konrad Dybcio, linux-arm-msm, linux-crypto,
linux-mmc, linux-scsi
Ice driver currently enables its clocks during probe and keeps them
prepared/enabled even after probe is complete. On targets where ICE
exists as separate DT node and storage consumers reference it through
"qcom,ice", leaves ICE clock voted while the system is idle.
To mitigate this, add runtime PM callbacks to gate the core and iface
clocks. During probe, enable the clocks to read the ICE version/fuse
state, and then disable clocks and mark runtime PM state as suspended.
For legacy binding, keep clock ownership with the storage consumer dev
as it created the ICE instance.
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/soc/qcom/ice.c | 73 ++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 62 insertions(+), 11 deletions(-)
diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
index beeaa6708206..ea4a79c98b23 100644
--- a/drivers/soc/qcom/ice.c
+++ b/drivers/soc/qcom/ice.c
@@ -16,6 +16,7 @@
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <linux/xarray.h>
#include <linux/firmware/qcom/qcom_scm.h>
@@ -316,7 +317,7 @@ int qcom_ice_enable(struct qcom_ice *ice)
}
EXPORT_SYMBOL_GPL(qcom_ice_enable);
-int qcom_ice_resume(struct qcom_ice *ice)
+static int qcom_ice_enable_clocks(struct qcom_ice *ice)
{
struct device *dev = ice->dev;
int err;
@@ -333,6 +334,24 @@ int qcom_ice_resume(struct qcom_ice *ice)
clk_disable_unprepare(ice->core_clk);
return err;
}
+
+ return 0;
+}
+
+static void qcom_ice_disable_clocks(struct qcom_ice *ice)
+{
+ clk_disable_unprepare(ice->iface_clk);
+ clk_disable_unprepare(ice->core_clk);
+}
+
+int qcom_ice_resume(struct qcom_ice *ice)
+{
+ int err;
+
+ err = qcom_ice_enable_clocks(ice);
+ if (err)
+ return err;
+
qcom_ice_hwkm_init(ice);
err = qcom_ice_wait_bist_status(ice);
@@ -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;
}
EXPORT_SYMBOL_GPL(qcom_ice_suspend);
+static int qcom_ice_runtime_resume(struct device *dev)
+{
+ return qcom_ice_resume(dev_get_drvdata(dev));
+}
+
+static int qcom_ice_runtime_suspend(struct device *dev)
+{
+ return qcom_ice_suspend(dev_get_drvdata(dev));
+}
+
static unsigned int translate_hwkm_slot(struct qcom_ice *ice, unsigned int slot)
{
return ice->hwkm_version == QCOM_ICE_HWKM_V1 ? slot : slot * 2;
@@ -579,6 +607,7 @@ static struct qcom_ice *qcom_ice_create(struct device *dev,
void __iomem *base)
{
struct qcom_ice *engine;
+ int err;
if (!qcom_scm_is_available())
return ERR_PTR(-EPROBE_DEFER);
@@ -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);
dev_dbg(dev, "Registered Qualcomm Inline Crypto Engine\n");
@@ -753,6 +788,7 @@ static int qcom_ice_probe(struct platform_device *pdev)
unsigned long phandle = pdev->dev.of_node->phandle;
struct qcom_ice *engine;
void __iomem *base;
+ int err;
guard(mutex)(&ice_mutex);
@@ -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;
+ }
+
xa_store(&ice_handles, phandle, engine, GFP_KERNEL);
return 0;
@@ -790,12 +835,18 @@ static const struct of_device_id qcom_ice_of_match_table[] = {
};
MODULE_DEVICE_TABLE(of, qcom_ice_of_match_table);
+static const struct dev_pm_ops qcom_ice_pm_ops = {
+ RUNTIME_PM_OPS(qcom_ice_runtime_suspend, qcom_ice_runtime_resume, NULL)
+ SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+};
+
static struct platform_driver qcom_ice_driver = {
.probe = qcom_ice_probe,
.remove = qcom_ice_remove,
.driver = {
.name = "qcom-ice",
.of_match_table = qcom_ice_of_match_table,
+ .pm = pm_ptr(&qcom_ice_pm_ops),
},
};
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v3 4/6] soc: qcom: ice: Add runtime PM support
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
0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-12-03 12:49 UTC (permalink / raw)
To: Kuldeep Singh, Abel Vesa, Bjorn Andersson, Konrad Dybcio,
Manivannan Sadhasivam, Harshal Dev, Eric Biggers, Ulf Hansson,
Bartosz Golaszewski, Martin K. Petersen, Gaurav Kashyap,
Adrian Hunter, James E.J. Bottomley
Cc: Konrad Dybcio, linux-crypto, linux-scsi
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 5/6] ice: Link storage consumers for runtime PM
2026-12-03 12:22 [PATCH v3 0/6] ICE: Enable runtime PM support and fixes Kuldeep Singh
` (3 preceding siblings ...)
2026-12-03 12:22 ` [PATCH v3 4/6] soc: qcom: ice: Add runtime PM support Kuldeep Singh
@ 2026-12-03 12:22 ` 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
5 siblings, 1 reply; 11+ messages in thread
From: Kuldeep Singh @ 2026-12-03 12:22 UTC (permalink / raw)
To: Abel Vesa, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
Harshal Dev, Eric Biggers, Ulf Hansson, Bartosz Golaszewski,
Martin K. Petersen, Gaurav Kashyap, Adrian Hunter,
James E.J. Bottomley
Cc: Kuldeep Singh, Konrad Dybcio, linux-arm-msm, linux-crypto,
linux-mmc, linux-scsi
Create a runtime PM device link from storage consumers to ICE supplier.
This lets the PM core control ice runtime-resume/suspend too as per
storage consumer.
After defining the link, qcom_ice_resume/suspend calls are not needed in
MMC and UFS driver as PM core itself will take care and hence, drop API
usages.
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/mmc/host/sdhci-msm.c | 36 ++----------------------------------
drivers/soc/qcom/ice.c | 4 +++-
drivers/ufs/host/ufs-qcom.c | 37 ++++---------------------------------
3 files changed, 9 insertions(+), 68 deletions(-)
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 32b1bcba47d6..73b2851c51c5 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -1969,22 +1969,6 @@ static void sdhci_msm_ice_enable(struct sdhci_msm_host *msm_host)
qcom_ice_enable(msm_host->ice);
}
-static int sdhci_msm_ice_resume(struct sdhci_msm_host *msm_host)
-{
- if (msm_host->mmc->caps2 & MMC_CAP2_CRYPTO)
- return qcom_ice_resume(msm_host->ice);
-
- return 0;
-}
-
-static int sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host)
-{
- if (msm_host->mmc->caps2 & MMC_CAP2_CRYPTO)
- return qcom_ice_suspend(msm_host->ice);
-
- return 0;
-}
-
static inline struct sdhci_msm_host *
sdhci_msm_host_from_crypto_profile(struct blk_crypto_profile *profile)
{
@@ -2145,18 +2129,6 @@ static inline void sdhci_msm_ice_enable(struct sdhci_msm_host *msm_host)
{
}
-static inline int
-sdhci_msm_ice_resume(struct sdhci_msm_host *msm_host)
-{
- return 0;
-}
-
-static inline int
-sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host)
-{
- return 0;
-}
-
static inline void sdhci_msm_ice_restore(struct sdhci_host *host)
{
}
@@ -2956,7 +2928,7 @@ static int sdhci_msm_runtime_suspend(struct device *dev)
clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks),
msm_host->bulk_clks);
- return sdhci_msm_ice_suspend(msm_host);
+ return 0;
}
static int sdhci_msm_runtime_resume(struct device *dev)
@@ -2983,15 +2955,11 @@ static int sdhci_msm_runtime_resume(struct device *dev)
dev_pm_opp_set_rate(dev, msm_host->clk_rate);
- ret = sdhci_msm_ice_resume(msm_host);
- if (ret)
- return ret;
-
spin_lock_irqsave(&host->lock, flags);
host->runtime_suspended = false;
spin_unlock_irqrestore(&host->lock, flags);
- return ret;
+ return 0;
}
static int sdhci_msm_restore(struct device *dev)
diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
index ea4a79c98b23..1fe1f1bb21c9 100644
--- a/drivers/soc/qcom/ice.c
+++ b/drivers/soc/qcom/ice.c
@@ -725,7 +725,9 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
return ice;
}
- link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
+ link = device_link_add(dev, &pdev->dev, DL_FLAG_PM_RUNTIME |
+ DL_FLAG_RPM_ACTIVE |
+ DL_FLAG_AUTOREMOVE_SUPPLIER);
if (!link) {
dev_err(&pdev->dev,
"Failed to create device link to consumer %s\n",
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 6afb8498b8c2..2e65b55f1405 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -223,22 +223,6 @@ static int ufs_qcom_ice_init(struct ufs_qcom_host *host)
return 0;
}
-static inline int ufs_qcom_ice_resume(struct ufs_qcom_host *host)
-{
- if (host->hba->caps & UFSHCD_CAP_CRYPTO)
- return qcom_ice_resume(host->ice);
-
- return 0;
-}
-
-static inline int ufs_qcom_ice_suspend(struct ufs_qcom_host *host)
-{
- if (host->hba->caps & UFSHCD_CAP_CRYPTO)
- return qcom_ice_suspend(host->ice);
-
- return 0;
-}
-
static int ufs_qcom_ice_keyslot_program(struct blk_crypto_profile *profile,
const struct blk_crypto_key *key,
unsigned int slot)
@@ -327,16 +311,6 @@ static int ufs_qcom_ice_init(struct ufs_qcom_host *host)
return 0;
}
-static inline int ufs_qcom_ice_resume(struct ufs_qcom_host *host)
-{
- return 0;
-}
-
-static inline int ufs_qcom_ice_suspend(struct ufs_qcom_host *host)
-{
- return 0;
-}
-
static void ufs_qcom_config_ice_allocator(struct ufs_qcom_host *host)
{
}
@@ -829,7 +803,7 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
usleep_range(10000, 11000);
}
- return ufs_qcom_ice_suspend(host);
+ return 0;
}
static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
@@ -859,25 +833,22 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
ufshcd_readl(hba, UFS_MEM_ICE_CFG);
}
- return ufs_qcom_ice_resume(host);
+ return 0;
}
static int ufs_qcom_fw_managed_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
enum ufs_notify_change_status status)
{
- struct ufs_qcom_host *host = ufshcd_get_variant(hba);
-
if (status == PRE_CHANGE)
return 0;
pm_runtime_put_sync(hba->dev);
- return ufs_qcom_ice_suspend(host);
+ return 0;
}
static int ufs_qcom_fw_managed_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
{
- struct ufs_qcom_host *host = ufshcd_get_variant(hba);
int err;
err = pm_runtime_resume_and_get(hba->dev);
@@ -886,7 +857,7 @@ static int ufs_qcom_fw_managed_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
return err;
}
- return ufs_qcom_ice_resume(host);
+ return 0;
}
static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable)
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v3 5/6] ice: Link storage consumers for runtime PM
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
0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-12-03 12:53 UTC (permalink / raw)
To: Kuldeep Singh, Abel Vesa, Bjorn Andersson, Konrad Dybcio,
Manivannan Sadhasivam, Harshal Dev, Eric Biggers, Ulf Hansson,
Bartosz Golaszewski, Martin K. Petersen, Gaurav Kashyap,
Adrian Hunter, James E.J. Bottomley
Cc: Konrad Dybcio, linux-crypto, linux-scsi
Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [High] soc: qcom: ice: removing resume/suspend breaks legacy DT
bindings
- [High] soc: qcom: ice: clocks stay permanently disabled under
CONFIG_PM=n
- [High] soc: qcom: ice: legacy DT bindings leave ICE clocks off and
skip resume
- [High] ufs: qcom: UFS v5.0.0 ICE reset now runs after
qcom_ice_runtime_resume()
- [High] soc: qcom: ice: PM link resumes ICE before consumer clocks on
legacy DTBs
- [Medium] soc: qcom: ice: leak supplier RPM ref on ufs-qcom probe
failure
- [Medium] soc: qcom: ice: missing clock disable in qcom_ice_remove()
when RPM active
--
commit d6be345364d48f56eae0a0efabdbaa3684476c9c
Author: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
ice: Link storage consumers for runtime PM
This commit adds a runtime PM device link from storage consumers to the
ICE supplier in of_qcom_ice_get() and removes the explicit
qcom_ice_resume() and qcom_ice_suspend() calls from sdhci-msm and
ufs-qcom.
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index 32b1bcba47d6b..73b2851c51c56 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
[ ... ]
> @@ -2983,15 +2955,11 @@ static int sdhci_msm_runtime_resume(struct device *dev)
>
> dev_pm_opp_set_rate(dev, msm_host->clk_rate);
>
> - ret = sdhci_msm_ice_resume(msm_host);
> - if (ret)
> - return ret;
> -
> spin_lock_irqsave(&host->lock, flags);
> host->runtime_suspended = false;
> spin_unlock_irqrestore(&host->lock, flags);
>
> - return ret;
> + return 0;
> }
[Severity: High]
Does removing sdhci_msm_ice_resume() break platforms using the legacy
devicetree binding where the storage node provides an "ice" reg range
instead of a "qcom,ice" phandle?
In of_qcom_ice_get(), legacy DT consumers return qcom_ice_create() early
without a separate qcom-ice device or PM device link, and
qcom_ice_create() disables engine->core_clk and engine->iface_clk before
returning. Because sdhci-msm does not manage the ice clock (for example
on sdm670), nothing re-enables it after probe, so later calls to
qcom_ice_enable() and qcom_ice_program_key() access ICE registers while
unclocked, causing bus hangs, SErrors, or BIST timeouts.
[ ... ]
> diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
> index ea4a79c98b232..1fe1f1bb21c98 100644
> --- a/drivers/soc/qcom/ice.c
> +++ b/drivers/soc/qcom/ice.c
> @@ -725,7 +725,9 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
> return ice;
> }
>
> - link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
> + link = device_link_add(dev, &pdev->dev, DL_FLAG_PM_RUNTIME |
> + DL_FLAG_RPM_ACTIVE |
> + DL_FLAG_AUTOREMOVE_SUPPLIER);
> if (!link) {
> dev_err(&pdev->dev,
> "Failed to create device link to consumer %s\n",
[Severity: Medium]
Can combining DL_FLAG_RPM_ACTIVE with DL_FLAG_AUTOREMOVE_SUPPLIER leak
the ICE supplier's runtime PM reference if ufs-qcom probe fails?
In ufshcd_pltfrm_init(), ufshcd_init() calls ufs_qcom_ice_init() while
hba->dev is still RPM_SUSPENDED, before pm_runtime_set_active(). If
ufshcd_init() later returns an error, __device_links_no_driver() does
not drop DL_FLAG_AUTOREMOVE_SUPPLIER links and pm_runtime_reinit() skips
rpm_put_suppliers() because hba->dev is already RPM_SUSPENDED, leaving
ICE clocks and its power domain permanently active. Using
DL_FLAG_AUTOREMOVE_CONSUMER would drop the link and release the supplier
reference on consumer probe failure.
[Severity: High]
Will ICE clocks stay permanently disabled when the kernel is built with
CONFIG_PM=n?
QCOM_INLINE_CRYPTO_ENGINE does not depend on or select PM. When
CONFIG_PM=n, qcom_ice_create() still disables core_clk and iface_clk
before returning, while pm_ptr(&qcom_ice_pm_ops) evaluates to NULL and
DL_FLAG_RPM_ACTIVE is a no-op, leaving ICE unclocked during
qcom_ice_enable() and keyslot programming.
[Severity: High]
Can linking ICE as a PM supplier resume ICE before the storage
consumer's shared AHB clock and power domain are enabled on older
deployed DTBs?
The DT binding in qcom,inline-crypto-engine.yaml preserves compatibility
for older standalone ICE nodes (for example on sm8550) that declare only
core_clk without an iface clock or power-domains. With
DL_FLAG_PM_RUNTIME, __rpm_callback() runs qcom_ice_runtime_resume()
before the storage consumer enables its AHB clock and UFS_PHY_GDSC, so
qcom_ice_hwkm_init() and qcom_ice_wait_bist_status() access ICE MMIO
registers while the block is still powered off or unclocked, causing an
SError or bus hang.
[Severity: Medium]
If qcom-ice is unbound while runtime-active, does qcom_ice_remove() leak
the prepare and enable counts on core_clk and iface_clk?
qcom_ice_remove() only clears the xarray entry and relies on
devm_pm_runtime_enable() and devm_clk_get() cleanup, neither of which
invokes qcom_ice_runtime_suspend() or disables clocks. When usage_count
is still non-zero at unbind (for instance after a failed ufs-qcom probe
leaks the supplier link reference, or if userspace set power/control to
"on"), __device_release_driver() skips runtime suspend before
devres_release_all() puts the clocks.
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 6afb8498b8c26..2e65b55f14052 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
[ ... ]
> @@ -859,25 +833,22 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
> ufshcd_readl(hba, UFS_MEM_ICE_CFG);
> }
>
> - return ufs_qcom_ice_resume(host);
> + return 0;
> }
[Severity: High]
Does dropping ufs_qcom_ice_resume() skip ICE resume on legacy UFS
devicetree bindings (such as sdm845 and sm8150)?
When the UFS node provides an "ice" reg range instead of a "qcom,ice"
phandle, of_qcom_ice_get() returns early without creating a PM device
link or binding qcom_ice_pm_ops. Without ufs_qcom_ice_suspend() and
ufs_qcom_ice_resume(), ice->hwkm_init_complete is never cleared on
suspend and qcom_ice_hwkm_init() and qcom_ice_wait_bist_status() never
run on Hibern8 resume.
[Severity: High]
On UFS v5.0.0 controllers (such as SM8550), does the ICE synchronous
reset in ufs_qcom_resume() now run after qcom_ice_runtime_resume()?
With ICE linked as a PM supplier of hba->dev, PM core runs
qcom_ice_runtime_resume() before resuming hba->dev and calling
ufs_qcom_resume(). ufs_qcom_resume() then pulses UFS_ICE_SYNC_RST_SW in
UFS_MEM_ICE_CFG, wiping the HWKM configuration while leaving
ice->hwkm_init_complete set and skipping the post-reset BIST wait; on
Hibern8 resume, __ufshcd_wl_resume() does not call ufs_qcom_ice_enable(),
breaking wrapped-key programming and encrypted I/O.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-qcom_ice_pm_enable-v3-0-86f79ce468b5@oss.qualcomm.com?part=5
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 6/6] soc: qcom: ice: Drop exported resume and suspend APIs
2026-12-03 12:22 [PATCH v3 0/6] ICE: Enable runtime PM support and fixes Kuldeep Singh
` (4 preceding siblings ...)
2026-12-03 12:22 ` [PATCH v3 5/6] ice: Link storage consumers for runtime PM Kuldeep Singh
@ 2026-12-03 12:22 ` Kuldeep Singh
2026-12-03 12:53 ` sashiko-bot
5 siblings, 1 reply; 11+ messages in thread
From: Kuldeep Singh @ 2026-12-03 12:22 UTC (permalink / raw)
To: Abel Vesa, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
Harshal Dev, Eric Biggers, Ulf Hansson, Bartosz Golaszewski,
Martin K. Petersen, Gaurav Kashyap, Adrian Hunter,
James E.J. Bottomley
Cc: Kuldeep Singh, Konrad Dybcio, linux-arm-msm, linux-crypto,
linux-mmc, linux-scsi
Now that storage consumers rely on runtime PM device links for ICE power
management, qcom_ice_resume() and qcom_ice_suspend() no longer need to
be exported.
Fold their implementation into the ICE runtime PM callbacks and remove
the public declarations.
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/soc/qcom/ice.c | 19 +++++--------------
include/soc/qcom/ice.h | 2 --
2 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
index 1fe1f1bb21c9..6246bbf8968d 100644
--- a/drivers/soc/qcom/ice.c
+++ b/drivers/soc/qcom/ice.c
@@ -344,8 +344,9 @@ static void qcom_ice_disable_clocks(struct qcom_ice *ice)
clk_disable_unprepare(ice->core_clk);
}
-int qcom_ice_resume(struct qcom_ice *ice)
+static int qcom_ice_runtime_resume(struct device *dev)
{
+ struct qcom_ice *ice = dev_get_drvdata(dev);
int err;
err = qcom_ice_enable_clocks(ice);
@@ -363,26 +364,16 @@ int qcom_ice_resume(struct qcom_ice *ice)
return 0;
}
-EXPORT_SYMBOL_GPL(qcom_ice_resume);
-int qcom_ice_suspend(struct qcom_ice *ice)
+static int qcom_ice_runtime_suspend(struct device *dev)
{
+ struct qcom_ice *ice = dev_get_drvdata(dev);
+
ice->hwkm_init_complete = false;
qcom_ice_disable_clocks(ice);
return 0;
}
-EXPORT_SYMBOL_GPL(qcom_ice_suspend);
-
-static int qcom_ice_runtime_resume(struct device *dev)
-{
- return qcom_ice_resume(dev_get_drvdata(dev));
-}
-
-static int qcom_ice_runtime_suspend(struct device *dev)
-{
- return qcom_ice_suspend(dev_get_drvdata(dev));
-}
static unsigned int translate_hwkm_slot(struct qcom_ice *ice, unsigned int slot)
{
diff --git a/include/soc/qcom/ice.h b/include/soc/qcom/ice.h
index 4bee553f0a59..b17f2df0b75c 100644
--- a/include/soc/qcom/ice.h
+++ b/include/soc/qcom/ice.h
@@ -12,8 +12,6 @@
struct qcom_ice;
int qcom_ice_enable(struct qcom_ice *ice);
-int qcom_ice_resume(struct qcom_ice *ice);
-int qcom_ice_suspend(struct qcom_ice *ice);
int qcom_ice_program_key(struct qcom_ice *ice, unsigned int slot,
const struct blk_crypto_key *blk_key);
int qcom_ice_evict_key(struct qcom_ice *ice, int slot);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v3 6/6] soc: qcom: ice: Drop exported resume and suspend APIs
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
0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-12-03 12:53 UTC (permalink / raw)
To: Kuldeep Singh, Abel Vesa, Bjorn Andersson, Konrad Dybcio,
Manivannan Sadhasivam, Harshal Dev, Eric Biggers, Ulf Hansson,
Bartosz Golaszewski, Martin K. Petersen, Gaurav Kashyap,
Adrian Hunter, James E.J. Bottomley
Cc: Konrad Dybcio, linux-crypto, linux-scsi
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] soc: qcom: ice: dropping resume/suspend breaks legacy DT
bindings
- [High] soc: qcom: ice: unclocked MMIO access when CONFIG_PM is
disabled
- [High] soc: qcom: ice: legacy DT bindings left unclocked after
qcom_ice_create()
- [High] soc: qcom: ice: UFS v5.0.0 sync reset runs after
qcom_ice_runtime_resume()
- [Medium] soc: qcom: ice: DL_FLAG_AUTOREMOVE_SUPPLIER leaks RPM ref on
probe failure
- [Medium] soc: qcom: ice: qcom_ice_remove() leaks enabled clocks when
runtime-active
--
commit 56528d5ac3c6c7e88600729e222e97f438e79ee1
Author: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
soc: qcom: ice: Drop exported resume and suspend APIs
This commit folds qcom_ice_resume() and qcom_ice_suspend() into the
runtime PM callbacks in drivers/soc/qcom/ice.c and removes their
exported symbols and public declarations from include/soc/qcom/ice.h.
> diff --git a/drivers/soc/qcom/ice.c b/drivers/soc/qcom/ice.c
> index 1fe1f1bb21c98..6246bbf8968d7 100644
> --- a/drivers/soc/qcom/ice.c
> +++ b/drivers/soc/qcom/ice.c
> @@ -344,8 +344,9 @@ static void qcom_ice_disable_clocks(struct qcom_ice *ice)
> clk_disable_unprepare(ice->core_clk);
> }
>
> -int qcom_ice_resume(struct qcom_ice *ice)
> +static int qcom_ice_runtime_resume(struct device *dev)
> {
> + struct qcom_ice *ice = dev_get_drvdata(dev);
> int err;
>
> err = qcom_ice_enable_clocks(ice);
[Severity: High]
Will ICE clocks stay permanently disabled when CONFIG_PM is disabled?
QCOM_INLINE_CRYPTO_ENGINE and its storage consumers do not select or
depend on PM. With CONFIG_PM=n, pm_ptr(&qcom_ice_pm_ops) evaluates to
NULL and __pm_runtime_resume() in device_link_add() is a no-op stub, so
qcom_ice_runtime_resume() never runs.
Because qcom_ice_create() unconditionally calls qcom_ice_disable_clocks()
before returning and qcom_ice_resume() is gone, subsequent calls to
qcom_ice_enable() access unclocked ICE MMIO registers and can hang the
bus or trigger an SError at boot.
[Severity: High]
Are legacy devicetree bindings left with ICE clocks disabled even when
CONFIG_PM is enabled?
When a storage node provides an "ice" reg range (such as sdhc_1 in
sdm670.dtsi), of_qcom_ice_get() returns directly from
qcom_ice_create(&pdev->dev, base) without probing qcom_ice_driver,
attaching qcom_ice_pm_ops, or creating a device link.
Because qcom_ice_create() disables core_clk and iface_clk before
returning and sdhci_msm_probe() never enables the "ice" clock, nothing
re-enables core_clk. Subsequent calls to qcom_ice_enable() then perform
unclocked MMIO accesses during boot, causing a bus hang or SError.
[Severity: High]
Does folding qcom_ice_resume() into the supplier runtime PM callback
break UFS v5.0.0 resume ordering?
On UFS v5.0.0 (such as SM8550), ufs_qcom_resume() pulses
UFS_ICE_SYNC_RST_SEL | UFS_ICE_SYNC_RST_SW in UFS_MEM_ICE_CFG when the
link is not active (for example, on Hibern8 exit). Previously,
ufs_qcom_resume() called qcom_ice_resume() after that reset.
With runtime PM device links, the PM core runs qcom_ice_runtime_resume()
before hba->dev resumes and before __ufshcd_wl_resume() calls
ufs_qcom_resume(). The later synchronous reset wipes HWKM setup and
starts BIST while ice->hwkm_init_complete stays true, and Hibern8 exit
does not call qcom_ice_enable() to re-initialize ICE.
> @@ -363,26 +364,16 @@ int qcom_ice_resume(struct qcom_ice *ice)
>
> return 0;
> }
> -EXPORT_SYMBOL_GPL(qcom_ice_resume);
>
> -int qcom_ice_suspend(struct qcom_ice *ice)
> +static int qcom_ice_runtime_suspend(struct device *dev)
> {
> + struct qcom_ice *ice = dev_get_drvdata(dev);
> +
> ice->hwkm_init_complete = false;
> qcom_ice_disable_clocks(ice);
>
> return 0;
> }
> -EXPORT_SYMBOL_GPL(qcom_ice_suspend);
[Severity: Medium]
Can a consumer probe failure or deferral leak the ICE supplier's runtime
PM usage_count and prevent qcom_ice_runtime_suspend() from running?
of_qcom_ice_get() adds the device link with DL_FLAG_PM_RUNTIME |
DL_FLAG_RPM_ACTIVE | DL_FLAG_AUTOREMOVE_SUPPLIER. In
ufshcd_pltfrm_init(), ufshcd_init() acquires ICE before
pm_runtime_set_active(dev) runs, so dev->power.runtime_status is still
RPM_SUSPENDED if ufshcd_init() fails or returns -EPROBE_DEFER.
On probe unwind, __device_links_no_driver() only drops links marked
DL_FLAG_AUTOREMOVE_CONSUMER, and pm_runtime_reinit() skips
pm_runtime_set_suspended() because runtime_status is not RPM_ACTIVE.
The supplier's usage_count stays elevated and ICE clocks remain on
indefinitely; using DL_FLAG_AUTOREMOVE_CONSUMER would drop the link on
consumer probe failure.
[Severity: Medium]
Does qcom_ice_remove() leak enabled ICE clocks if the driver is unbound
while runtime-active?
If ice->dev still has power.usage_count > 0 when __device_release_driver()
calls pm_runtime_put_sync() (for instance if userspace set power/control
to "on" or after a failed consumer probe leaked the device link),
qcom_ice_runtime_suspend() is not called.
qcom_ice_remove() only clears the ice_handles xarray entry, and
device_unbind_cleanup() then runs devm_pm_runtime_enable()'s cleanup
(which disables runtime PM without suspending) followed by
devm_clk_release(), calling clk_put() while core_clk and iface_clk are
still prepared and enabled.
> diff --git a/include/soc/qcom/ice.h b/include/soc/qcom/ice.h
> index 4bee553f0a59d..b17f2df0b75cf 100644
> --- a/include/soc/qcom/ice.h
> +++ b/include/soc/qcom/ice.h
> @@ -12,8 +12,6 @@
> struct qcom_ice;
>
> int qcom_ice_enable(struct qcom_ice *ice);
> -int qcom_ice_resume(struct qcom_ice *ice);
> -int qcom_ice_suspend(struct qcom_ice *ice);
> int qcom_ice_program_key(struct qcom_ice *ice, unsigned int slot,
> const struct blk_crypto_key *blk_key);
> int qcom_ice_evict_key(struct qcom_ice *ice, int slot);
[Severity: High]
Without qcom_ice_resume() and qcom_ice_suspend(), how do legacy
devicetree consumers re-initialize ICE across suspend and resume?
Legacy bindings (used by storage nodes in dtsi files such as sdm845.dtsi
and sdm670.dtsi) do not have a standalone qcom-ice supplier device or
runtime PM device link. With these APIs gone, qcom_ice_runtime_suspend()
and qcom_ice_runtime_resume() never execute for them, so
ice->hwkm_init_complete is never cleared on suspend and
qcom_ice_hwkm_init() and qcom_ice_wait_bist_status() are never re-run
after power collapse or Hibern8, breaking inline encryption.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-qcom_ice_pm_enable-v3-0-86f79ce468b5@oss.qualcomm.com?part=6
^ permalink raw reply [flat|nested] 11+ messages in thread