Lines Matching refs:hba
23 static int ufshcd_program_key(struct ufs_hba *hba, in ufshcd_program_key() argument
27 u32 slot_offset = hba->crypto_cfg_register + slot * sizeof(*cfg); in ufshcd_program_key()
30 ufshcd_hold(hba, false); in ufshcd_program_key()
32 if (hba->vops && hba->vops->program_key) { in ufshcd_program_key()
33 err = hba->vops->program_key(hba, cfg, slot); in ufshcd_program_key()
38 ufshcd_writel(hba, 0, slot_offset + 16 * sizeof(cfg->reg_val[0])); in ufshcd_program_key()
40 ufshcd_writel(hba, le32_to_cpu(cfg->reg_val[i]), in ufshcd_program_key()
44 ufshcd_writel(hba, le32_to_cpu(cfg->reg_val[17]), in ufshcd_program_key()
47 ufshcd_writel(hba, le32_to_cpu(cfg->reg_val[16]), in ufshcd_program_key()
50 ufshcd_release(hba); in ufshcd_program_key()
58 struct ufs_hba *hba = container_of(ksm, struct ufs_hba, ksm); in ufshcd_crypto_keyslot_program() local
59 const union ufs_crypto_cap_entry *ccap_array = hba->crypto_cap_array; in ufshcd_crypto_keyslot_program()
69 for (i = 0; i < hba->crypto_capabilities.num_crypto_cap; i++) { in ufshcd_crypto_keyslot_program()
94 err = ufshcd_program_key(hba, &cfg, slot); in ufshcd_crypto_keyslot_program()
100 static int ufshcd_clear_keyslot(struct ufs_hba *hba, int slot) in ufshcd_clear_keyslot() argument
108 return ufshcd_program_key(hba, &cfg, slot); in ufshcd_clear_keyslot()
115 struct ufs_hba *hba = container_of(ksm, struct ufs_hba, ksm); in ufshcd_crypto_keyslot_evict() local
117 return ufshcd_clear_keyslot(hba, slot); in ufshcd_crypto_keyslot_evict()
120 bool ufshcd_crypto_enable(struct ufs_hba *hba) in ufshcd_crypto_enable() argument
122 if (!(hba->caps & UFSHCD_CAP_CRYPTO)) in ufshcd_crypto_enable()
126 if (hba->ksm.num_slots) { in ufshcd_crypto_enable()
129 trace_android_rvh_ufs_reprogram_all_keys(hba, &err); in ufshcd_crypto_enable()
131 blk_ksm_reprogram_all_keys(&hba->ksm); in ufshcd_crypto_enable()
134 if (hba->quirks & UFSHCD_QUIRK_BROKEN_CRYPTO_ENABLE) in ufshcd_crypto_enable()
167 int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba) in ufshcd_hba_init_crypto_capabilities() argument
173 if (hba->quirks & UFSHCD_QUIRK_CUSTOM_KEYSLOT_MANAGER) in ufshcd_hba_init_crypto_capabilities()
181 if (!(hba->capabilities & MASK_CRYPTO_SUPPORT) || in ufshcd_hba_init_crypto_capabilities()
182 !(hba->caps & UFSHCD_CAP_CRYPTO)) in ufshcd_hba_init_crypto_capabilities()
185 hba->crypto_capabilities.reg_val = in ufshcd_hba_init_crypto_capabilities()
186 cpu_to_le32(ufshcd_readl(hba, REG_UFS_CCAP)); in ufshcd_hba_init_crypto_capabilities()
187 hba->crypto_cfg_register = in ufshcd_hba_init_crypto_capabilities()
188 (u32)hba->crypto_capabilities.config_array_ptr * 0x100; in ufshcd_hba_init_crypto_capabilities()
189 hba->crypto_cap_array = in ufshcd_hba_init_crypto_capabilities()
190 devm_kcalloc(hba->dev, hba->crypto_capabilities.num_crypto_cap, in ufshcd_hba_init_crypto_capabilities()
191 sizeof(hba->crypto_cap_array[0]), GFP_KERNEL); in ufshcd_hba_init_crypto_capabilities()
192 if (!hba->crypto_cap_array) { in ufshcd_hba_init_crypto_capabilities()
198 err = devm_blk_ksm_init(hba->dev, &hba->ksm, in ufshcd_hba_init_crypto_capabilities()
199 hba->crypto_capabilities.config_count + 1); in ufshcd_hba_init_crypto_capabilities()
203 hba->ksm.ksm_ll_ops = ufshcd_ksm_ops; in ufshcd_hba_init_crypto_capabilities()
205 hba->ksm.max_dun_bytes_supported = 8; in ufshcd_hba_init_crypto_capabilities()
206 hba->ksm.features = BLK_CRYPTO_FEATURE_STANDARD_KEYS; in ufshcd_hba_init_crypto_capabilities()
207 hba->ksm.dev = hba->dev; in ufshcd_hba_init_crypto_capabilities()
213 for (cap_idx = 0; cap_idx < hba->crypto_capabilities.num_crypto_cap; in ufshcd_hba_init_crypto_capabilities()
215 hba->crypto_cap_array[cap_idx].reg_val = in ufshcd_hba_init_crypto_capabilities()
216 cpu_to_le32(ufshcd_readl(hba, in ufshcd_hba_init_crypto_capabilities()
220 hba->crypto_cap_array[cap_idx]); in ufshcd_hba_init_crypto_capabilities()
222 hba->ksm.crypto_modes_supported[blk_mode_num] |= in ufshcd_hba_init_crypto_capabilities()
223 hba->crypto_cap_array[cap_idx].sdus_mask * 512; in ufshcd_hba_init_crypto_capabilities()
230 hba->caps &= ~UFSHCD_CAP_CRYPTO; in ufshcd_hba_init_crypto_capabilities()
238 void ufshcd_init_crypto(struct ufs_hba *hba) in ufshcd_init_crypto() argument
242 if (!(hba->caps & UFSHCD_CAP_CRYPTO)) in ufshcd_init_crypto()
246 for (slot = 0; slot < hba->ksm.num_slots; slot++) in ufshcd_init_crypto()
247 hba->ksm.ksm_ll_ops.keyslot_evict(&hba->ksm, NULL, slot); in ufshcd_init_crypto()
250 void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba, in ufshcd_crypto_setup_rq_keyslot_manager() argument
253 if (hba->caps & UFSHCD_CAP_CRYPTO) in ufshcd_crypto_setup_rq_keyslot_manager()
254 blk_ksm_register(&hba->ksm, q); in ufshcd_crypto_setup_rq_keyslot_manager()