Re: [PATCH RESEND v4] mmc: Avoid reprogram all keys to Inline Crypto Engine for MMC runtime suspend resume
From: Neeraj Soni
Date: Tue Jul 28 2026 - 02:02:15 EST
On 7/24/2026 4:31 AM, Eric Biggers wrote:
> On Fri, May 29, 2026 at 04:05:52PM +0530, Neeraj Soni wrote:
>> Yes for cold boot this is true and Crypto reprogram is not needed. This patch addreses the use cases like
>> runtime suspend resume, deep sleep / Quick boot (DS/QB) and suspend to disk (aka hibernation) use cases
>> where the runtime context is preserved either in dynamic memory (DS/QB) or in secondry memory (hibernation).
>> This is tested internally on SAR1250P chipset for hibernation and DS/QB.
>
> But sdhci_msm_gcc_reset() is called only from the driver probe function
> (sdhci_msm_probe()), before MMC_CAP2_CRYPTO is set. So Jie's comment is
> correct: the new key reprogramming path is dead code. And as per the
> following comment, key reprogramming is still needed in some cases
> (https://lore.kernel.org/linux-mmc/42797330-868a-bfcd-e0bb-b5f0dd3eeb16@xxxxxxxxxxxxxxxx/).
> So doesn't this patch break the sdhci-msm driver?
>
Yes, re-programming is needed only when the host is reset while the device
either resumes from a known previous state (like in hibernation) or is
already operating in a known state. I understood the concern regarding
MMC_CAP2_CRYPTO and will move the reprogramming to sdhci_msm_ice_init().
This was also suggested by Ulf here (https://lore.kernel.org/linux-mmc/CAPx+jO8rUwYV6q1-RrA4aZ9XnomSf82fgf8Jh2fUC0fE03RFPw@xxxxxxxxxxxxxx/).
Will post V5 to fix this.
> I'm also skeptical of the following change, which seems unrelated to the
> rest of the patch:
>
>> -#ifdef CONFIG_MMC_CRYPTO
>> #define MMC_CAP2_CRYPTO (1 << 27) /* Host supports inline encryption */
>> -#else
>> -#define MMC_CAP2_CRYPTO 0
>> -#endif
>
> Because of that, mtk-sd sets MMC_CAP2_CRYPTO even when
> CONFIG_MMC_CRYPTO=n. That makes CQHCI_CRYPTO_GENERAL_ENABLE be used
> even when CONFIG_MMC_CRYPTO=n.
>
Yes this is unrelated but it was cleaned up while cleaning similar change
for MMC_CAP2_CRYPTO_NO_REPROG here (https://lore.kernel.org/linux-mmc/cead2d86-bac8-2d4f-1a7d-c9b90dc05a7c@xxxxxxxxxxxxxxxx/)
Konrad had similar suggestion here https://lore.kernel.org/linux-mmc/a569a2c3-2fb2-4a40-8d54-898e7c36f4b3@xxxxxxxxxxxxxxxx/)
I will fix the mtk-sd driver in V5.
> - Eric
>
Regards,
Neeraj