Re: [PATCH v6 1/2] mmc: Allow host driver to control the re-programming of crypto keys

Dmitry Baryshkov <[email protected]> Mon, 3 Aug 2026 21:12:05 +0300
Newsgroups org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel,org.kernel.vger.linux-mmc
Message-ID <wz2zgw7kp7vsc3r43wa2kssi4niy5itsmee5rbnki6lfvmid4z@qdt6ib3sj4wl>
On Mon, Aug 03, 2026 at 10:01:22PM +0530, Neeraj Soni wrote:
> The register context for the crypto profile belongs to the
> sdhci/cqhci host and not the mmc card, hence re-programming should be
> managed by the host driver itself.

Don't you have a reference to the host in the function?

> 
> Add the flag MMC_CAP2_CRYPTO_NO_REPROG as part of host->caps2 to control
> reprogramming keys to crypto engine for SoCs which do not require this
> feature.
> 
> Signed-off-by: Seshu Madhavi Puppala <[email protected]>
> Co-developed-by: Ram Prakash Gupta <[email protected]>
> Signed-off-by: Ram Prakash Gupta <[email protected]>
> Co-developed-by: Sarthak Garg <[email protected]>
> Signed-off-by: Sarthak Garg <[email protected]>
> Signed-off-by: Debraj Mukhopadhyay <[email protected]>
> Signed-off-by: Neeraj Soni <[email protected]>
> ---
>  drivers/mmc/core/crypto.c | 2 +-
>  include/linux/mmc/host.h  | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/core/crypto.c b/drivers/mmc/core/crypto.c
> index fec4fbf16a5b..a5a90bfc634e 100644
> --- a/drivers/mmc/core/crypto.c
> +++ b/drivers/mmc/core/crypto.c
> @@ -15,7 +15,7 @@
>  void mmc_crypto_set_initial_state(struct mmc_host *host)
>  {
>  	/* Reset might clear all keys, so reprogram all the keys. */
> -	if (host->caps2 & MMC_CAP2_CRYPTO)
> +	if ((host->caps2 & MMC_CAP2_CRYPTO) && !(host->caps2 & MMC_CAP2_CRYPTO_NO_REPROG))
>  		blk_crypto_reprogram_all_keys(&host->crypto_profile);
>  }

-- 
With best wishes
Dmitry