Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Md Sadre Alam <quic_mdalam@quicinc.com>
Cc: adrian.hunter@intel.com, ulf.hansson@linaro.org,
	abel.vesa@linaro.org, linux-arm-msm@vger.kernel.org,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] mmc: sdhci-msm: Enable ICE for CQE-capable controllers with non-CQE cards
Date: Fri, 21 Nov 2025 02:12:32 +0000	[thread overview]
Message-ID: <20251121021232.GD3078357@google.com> (raw)
In-Reply-To: <20251119114653.751992-1-quic_mdalam@quicinc.com>

On Wed, Nov 19, 2025 at 05:16:53PM +0530, Md Sadre Alam wrote:
>  struct sdhci_msm_offset {
>  	u32 core_hc_mode;
>  	u32 core_mci_data_cnt;
> @@ -300,6 +312,7 @@ struct sdhci_msm_host {
>  	u32 dll_config;
>  	u32 ddr_config;
>  	bool vqmmc_enabled;
> +	bool ice_init_done;

Rename to non_cqe_ice_init_done

> +static void sdhci_msm_non_cqe_ice_init(struct sdhci_host *host)
> +{
> +	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> +	struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
> +	struct mmc_host *mmc = msm_host->mmc;
> +	struct cqhci_host *cq_host = mmc->cqe_private;
> +	u32 config;
> +	u32 ice_cap;
> +
> +	config = sdhci_readl(host, HC_VENDOR_SPECIFIC_FUNC4);
> +	config &= ~DISABLE_CRYPTO;
> +	sdhci_writel(host, config, HC_VENDOR_SPECIFIC_FUNC4);
> +	ice_cap = cqhci_readl(cq_host, CQHCI_CAP);
> +	if (ice_cap & ICE_HCI_SUPPORT) {
> +		config = cqhci_readl(cq_host, CQHCI_CFG);
> +		config |= CRYPTO_GENERAL_ENABLE;
> +		cqhci_writel(cq_host, config, CQHCI_CFG);
> +	}
> +}

Why would ICE_HCI_SUPPORT not be set here?  When this is called, the
driver is already in the middle of processing an mmc_request with an
encryption context, due to the driver advertising that it supports
inline crypto earlier.  If the hardware doesn't actually support inline
crypto, that has to be detected earlier.  But I thought it already does.
So it's unclear what checking ICE_HCI_SUPPORT here is meant to achieve.

> +static int sdhci_msm_ice_cfg(struct sdhci_host *host, struct mmc_request *mrq)

This should return void.

> +	if (mrq->crypto_ctx) {
> +		if (!msm_host->ice_init_done) {
> +			sdhci_msm_non_cqe_ice_init(host);
> +			msm_host->ice_init_done = true;
> +		}
> +
> +		crypto_enable = true;
> +		dun = mrq->crypto_ctx->bc_dun[0];
> +		key_index = mrq->crypto_key_slot;
> +		crypto_params = FIELD_PREP(ICE_HCI_PARAM_CE, crypto_enable) |
> +				FIELD_PREP(ICE_HCI_PARAM_CCI, key_index);
> +
> +		cqhci_writel(cq_host, crypto_params, NONCQ_CRYPTO_PARM);
> +		cqhci_writel(cq_host, lower_32_bits(dun), NONCQ_CRYPTO_DUN);

No need for the crypto_enable variable.  Just use:

	FIELD_PREP(ICE_HCI_PARAM_CE, 1).

Also no need for the dun variable.  Just use: 

	cqhci_writel(cq_host, lower_32_bits(mrq->crypto_ctx->bc_dun[0]),
		     NONCQ_CRYPTO_DUN);

> + * For CQE requests, crypto is handled in cqhci_request() in
> + * drivers/mmc/host/cqhci-core.c using the existing CQE crypto infrastructure.

It's recommended to not reference file paths like this in kernel code,
since files are sometimes moved around.

- Eric

  parent reply	other threads:[~2025-11-21  2:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19 11:46 [PATCH v5] mmc: sdhci-msm: Enable ICE for CQE-capable controllers with non-CQE cards Md Sadre Alam
2025-11-20  6:40 ` Adrian Hunter
2025-11-21  6:28   ` Md Sadre Alam
2025-11-21  2:12 ` Eric Biggers [this message]
2025-11-21  6:33   ` Md Sadre Alam

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=20251121021232.GD3078357@google.com \
    --to=ebiggers@kernel.org \
    --cc=abel.vesa@linaro.org \
    --cc=adrian.hunter@intel.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=quic_mdalam@quicinc.com \
    --cc=ulf.hansson@linaro.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