Skip to content

Commit c2a90ee

Browse files
ebiggersmartinkpetersen
authored andcommitted
scsi: ufs: core: Add UFSHCD_QUIRK_CUSTOM_CRYPTO_PROFILE
Add UFSHCD_QUIRK_CUSTOM_CRYPTO_PROFILE which lets UFS host drivers initialize the blk_crypto_profile themselves rather than have it be initialized by ufshcd-core according to the UFSHCI standard. This is needed to support inline encryption on the "Exynos" UFS controller which has a nonstandard interface. 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 a420a8e commit c2a90ee

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

drivers/ufs/core/ufshcd-crypto.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
159159
int err = 0;
160160
enum blk_crypto_mode_num blk_mode_num;
161161

162+
if (hba->quirks & UFSHCD_QUIRK_CUSTOM_CRYPTO_PROFILE)
163+
return 0;
164+
162165
/*
163166
* Don't use crypto if either the hardware doesn't advertise the
164167
* standard crypto capability bit *or* if the vendor specific driver
@@ -228,9 +231,10 @@ void ufshcd_init_crypto(struct ufs_hba *hba)
228231
if (!(hba->caps & UFSHCD_CAP_CRYPTO))
229232
return;
230233

231-
/* Clear all keyslots - the number of keyslots is (CFGC + 1) */
232-
for (slot = 0; slot < hba->crypto_capabilities.config_count + 1; slot++)
233-
ufshcd_clear_keyslot(hba, slot);
234+
/* Clear all keyslots. */
235+
for (slot = 0; slot < hba->crypto_profile.num_slots; slot++)
236+
hba->crypto_profile.ll_ops.keyslot_evict(&hba->crypto_profile,
237+
NULL, slot);
234238
}
235239

236240
void ufshcd_crypto_register(struct ufs_hba *hba, struct request_queue *q)

include/ufs/ufshcd.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,15 @@ enum ufshcd_quirks {
645645
* thus need this quirk to skip related flow.
646646
*/
647647
UFSHCD_QUIRK_MCQ_BROKEN_RTC = 1 << 21,
648+
649+
/*
650+
* This quirk needs to be enabled if the host controller supports inline
651+
* encryption but it needs to initialize the crypto capabilities in a
652+
* nonstandard way and/or needs to override blk_crypto_ll_ops. If
653+
* enabled, the standard code won't initialize the blk_crypto_profile;
654+
* ufs_hba_variant_ops::init() must do it instead.
655+
*/
656+
UFSHCD_QUIRK_CUSTOM_CRYPTO_PROFILE = 1 << 22,
648657
};
649658

650659
enum ufshcd_caps {

0 commit comments

Comments
 (0)