From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5585C350A21 for ; Fri, 23 Jan 2026 09:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.167.51 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769161165; cv=pass; b=VFu4NC41UXni7+0Dt8q0zgncQ75nF6eLhUDLTPg/bM9+MpfN8U88TCH45Mqj3/E8xcQ/n3iLsKWvn+HRJDB46Zsb+3iOcgOnQZC61yI67iB1vdbL2rawrFok1Pwz5IB1CJq3c2uii8ax/bRkWRi5Y9iZ+kQ2+lU8hOZsUCJD07c= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769161165; c=relaxed/simple; bh=E9sY73mzI8WIkjfDsoZWnuIR2fVyge0FFmizubuNHXA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=SDtxVIn2X0F5e5YMaxYEC41b8Dr4z8An1Ygf0qFNxNi5RTdNb3p2qiQX1XeYhImFKhZH+F3NogUpZ2o5gotDWzI/LLNs7RiLjEz7DwhGmsrzMB16x6hIouUyBK5HIlLFHUARyXx+MfOcUCQ6e2cAxA3R7Rs/OCyARs1glKqWSjY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jOq3pRio; arc=pass smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jOq3pRio" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-59b76844f89so1961296e87.1 for ; Fri, 23 Jan 2026 01:39:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769161150; cv=none; d=google.com; s=arc-20240605; b=CUJUQNpMOQjT6K0gRavm321W4ABUqw8/cVxXfHGqk741Jw3yUtIzuhv7IPVEjp+aGC V0iMzWnZccuAJC5+k5fVJGgf/J1vOWNAlvirH0ji0pXwszj8/eBSANIqmothqBUlXg5P NlzdNZfHfisQ8srfaCbTCQ3DfpCkEpBq6uDohZ30NJdItrTchIU7Gd6ERVOJVI5+ZFXp Uvvy9LzYK3T7qmzEdQ2HowSLfJQQutoRYQfgbdhLEcdRY2jvPMv9wq2G5ljCFlbEjEvV S1Hvvh3g4ArCZIpUFsAZ4OGrj8CXJ/BKcmJNnrInHl97TOEfsEo8owImOMtGO48WabfI I0+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rG52QXraaViSSSy0BOpcFpXuiB3xymU1NOmvEWWxI0g=; fh=1Nj7d7yVdM59F2W6m0J2iZQPZvCFCUQ0pJ2wdlBN20M=; b=elSmsgpJXtR8uK5bWLnAz0jS5oxYYxSZmNDBQKGo1Ln0T+ArPk1xZgC4xX/vhQJ8Xv oi02IrTZvImubFj5P6QssZtgWRCWrF8auIpmykj2QigcBSmO516yGYxOrrw2Bg8oDe4t keg8vMOpKbZ5D1IyO4XXwH3y+5HMcxbECpEz06h7QCHNmcwJd0fsnRDHMgbtDxJ3LfWv qkS2baknoFbaGwhYQ+Vx7xX/xx+MWvuD595bk6R6zKrwn1xubXImXBf2sH2JdA2/Kiyk HnpQHvBAXnrSJiakZsu9Gm1ch9vLD3Rw790otbO9Xz3SRyKXvBv3/r0tdeyVBh5nS1UL 6NIw==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1769161150; x=1769765950; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rG52QXraaViSSSy0BOpcFpXuiB3xymU1NOmvEWWxI0g=; b=jOq3pRioWt9pVUiWulyxA+CNpHXtnKAoAL0ppF4VN7sPCybk7m9gew0c2Adp0rqVUR lijiw0lWA+byQBkz773d8e3pI5XH1MKkWVEjCuqKvzN4p/PPjhIVn9JKnpTPMQWubHXC 3AM+9RAbCo5/Pjg21zUa9FrlF0DSxOcGUG6oHUk1BVcjiRwvaCwRqo+zVSleaKz+hmYk v7aJ01+H8tQ8tFQ53Q653T0TH3Q4IeBViHr0DhZGs+6U/8/GoxGsRLMbexKMqWyRV0oI vOo2h7DiTqNPsJbZdf8R8OezbWR7l1PZIPFsBZ1dRbQMigHaI2OELXG6pSoetg7JV6+q 4M2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769161150; x=1769765950; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rG52QXraaViSSSy0BOpcFpXuiB3xymU1NOmvEWWxI0g=; b=rtmVnqZT79SavIpwcHQCuwBDf4RBITS1kQA5tK4X4EElLrliwmgARFaph7rDVMRO8P HLwExzF2oyz8tzI55iEWl2958O2sv4b3o2MGHPsXwD02g/1W9tpR+cuwqWJfGvZtC+ff 2HEIRTgTdOAA/uzXq+u32xzt+71/aH6QqOvP/VdSFIvUnOJaDTuR7CAoGUoE8m7ltn1b 7IM4oh6uvcBs6gIRagVlSo2YnswzlNhP0P6cEjbyt0B8OPuZxfPz8uG/hxfPqgV0SWHw tmsT5R8NFu56gbV8GVUsiNRdWos/sBEJHlcw/euXnaOaQszzQnIehPPnpS7zKifzdbCD 8k9A== X-Forwarded-Encrypted: i=1; AJvYcCUoZ+YBPLjtlhyOtR4m88ul/oOLjBJDyI0PqqA/Nx00wuIsDTWD1++WsYy05tVvhSsx3LlX6E3g0v5ddGE=@vger.kernel.org X-Gm-Message-State: AOJu0YwqHmMq1E1284415SKUuAQHzH37gbqug6NwCMbOv+hLWMV5S3mH C3Ac4GOa7FqZ7NlOwucADCdzKZJp2vt3TXdirYHznFg9GCeYljCAj3LokvvSq2deVIM6uto2u9Q jbYMkHH8JQB77YTEuEeo7wYp2CSe/du+7M8AwzNSsqw== X-Gm-Gg: AZuq6aIHHOKiKRxAf8F425mn7DU5bDNVtQUke3S2CEMKhMGW/0Av5NZhm18PZ/YLh+g x05lN8IYyNdcbWe2ovexujF/JYWIbc1jmxbQ9BGlBaKGNjRX21CVVa3v1NRNWhdnOgDiefv3gBk FLAAl9wGeSWWwGfsY4hmOBL3+EsnLNSeYdTu3dpXwsspmLUEskcJtiSpX2f8xTrA5cf4tKiJpCN 5gmnQvCoYWfXID3zNIy4LFhAKtGT0fd02bRwTh/LpoqsPzb6mE3z5DtTsqO+ZS02u3EE+tn X-Received: by 2002:a05:6512:61a6:b0:59b:b0f9:53ee with SMTP id 2adb3069b0e04-59de48f39b4mr696019e87.7.1769161150160; Fri, 23 Jan 2026 01:39:10 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20251126064251.1928529-1-quic_mdalam@quicinc.com> <3df0ad20-61c0-73c4-be8f-aea43f70cb69@quicinc.com> In-Reply-To: <3df0ad20-61c0-73c4-be8f-aea43f70cb69@quicinc.com> From: Ulf Hansson Date: Fri, 23 Jan 2026 10:38:33 +0100 X-Gm-Features: AZwV_Qj-fRTlNB7M0mC81wCnKPw6IPYxZZexdPMmRUIdx1ZRPaLvBhXQXt4TZrg Message-ID: Subject: Re: [PATCH v6] mmc: sdhci-msm: Enable ICE for CQE-capable controllers with non-CQE cards To: Md Sadre Alam Cc: adrian.hunter@intel.com, linux-arm-msm@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, abel.vesa@linaro.org, ebiggers@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 23 Jan 2026 at 07:10, Md Sadre Alam wrote= : > > Hi, > > On 1/21/2026 6:14 PM, Ulf Hansson wrote: > > On Wed, 26 Nov 2025 at 07:43, Md Sadre Alam w= rote: > >> > >> Enable Inline Crypto Engine (ICE) support for CQE-capable sdhci-msm > >> controllers when used with eMMC cards that do not support CQE. > >> > >> This addresses the scenario where: > >> - The host controller supports CQE (and has CQHCI crypto infrastructur= e) > >> - The eMMC card does not support CQE > >> - Standard (non-CMDQ) requests need crypto support > >> > >> This allows hardware-accelerated encryption and decryption for standar= d > >> requests on CQE-capable hardware by utilizing the existing CQHCI crypt= o > >> register space even when CQE functionality is not available due to car= d > >> limitations. > >> > >> The implementation: > >> - Adds ICE register definitions for non-CQE crypto configuration > >> - Implements per-request crypto setup via sdhci_msm_ice_cfg() > >> - Hooks into the request path via mmc_host_ops.request for non-CQE req= uests > >> - Uses CQHCI register space (NONCQ_CRYPTO_PARM/DUN) for crypto configu= ration > >> > >> With this, CQE-capable controllers can benefit from inline encryption > >> when paired with non-CQE cards, improving performance for encrypted I/= O > >> while maintaining compatibility with existing CQE crypto support. > >> > >> Signed-off-by: Md Sadre Alam > >> Acked-by: Adrian Hunter > > > > This has been applied for next since a few weeks, but I have a > > question. See more below. > > > > [...] > > > >> > >> drivers/mmc/host/sdhci-msm.c | 77 ++++++++++++++++++++++++++++++++++= ++ > >> 1 file changed, 77 insertions(+) > >> > >> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm= .c > >> index 3b85233131b3..da356627d9de 100644 > >> --- a/drivers/mmc/host/sdhci-msm.c > >> +++ b/drivers/mmc/host/sdhci-msm.c > >> @@ -157,6 +157,17 @@ > >> #define CQHCI_VENDOR_CFG1 0xA00 > >> #define CQHCI_VENDOR_DIS_RST_ON_CQ_EN (0x3 << 13) > >> > >> +/* non command queue crypto enable register*/ > >> +#define NONCQ_CRYPTO_PARM 0x70 > >> +#define NONCQ_CRYPTO_DUN 0x74 > >> + > >> +#define DISABLE_CRYPTO BIT(15) > >> +#define CRYPTO_GENERAL_ENABLE BIT(1) > >> +#define HC_VENDOR_SPECIFIC_FUNC4 0x260 > >> + > >> +#define ICE_HCI_PARAM_CCI GENMASK(7, 0) > >> +#define ICE_HCI_PARAM_CE GENMASK(8, 8) > >> + > >> struct sdhci_msm_offset { > >> u32 core_hc_mode; > >> u32 core_mci_data_cnt; > >> @@ -300,6 +311,7 @@ struct sdhci_msm_host { > >> u32 dll_config; > >> u32 ddr_config; > >> bool vqmmc_enabled; > >> + bool non_cqe_ice_init_done; > >> }; > >> > >> static const struct sdhci_msm_offset *sdhci_priv_msm_offset(struct s= dhci_host *host) > >> @@ -2012,6 +2024,68 @@ static int sdhci_msm_ice_keyslot_evict(struct b= lk_crypto_profile *profile, > >> return qcom_ice_evict_key(msm_host->ice, slot); > >> } > >> > >> +static void sdhci_msm_non_cqe_ice_init(struct sdhci_host *host) > >> +{ > >> + struct sdhci_pltfm_host *pltfm_host =3D sdhci_priv(host); > >> + struct sdhci_msm_host *msm_host =3D sdhci_pltfm_priv(pltfm_hos= t); > >> + struct mmc_host *mmc =3D msm_host->mmc; > >> + struct cqhci_host *cq_host =3D mmc->cqe_private; > >> + u32 config; > >> + > >> + config =3D sdhci_readl(host, HC_VENDOR_SPECIFIC_FUNC4); > >> + config &=3D ~DISABLE_CRYPTO; > >> + sdhci_writel(host, config, HC_VENDOR_SPECIFIC_FUNC4); > >> + config =3D cqhci_readl(cq_host, CQHCI_CFG); > >> + config |=3D CRYPTO_GENERAL_ENABLE; > >> + cqhci_writel(cq_host, config, CQHCI_CFG); > >> +} > >> + > >> +static void sdhci_msm_ice_cfg(struct sdhci_host *host, struct mmc_req= uest *mrq) > >> +{ > >> + struct sdhci_pltfm_host *pltfm_host =3D sdhci_priv(host); > >> + struct sdhci_msm_host *msm_host =3D sdhci_pltfm_priv(pltfm_hos= t); > >> + struct mmc_host *mmc =3D msm_host->mmc; > >> + struct cqhci_host *cq_host =3D mmc->cqe_private; > >> + unsigned int crypto_params =3D 0; > >> + int key_index; > >> + > >> + if (mrq->crypto_ctx) { > >> + if (!msm_host->non_cqe_ice_init_done) { > >> + sdhci_msm_non_cqe_ice_init(host); > >> + msm_host->non_cqe_ice_init_done =3D true; > >> + } > >> + > >> + key_index =3D mrq->crypto_key_slot; > >> + crypto_params =3D FIELD_PREP(ICE_HCI_PARAM_CE, 1) | > >> + FIELD_PREP(ICE_HCI_PARAM_CCI, key_inde= x); > >> + > >> + cqhci_writel(cq_host, crypto_params, NONCQ_CRYPTO_PARM= ); > >> + cqhci_writel(cq_host, lower_32_bits(mrq->crypto_ctx->b= c_dun[0]), > >> + NONCQ_CRYPTO_DUN); > >> + } else { > >> + cqhci_writel(cq_host, crypto_params, NONCQ_CRYPTO_PARM= ); > > > > Should we really call cqhci_writel() here, even if > > sdhci_msm_non_cqe_ice_init() has not been called yet? > > > Thanks for the pointing this. The else branch is intentional. > for plain requests we must clear the crypto registers, otherwise > the ICE hardware would continue using the previous encryption context. > ICE initialization is only required when programming an encryption > context, so we don=E2=80=99t call sdhci_msm_non_cqe_ice_init() in the pla= in > path. Writing 0 to NONCQ_CRYPTO_PARM is safe without ICE init and > ensures that subsequent plain requests are handled correctly Thanks for clarifying! Kind regards Uffe