ice_driver: Fix the ice keyslot conflict
FDE only use one ice keyslot on gen3, the remains used by FBE. For the ufs crypto layer, it needs to support FBE and FDE request concurrently. Test cases: 1. LV host FDE OTA and basic test validated pass 2. LA container FBE OTA and basic test validated pass. Change-Id: Ic0c6e0f9d39d351c1095f531f1fa8bd2a8e614b7 Signed-off-by: jianshu <quic_jianshu@quicinc.com>
This commit is contained in:
@@ -5402,14 +5402,20 @@ static void ufs_qcom_hook_prepare_command(void *param, struct ufs_hba *hba,
|
||||
#if IS_ENABLED(CONFIG_QTI_CRYPTO_FDE)
|
||||
struct ice_data_setting setting;
|
||||
|
||||
if (!crypto_qti_ice_config_start(rq, &setting)) {
|
||||
if ((rq_data_dir(rq) == WRITE) ? setting.encr_bypass : setting.decr_bypass) {
|
||||
lrbp->crypto_key_slot = -1;
|
||||
} else {
|
||||
lrbp->crypto_key_slot = setting.crypto_data.key_index;
|
||||
lrbp->data_unit_num = rq->bio->bi_iter.bi_sector >>
|
||||
ICE_CRYPTO_DATA_UNIT_4_KB;
|
||||
if (!rq->crypt_keyslot) {
|
||||
if (!crypto_qti_ice_config_start(rq, &setting)) {
|
||||
if ((rq_data_dir(rq) == WRITE) ? setting.encr_bypass :
|
||||
setting.decr_bypass) {
|
||||
lrbp->crypto_key_slot = -1;
|
||||
} else {
|
||||
lrbp->crypto_key_slot = setting.crypto_data.key_index;
|
||||
lrbp->data_unit_num = rq->bio->bi_iter.bi_sector >>
|
||||
ICE_CRYPTO_DATA_UNIT_4_KB;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lrbp->crypto_key_slot = blk_ksm_get_slot_idx(rq->crypt_keyslot);
|
||||
lrbp->data_unit_num = rq->crypt_ctx->bc_dun[0];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -186,6 +186,7 @@ int ufshcd_qti_hba_init_crypto_capabilities(struct ufs_hba *hba)
|
||||
{
|
||||
int cap_idx;
|
||||
int err = 0;
|
||||
unsigned int max_slots = 0;
|
||||
enum blk_crypto_mode_num blk_mode_num;
|
||||
|
||||
/*
|
||||
@@ -212,9 +213,27 @@ int ufshcd_qti_hba_init_crypto_capabilities(struct ufs_hba *hba)
|
||||
goto out;
|
||||
}
|
||||
|
||||
max_slots = hba->crypto_capabilities.config_count + 1;
|
||||
#if IS_ENABLED(CONFIG_QTI_CRYPTO_FDE)
|
||||
if (max_slots > crypto_qti_ice_get_num_fde_slots()) {
|
||||
/*
|
||||
* Reduce the total number of slots available to FBE
|
||||
* (by the number reserved for the FDE)
|
||||
* Check at least one slot for backward compatibility,
|
||||
* otherwise return failure
|
||||
*/
|
||||
if (max_slots - crypto_qti_ice_get_num_fde_slots() < 1) {
|
||||
pr_err("%s: Too much slots allocated to fde\n", __func__);
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
} else {
|
||||
max_slots = max_slots - crypto_qti_ice_get_num_fde_slots();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The actual number of configurations supported is (CFGC+1) */
|
||||
err = devm_blk_ksm_init(hba->dev, &hba->ksm,
|
||||
hba->crypto_capabilities.config_count + 1);
|
||||
err = devm_blk_ksm_init(hba->dev, &hba->ksm, max_slots);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user