ANDROID: scsi: ufs: revise and fix custom keyslot manager support

UFSHCD_QUIRK_BROKEN_CRYPTO_CAPS really means
"override the blk_keyslot_manager", which (at least for now) handles
both the crypto capabilities and the actual keyslot management.
So give it a better name: UFSHCD_QUIRK_CUSTOM_KEYSLOT_MANAGER.

Also, fix ufshcd_init_crypto() to call hba->ksm.ksm_ll_ops.keyslot_evict
instead of using the standard key eviction procedure.  This is needed
when the blk_keyslot_manager is overridden with one that has
num_slots > 0 and uses a nonstandard key eviction procedure.

This patch, ANDROID-scsi-ufs-add-UFSHCD_QUIRK_BROKEN_CRYPTO_CAPS.patch,
and ANDROID-scsi-ufs-allow-for-there-to-be-no-keyslots.patch should all
be folded into one patch.

Bug: 162257402
Bug: 166139333
Change-Id: I7081bdd111f638eb28366aacbd9f9c3a093495ee
Signed-off-by: Eric Biggers <ebiggers@google.com>
This commit is contained in:
Eric Biggers 2020-11-06 11:22:23 -08:00
parent 9bdaa3fa87
commit ab8a8ffd2f
2 changed files with 7 additions and 6 deletions

View File

@ -162,7 +162,7 @@ int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
int err = 0;
enum blk_crypto_mode_num blk_mode_num;
if (hba->quirks & UFSHCD_QUIRK_BROKEN_CRYPTO_CAPS)
if (hba->quirks & UFSHCD_QUIRK_CUSTOM_KEYSLOT_MANAGER)
return 0;
/*
@ -238,7 +238,7 @@ void ufshcd_init_crypto(struct ufs_hba *hba)
/* Clear all keyslots */
for (slot = 0; slot < hba->ksm.num_slots; slot++)
ufshcd_clear_keyslot(hba, slot);
hba->ksm.ksm_ll_ops.keyslot_evict(&hba->ksm, NULL, slot);
}
void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,

View File

@ -557,11 +557,12 @@ enum ufshcd_quirks {
/*
* This quirk needs to be enabled if the host controller supports inline
* encryption, but it doesn't use the standard crypto capability
* registers. If enabled, the standard code won't initialize the
* keyslot manager; ufs_hba_variant_ops::init() must do it instead.
* encryption, but it needs to initialize the crypto capabilities in a
* nonstandard way and/or it needs to override blk_ksm_ll_ops. If
* enabled, the standard code won't initialize the blk_keyslot_manager;
* ufs_hba_variant_ops::init() must do it instead.
*/
UFSHCD_QUIRK_BROKEN_CRYPTO_CAPS = 1 << 20,
UFSHCD_QUIRK_CUSTOM_KEYSLOT_MANAGER = 1 << 20,
/*
* This quirk needs to be enabled if the host controller supports inline