Skip to content

Commit e95881e

Browse files
ebiggersmartinkpetersen
authored andcommitted
scsi: ufs: core: Add UFSHCD_QUIRK_BROKEN_CRYPTO_ENABLE
Add UFSHCD_QUIRK_BROKEN_CRYPTO_ENABLE which tells the UFS core to not use the crypto enable bit defined by the UFS specification. This is needed to support inline encryption on the "Exynos" UFS controller. Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Peter Griffin <[email protected]> Signed-off-by: Eric Biggers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Alim Akhtar <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent ec99818 commit e95881e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/ufs/core/ufshcd-crypto.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,21 @@ static int ufshcd_crypto_keyslot_evict(struct blk_crypto_profile *profile,
110110
return ufshcd_program_key(hba, &cfg, slot);
111111
}
112112

113+
/*
114+
* Reprogram the keyslots if needed, and return true if CRYPTO_GENERAL_ENABLE
115+
* should be used in the host controller initialization sequence.
116+
*/
113117
bool ufshcd_crypto_enable(struct ufs_hba *hba)
114118
{
115119
if (!(hba->caps & UFSHCD_CAP_CRYPTO))
116120
return false;
117121

118122
/* Reset might clear all keys, so reprogram all the keys. */
119123
blk_crypto_reprogram_all_keys(&hba->crypto_profile);
124+
125+
if (hba->quirks & UFSHCD_QUIRK_BROKEN_CRYPTO_ENABLE)
126+
return false;
127+
120128
return true;
121129
}
122130

include/ufs/ufshcd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,13 @@ enum ufshcd_quirks {
654654
* ufs_hba_variant_ops::init() must do it instead.
655655
*/
656656
UFSHCD_QUIRK_CUSTOM_CRYPTO_PROFILE = 1 << 22,
657+
658+
/*
659+
* This quirk needs to be enabled if the host controller supports inline
660+
* encryption but does not support the CRYPTO_GENERAL_ENABLE bit, i.e.
661+
* host controller initialization fails if that bit is set.
662+
*/
663+
UFSHCD_QUIRK_BROKEN_CRYPTO_ENABLE = 1 << 23,
657664
};
658665

659666
enum ufshcd_caps {

0 commit comments

Comments
 (0)