* [PATCH v2 0/2] Fix MMC/UFS sequence for ICE calls
@ 2026-11-12 13:18 Kuldeep Singh
2026-11-12 13:18 ` [PATCH v2 1/2] mmc: sdhci-msm: Enable ICE before enabling crypto support Kuldeep Singh
2026-11-12 13:18 ` [PATCH v2 2/2] ufs: ufs-qcom: " Kuldeep Singh
0 siblings, 2 replies; 3+ messages in thread
From: Kuldeep Singh @ 2026-11-12 13:18 UTC (permalink / raw)
To: Adrian Hunter, Ulf Hansson, Abel Vesa, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, Eric Biggers
Cc: Kuldeep Singh, linux-mmc, linux-arm-msm, linux-kernel,
linux-scsi, stable
This series fixes ICE initialization sequence where ICE is modeled as a
standalone device and referenced by storage controllers through
qcom,ice.
Currently, ICE driver enables clocks during probe and keeps them
prepared after probe completes. This keeps the ICE clock voted and
hence, any key programming call from blk-crypto succeed even when
storage driver don't have valid ice instance.
This exposes serious bug in sequencing but it works as of now because
ice clocks are voted. Storage controller should not rely on ice clock
state and rather ensure valid ice handle is available before any crypto
call is triggered.
Fixing this issue require ice instance at early ufs/emmc probe so that
correct sequence is established and ice is ready to accept key program
calls from blk-crypto or any explicit storage operation.
Validation:
Tested on shikra-evk, kodiak rb3-gen2 and sm8750-mtp.
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
Changes in v2:
- Drop patch 3/3 and post separately once 1/2 and 2/2 are merged.
- Tag stable kernel for storage fixes.
- Link to v1: https://patch.msgid.link/20261022-qcom_ice_pm_enable-v1-0-f7a84086c651@oss.qualcomm.com
To: Adrian Hunter <adrian.hunter@intel.com>
To: Ulf Hansson <ulfh@kernel.org>
To: Abel Vesa <abelvesa@kernel.org>
To: Manivannan Sadhasivam <mani@kernel.org>
To: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
To: "Martin K. Petersen" <mkp@kernel.org>
To: Eric Biggers <ebiggers@google.com>
Cc: linux-mmc@vger.kernel.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
---
Kuldeep Singh (2):
mmc: sdhci-msm: Enable ICE before enabling crypto support
ufs: ufs-qcom: Enable ICE before enabling crypto support
drivers/mmc/host/sdhci-msm.c | 21 ++++++---------------
drivers/ufs/host/ufs-qcom.c | 29 ++++++++++++++++++++---------
2 files changed, 26 insertions(+), 24 deletions(-)
---
base-commit: aaa2f954c21b205a0bcd0961e5b2be4e82e58455
change-id: 20261022-qcom_ice_pm_enable-3c5d21b99e42
Best regards,
--
Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] mmc: sdhci-msm: Enable ICE before enabling crypto support
2026-11-12 13:18 [PATCH v2 0/2] Fix MMC/UFS sequence for ICE calls Kuldeep Singh
@ 2026-11-12 13:18 ` Kuldeep Singh
2026-11-12 13:18 ` [PATCH v2 2/2] ufs: ufs-qcom: " Kuldeep Singh
1 sibling, 0 replies; 3+ messages in thread
From: Kuldeep Singh @ 2026-11-12 13:18 UTC (permalink / raw)
To: Adrian Hunter, Ulf Hansson, Abel Vesa, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, Eric Biggers
Cc: Kuldeep Singh, linux-mmc, linux-arm-msm, linux-kernel,
linux-scsi, stable
sdhci-msm currently exposes MMC crypto profile and sets MMC_CAP2_CRYPTO
before enabling ICE. This leaves a window where blk-crypto can issue
keyslot programming calls before sdhci-msm has explicitly enabled ICE.
Enable ICE during the sdhci-msm crypto early init path which ensures ICE
is ready before blk-crypto can issue key programming calls.
Remove ICE enable call from CQE path, since ICE is now enabled
during SDHCI crypto initialization only.
Fixes: c7eed31e235c ("mmc: sdhci-msm: Switch to the new ICE API")
Cc: stable@vger.kernel.org
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/mmc/host/sdhci-msm.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 32b1bcba47d6..b3e0356a03ff 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -1928,6 +1928,12 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host,
msm_host->ice = ice;
+ err = qcom_ice_enable(msm_host->ice);
+ if (err) {
+ dev_err(dev, "%s: failed to enable ICE: %d\n", __func__, err);
+ return err;
+ }
+
/* Initialize the blk_crypto_profile */
caps.reg_val = cpu_to_le32(cqhci_readl(cq_host, CQHCI_CCAP));
@@ -1963,12 +1969,6 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host,
return 0;
}
-static void sdhci_msm_ice_enable(struct sdhci_msm_host *msm_host)
-{
- if (msm_host->mmc->caps2 & MMC_CAP2_CRYPTO)
- 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)
@@ -2141,10 +2141,6 @@ static inline int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host,
return 0;
}
-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)
{
@@ -2182,12 +2178,7 @@ static u32 sdhci_msm_cqe_irq(struct sdhci_host *host, u32 intmask)
static void sdhci_msm_cqe_enable(struct mmc_host *mmc)
{
- struct sdhci_host *host = mmc_priv(mmc);
- struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
-
sdhci_cqe_enable(mmc);
- sdhci_msm_ice_enable(msm_host);
}
static void sdhci_msm_cqe_disable(struct mmc_host *mmc, bool recovery)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] ufs: ufs-qcom: Enable ICE before enabling crypto support
2026-11-12 13:18 [PATCH v2 0/2] Fix MMC/UFS sequence for ICE calls Kuldeep Singh
2026-11-12 13:18 ` [PATCH v2 1/2] mmc: sdhci-msm: Enable ICE before enabling crypto support Kuldeep Singh
@ 2026-11-12 13:18 ` Kuldeep Singh
1 sibling, 0 replies; 3+ messages in thread
From: Kuldeep Singh @ 2026-11-12 13:18 UTC (permalink / raw)
To: Adrian Hunter, Ulf Hansson, Abel Vesa, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, Eric Biggers
Cc: Kuldeep Singh, linux-mmc, linux-arm-msm, linux-kernel,
linux-scsi, stable
ufs-qcom currently exposes UFS crypto profile and sets UFSHCD_CAP_CRYPTO
before enabling ICE. This leaves a window where blk-crypto can issue
keyslot programming calls before ufs-qcom has explicitly enabled ICE.
Similar to MMC, enable ICE during ufs crypto init path to ensure ICE is
ready before blk-crypto can issue key programming calls.
Also call qcom_ice_enable() from HCE PRE_CHANGE path once crypto support
has been enabled. UFS controller reset can reset ICE state, and the UFS
core can reprogram keys during HCE start before POST_CHANGE.
Re-enabling ICE in PRE_CHANGE makes ICE ready before reset-time key
reprogramming and for any later ICE operation.
Fixes: 56541c7c4468 ("scsi: ufs: ufs-qcom: Switch to the new ICE API")
Cc: stable@vger.kernel.org
Signed-off-by: Kuldeep Singh <kuldeep.singh@oss.qualcomm.com>
---
drivers/ufs/host/ufs-qcom.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 6afb8498b8c2..4ec400c5281b 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -158,13 +158,15 @@ static void ufs_qcom_config_ice_allocator(struct ufs_qcom_host *host)
ufshcd_writel(hba, config, REG_UFS_MEM_ICE_NUM_CORE);
}
-static inline void ufs_qcom_ice_enable(struct ufs_qcom_host *host)
+static const struct blk_crypto_ll_ops ufs_qcom_crypto_ops; /* forward decl */
+
+static inline int ufs_qcom_ice_enable(struct ufs_qcom_host *host)
{
if (host->hba->caps & UFSHCD_CAP_CRYPTO)
- qcom_ice_enable(host->ice);
-}
+ return qcom_ice_enable(host->ice);
-static const struct blk_crypto_ll_ops ufs_qcom_crypto_ops; /* forward decl */
+ return 0;
+}
static int ufs_qcom_ice_init(struct ufs_qcom_host *host)
{
@@ -188,6 +190,12 @@ static int ufs_qcom_ice_init(struct ufs_qcom_host *host)
host->ice = ice;
+ err = qcom_ice_enable(host->ice);
+ if (err) {
+ dev_err(dev, "Failed to enable ICE: %d\n", err);
+ return err;
+ }
+
/* Initialize the blk_crypto_profile */
caps.reg_val = cpu_to_le32(ufshcd_readl(hba, REG_UFS_CCAP));
@@ -318,11 +326,12 @@ static const struct blk_crypto_ll_ops ufs_qcom_crypto_ops = {
#else
-static inline void ufs_qcom_ice_enable(struct ufs_qcom_host *host)
+static int ufs_qcom_ice_init(struct ufs_qcom_host *host)
{
+ return 0;
}
-static int ufs_qcom_ice_init(struct ufs_qcom_host *host)
+static inline int ufs_qcom_ice_enable(struct ufs_qcom_host *host)
{
return 0;
}
@@ -636,12 +645,15 @@ static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba,
* is initialized.
*/
err = ufs_qcom_enable_lane_clks(host);
+ if (err)
+ return err;
+
+ err = ufs_qcom_ice_enable(host);
break;
case POST_CHANGE:
/* check if UFS PHY moved from DISABLED to HIBERN8 */
err = ufs_qcom_check_hibern8(hba);
ufs_qcom_enable_hw_clk_gating(hba);
- ufs_qcom_ice_enable(host);
ufs_qcom_config_ice_allocator(host);
break;
default:
@@ -660,10 +672,9 @@ static int ufs_qcom_fw_managed_hce_enable_notify(struct ufs_hba *hba,
switch (status) {
case PRE_CHANGE:
ufs_qcom_select_unipro_mode(host);
- break;
+ return ufs_qcom_ice_enable(host);
case POST_CHANGE:
ufs_qcom_enable_hw_clk_gating(hba);
- ufs_qcom_ice_enable(host);
break;
default:
dev_err(hba->dev, "Invalid status %d\n", status);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-12 13:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 13:18 [PATCH v2 0/2] Fix MMC/UFS sequence for ICE calls Kuldeep Singh
2026-11-12 13:18 ` [PATCH v2 1/2] mmc: sdhci-msm: Enable ICE before enabling crypto support Kuldeep Singh
2026-11-12 13:18 ` [PATCH v2 2/2] ufs: ufs-qcom: " Kuldeep Singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®