Revert "ANDROID: scsi: ufs: UFS crypto variant operations API"
The ufs_hba_crypto_variant_ops support is causing lots of merge
conflicts with upstream, and it contains a lot of functionality that
vendors didn't end up using. Drop it for now; anything that's really
needed can be added back later with a proper justification.
Change-Id: I59b2de431bf770b922f319d227c2b539acaf985d
Signed-off-by: Eric Biggers <ebiggers@google.com>
diff --git a/drivers/scsi/ufs/ufshcd-crypto.c b/drivers/scsi/ufs/ufshcd-crypto.c
index b52f0b9..9bb8251 100644
--- a/drivers/scsi/ufs/ufshcd-crypto.c
+++ b/drivers/scsi/ufs/ufshcd-crypto.c
@@ -122,8 +122,7 @@ static int ufshcd_crypto_keyslot_evict(struct blk_keyslot_manager *ksm,
return 0;
}
-/* Functions implementing UFSHCI v2.1 specification behaviour */
-bool ufshcd_crypto_enable_spec(struct ufs_hba *hba)
+bool ufshcd_crypto_enable(struct ufs_hba *hba)
{
if (!(hba->caps & UFSHCD_CAP_CRYPTO))
return false;
@@ -132,7 +131,6 @@ bool ufshcd_crypto_enable_spec(struct ufs_hba *hba)
blk_ksm_reprogram_all_keys(&hba->ksm);
return true;
}
-EXPORT_SYMBOL(ufshcd_crypto_enable_spec);
static const struct blk_ksm_ll_ops ufshcd_ksm_ops = {
.keyslot_program = ufshcd_crypto_keyslot_program,
@@ -160,8 +158,7 @@ ufshcd_find_blk_crypto_mode(union ufs_crypto_cap_entry cap)
*
* Return: 0 if crypto was initialized or is not supported, else a -errno value.
*/
-int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba,
- const struct blk_ksm_ll_ops *ksm_ops)
+int ufshcd_hba_init_crypto(struct ufs_hba *hba)
{
int cap_idx = 0;
int err = 0;
@@ -196,7 +193,7 @@ int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba,
if (err)
goto out_free_caps;
- hba->ksm.ksm_ll_ops = *ksm_ops;
+ hba->ksm.ksm_ll_ops = ufshcd_ksm_ops;
/* UFS only supports 8 bytes for any DUN */
hba->ksm.max_dun_bytes_supported = 8;
hba->ksm.features = BLK_CRYPTO_FEATURE_STANDARD_KEYS;
@@ -231,118 +228,15 @@ int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba,
hba->caps &= ~UFSHCD_CAP_CRYPTO;
return err;
}
-EXPORT_SYMBOL(ufshcd_hba_init_crypto_spec);
-
-void ufshcd_crypto_setup_rq_keyslot_manager_spec(struct ufs_hba *hba,
- struct request_queue *q)
-{
- if (hba->caps & UFSHCD_CAP_CRYPTO)
- blk_ksm_register(&hba->ksm, q);
-}
-EXPORT_SYMBOL(ufshcd_crypto_setup_rq_keyslot_manager_spec);
-
-void ufshcd_crypto_destroy_keyslot_manager_spec(struct ufs_hba *hba)
-{
- blk_ksm_destroy(&hba->ksm);
-}
-EXPORT_SYMBOL(ufshcd_crypto_destroy_keyslot_manager_spec);
-
-/* Crypto Variant Ops Support */
-
-bool ufshcd_crypto_enable(struct ufs_hba *hba)
-{
- if (hba->crypto_vops && hba->crypto_vops->enable)
- return hba->crypto_vops->enable(hba);
-
- return ufshcd_crypto_enable_spec(hba);
-}
-
-int ufshcd_hba_init_crypto(struct ufs_hba *hba)
-{
- if (hba->crypto_vops && hba->crypto_vops->hba_init_crypto)
- return hba->crypto_vops->hba_init_crypto(hba,
- &ufshcd_ksm_ops);
-
- return ufshcd_hba_init_crypto_spec(hba, &ufshcd_ksm_ops);
-}
void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
struct request_queue *q)
{
- if (hba->crypto_vops && hba->crypto_vops->setup_rq_keyslot_manager) {
- hba->crypto_vops->setup_rq_keyslot_manager(hba, q);
- return;
- }
-
- ufshcd_crypto_setup_rq_keyslot_manager_spec(hba, q);
+ if (hba->caps & UFSHCD_CAP_CRYPTO)
+ blk_ksm_register(&hba->ksm, q);
}
void ufshcd_crypto_destroy_keyslot_manager(struct ufs_hba *hba)
{
- if (hba->crypto_vops && hba->crypto_vops->destroy_keyslot_manager) {
- hba->crypto_vops->destroy_keyslot_manager(hba);
- return;
- }
-
- ufshcd_crypto_destroy_keyslot_manager_spec(hba);
-}
-
-void ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
- struct scsi_cmnd *cmd,
- struct ufshcd_lrb *lrbp)
-{
- if (hba->crypto_vops && hba->crypto_vops->prepare_lrbp_crypto) {
- hba->crypto_vops->prepare_lrbp_crypto(hba, cmd, lrbp);
- return;
- }
-
- ufshcd_prepare_lrbp_crypto_spec(hba, cmd, lrbp);
-}
-
-int ufshcd_map_sg_crypto(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
-{
- if (hba->crypto_vops && hba->crypto_vops->map_sg_crypto)
- return hba->crypto_vops->map_sg_crypto(hba, lrbp);
-
- return 0;
-}
-
-int ufshcd_complete_lrbp_crypto(struct ufs_hba *hba,
- struct scsi_cmnd *cmd,
- struct ufshcd_lrb *lrbp)
-{
- if (hba->crypto_vops && hba->crypto_vops->complete_lrbp_crypto)
- return hba->crypto_vops->complete_lrbp_crypto(hba, cmd, lrbp);
-
- return 0;
-}
-
-void ufshcd_crypto_debug(struct ufs_hba *hba)
-{
- if (hba->crypto_vops && hba->crypto_vops->debug)
- hba->crypto_vops->debug(hba);
-}
-
-int ufshcd_crypto_suspend(struct ufs_hba *hba,
- enum ufs_pm_op pm_op)
-{
- if (hba->crypto_vops && hba->crypto_vops->suspend)
- return hba->crypto_vops->suspend(hba, pm_op);
-
- return 0;
-}
-
-int ufshcd_crypto_resume(struct ufs_hba *hba,
- enum ufs_pm_op pm_op)
-{
- if (hba->crypto_vops && hba->crypto_vops->resume)
- return hba->crypto_vops->resume(hba, pm_op);
-
- return 0;
-}
-
-void ufshcd_crypto_set_vops(struct ufs_hba *hba,
- struct ufs_hba_crypto_variant_ops *crypto_vops)
-{
- hba->crypto_vops = crypto_vops;
+ blk_ksm_destroy(&hba->ksm);
}
diff --git a/drivers/scsi/ufs/ufshcd-crypto.h b/drivers/scsi/ufs/ufshcd-crypto.h
index 7fbc459..9578edb 100644
--- a/drivers/scsi/ufs/ufshcd-crypto.h
+++ b/drivers/scsi/ufs/ufshcd-crypto.h
@@ -10,9 +10,9 @@
#include "ufshcd.h"
#include "ufshci.h"
-static inline void ufshcd_prepare_lrbp_crypto_spec(struct ufs_hba *hba,
- struct scsi_cmnd *cmd,
- struct ufshcd_lrb *lrbp)
+static inline void ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
+ struct scsi_cmnd *cmd,
+ struct ufshcd_lrb *lrbp)
{
struct request *rq = cmd->request;
@@ -24,18 +24,6 @@ static inline void ufshcd_prepare_lrbp_crypto_spec(struct ufs_hba *hba,
}
}
-bool ufshcd_crypto_enable_spec(struct ufs_hba *hba);
-
-struct blk_ksm_ll_ops;
-int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba,
- const struct blk_ksm_ll_ops *ksm_ops);
-
-void ufshcd_crypto_setup_rq_keyslot_manager_spec(struct ufs_hba *hba,
- struct request_queue *q);
-
-void ufshcd_crypto_destroy_keyslot_manager_spec(struct ufs_hba *hba);
-
-/* Crypto Variant Ops Support */
bool ufshcd_crypto_enable(struct ufs_hba *hba);
int ufshcd_hba_init_crypto(struct ufs_hba *hba);
@@ -45,25 +33,6 @@ void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
void ufshcd_crypto_destroy_keyslot_manager(struct ufs_hba *hba);
-void ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
- struct scsi_cmnd *cmd,
- struct ufshcd_lrb *lrbp);
-
-int ufshcd_map_sg_crypto(struct ufs_hba *hba, struct ufshcd_lrb *lrbp);
-
-int ufshcd_complete_lrbp_crypto(struct ufs_hba *hba,
- struct scsi_cmnd *cmd,
- struct ufshcd_lrb *lrbp);
-
-void ufshcd_crypto_debug(struct ufs_hba *hba);
-
-int ufshcd_crypto_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op);
-
-int ufshcd_crypto_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op);
-
-void ufshcd_crypto_set_vops(struct ufs_hba *hba,
- struct ufs_hba_crypto_variant_ops *crypto_vops);
-
#else /* CONFIG_SCSI_UFS_CRYPTO */
static inline void ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
@@ -86,36 +55,6 @@ static inline void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
static inline void ufshcd_crypto_destroy_keyslot_manager(struct ufs_hba *hba)
{ }
-static inline int ufshcd_map_sg_crypto(struct ufs_hba *hba,
- struct ufshcd_lrb *lrbp)
-{
- return 0;
-}
-
-static inline int ufshcd_complete_lrbp_crypto(struct ufs_hba *hba,
- struct scsi_cmnd *cmd,
- struct ufshcd_lrb *lrbp)
-{
- return 0;
-}
-
-static inline void ufshcd_crypto_debug(struct ufs_hba *hba) { }
-
-static inline int ufshcd_crypto_suspend(struct ufs_hba *hba,
- enum ufs_pm_op pm_op)
-{
- return 0;
-}
-
-static inline int ufshcd_crypto_resume(struct ufs_hba *hba,
- enum ufs_pm_op pm_op)
-{
- return 0;
-}
-
-static inline void ufshcd_crypto_set_vops(struct ufs_hba *hba,
- struct ufs_hba_crypto_variant_ops *crypto_vops) { }
-
#endif /* CONFIG_SCSI_UFS_CRYPTO */
#endif /* _UFSHCD_CRYPTO_H */
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 38db78b..96be7f6 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -449,8 +449,6 @@ static void ufshcd_print_host_regs(struct ufs_hba *hba)
ufshcd_print_clk_freqs(hba);
ufshcd_vops_dbg_register_dump(hba);
-
- ufshcd_crypto_debug(hba);
}
static
@@ -2188,7 +2186,7 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
lrbp->utr_descriptor_ptr->prd_table_length = 0;
}
- return ufshcd_map_sg_crypto(hba, lrbp);
+ return 0;
}
/**
@@ -4896,7 +4894,6 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
result = ufshcd_transfer_rsp_status(hba, lrbp);
scsi_dma_unmap(cmd);
cmd->result = result;
- ufshcd_complete_lrbp_crypto(hba, cmd, lrbp);
/* Mark completed command as NULL in LRB */
lrbp->cmd = NULL;
lrbp->compl_time_stamp = ktime_get();
@@ -8238,10 +8235,6 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
req_link_state = UIC_LINK_OFF_STATE;
}
- ret = ufshcd_crypto_suspend(hba, pm_op);
- if (ret)
- goto out;
-
/*
* If we can't transition into any of the low power modes
* just gate the clocks.
@@ -8363,7 +8356,6 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
hba->clk_gating.is_suspended = false;
hba->dev_info.b_rpm_dev_flush_capable = false;
ufshcd_release(hba);
- ufshcd_crypto_resume(hba, pm_op);
out:
if (hba->dev_info.b_rpm_dev_flush_capable) {
schedule_delayed_work(&hba->rpm_dev_flush_recheck_work,
@@ -8391,11 +8383,9 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
{
int ret;
enum uic_link_state old_link_state;
- enum ufs_dev_pwr_mode old_pwr_mode;
hba->pm_op_in_progress = 1;
old_link_state = hba->uic_link_state;
- old_pwr_mode = hba->curr_dev_pwr_mode;
ufshcd_hba_vreg_set_hpm(hba);
/* Make sure clocks are enabled before accessing controller */
@@ -8445,10 +8435,6 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
goto set_old_link_state;
}
- ret = ufshcd_crypto_resume(hba, pm_op);
- if (ret)
- goto set_old_dev_pwr_mode;
-
if (ufshcd_keep_autobkops_enabled_except_suspend(hba))
ufshcd_enable_auto_bkops(hba);
else
@@ -8476,9 +8462,6 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
goto out;
-set_old_dev_pwr_mode:
- if (old_pwr_mode != hba->curr_dev_pwr_mode)
- ufshcd_set_dev_pwr_mode(hba, old_pwr_mode);
set_old_link_state:
ufshcd_link_state_transition(hba, old_link_state, 0);
vendor_suspend:
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 31a0564..b448c9a 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -360,27 +360,6 @@ struct ufs_hba_variant_ops {
const union ufs_crypto_cfg_entry *cfg, int slot);
};
-struct blk_ksm_ll_ops;
-struct ufs_hba_crypto_variant_ops {
- void (*setup_rq_keyslot_manager)(struct ufs_hba *hba,
- struct request_queue *q);
- void (*destroy_keyslot_manager)(struct ufs_hba *hba);
- int (*hba_init_crypto)(struct ufs_hba *hba,
- const struct blk_ksm_ll_ops *ksm_ops);
- bool (*enable)(struct ufs_hba *hba);
- int (*suspend)(struct ufs_hba *hba, enum ufs_pm_op pm_op);
- int (*resume)(struct ufs_hba *hba, enum ufs_pm_op pm_op);
- int (*debug)(struct ufs_hba *hba);
- void (*prepare_lrbp_crypto)(struct ufs_hba *hba,
- struct scsi_cmnd *cmd,
- struct ufshcd_lrb *lrbp);
- int (*map_sg_crypto)(struct ufs_hba *hba, struct ufshcd_lrb *lrbp);
- int (*complete_lrbp_crypto)(struct ufs_hba *hba,
- struct scsi_cmnd *cmd,
- struct ufshcd_lrb *lrbp);
- void *priv;
-};
-
/* clock gating state */
enum clk_gating_state {
CLKS_OFF,
@@ -722,7 +701,6 @@ struct ufs_hba {
const struct ufs_hba_variant_ops *vops;
struct ufs_hba_variant_params *vps;
void *priv;
- const struct ufs_hba_crypto_variant_ops *crypto_vops;
size_t sg_entry_size;
unsigned int irq;
bool is_irq_enabled;