ufs: crypto: check for ufs state before key programming
There might be asynchronous calls to program ICE keys when UFS is in an error state. Avoid programming keys in these cases and program only when UFS is in a reset or operational state. Change-Id: If9a2a89daf515c6a61a0440c1abfabd1ebacfac3 Signed-off-by: Gaurav Kashyap <gaurkash@codeaurora.org>
This commit is contained in:
parent
1a8360450f
commit
a354ef58a6
@ -15,6 +15,14 @@
|
||||
#define MINIMUM_DUN_SIZE 512
|
||||
#define MAXIMUM_DUN_SIZE 65536
|
||||
|
||||
enum {
|
||||
UFSHCD_STATE_RESET,
|
||||
UFSHCD_STATE_ERROR,
|
||||
UFSHCD_STATE_OPERATIONAL,
|
||||
UFSHCD_STATE_EH_SCHEDULED_FATAL,
|
||||
UFSHCD_STATE_EH_SCHEDULED_NON_FATAL,
|
||||
};
|
||||
|
||||
/* Blk-crypto modes supported by UFS crypto */
|
||||
static const struct ufs_crypto_alg_entry {
|
||||
enum ufs_crypto_alg ufs_alg;
|
||||
@ -69,6 +77,13 @@ static int ufshcd_crypto_qti_keyslot_program(struct blk_keyslot_manager *ksm,
|
||||
if (WARN_ON(cap_idx < 0))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if ((hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL) &&
|
||||
(hba->ufshcd_state != UFSHCD_STATE_RESET)) {
|
||||
pr_err("UFS not in reset or op state, state = 0x%x\n",
|
||||
hba->ufshcd_state);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = ufshcd_hold(hba, false);
|
||||
if (err) {
|
||||
pr_err("%s: failed to enable clocks, err %d\n", __func__, err);
|
||||
@ -96,6 +111,13 @@ static int ufshcd_crypto_qti_keyslot_evict(struct blk_keyslot_manager *ksm,
|
||||
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
|
||||
struct ice_mmio_data mmio_data;
|
||||
|
||||
if ((hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL) &&
|
||||
(hba->ufshcd_state != UFSHCD_STATE_RESET)) {
|
||||
pr_err("UFS not in reset or op state, state = 0x%x\n",
|
||||
hba->ufshcd_state);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = ufshcd_hold(hba, false);
|
||||
if (err) {
|
||||
pr_err("%s: failed to enable clocks, err %d\n", __func__, err);
|
||||
@ -121,6 +143,13 @@ static int ufshcd_crypto_qti_derive_raw_secret(struct blk_keyslot_manager *ksm,
|
||||
int err = 0;
|
||||
struct ufs_hba *hba = container_of(ksm, struct ufs_hba, ksm);
|
||||
|
||||
if ((hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL) &&
|
||||
(hba->ufshcd_state != UFSHCD_STATE_RESET)) {
|
||||
pr_err("UFS not in reset or op state, state = 0x%x\n",
|
||||
hba->ufshcd_state);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = ufshcd_hold(hba, false);
|
||||
if (err) {
|
||||
pr_err("%s: failed to enable clocks, err %d\n", __func__, err);
|
||||
|
Loading…
Reference in New Issue
Block a user