Re: [PATCH RESEND v4] mmc: Avoid reprogram all keys to Inline Crypto Engine for MMC runtime suspend resume

Neeraj Soni <[email protected]> Tue, 28 Jul 2026 11:31:45 +0530
Newsgroups org.kernel.vger.linux-mmc,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

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/[email protected]/).
> 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@mail.gmail.com/).
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/[email protected]/)
Konrad had similar suggestion here https://lore.kernel.org/linux-mmc/[email protected]/)
I will fix the mtk-sd driver in V5.

> - Eric
> 
Regards,
Neeraj