crypto: ice: split the config callback
The requests configuration has to be split so clients can inform ICE laeyr when the request is completed. Rename the 'config' callback to 'config_start' and add 'config_end' callback. Change-Id: Ife0b5b62805b827449a1bb1002348db445f03c60 Signed-off-by: Gilad Broner <gbroner@codeaurora.org> Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
This commit is contained in:
parent
e29851c910
commit
fe9cbb77bf
7 changed files with 77 additions and 31 deletions
|
@ -1363,8 +1363,9 @@ static int qcom_ice_reset(struct platform_device *pdev)
|
|||
return qcom_ice_finish_power_collapse(ice_dev);
|
||||
}
|
||||
|
||||
static int qcom_ice_config(struct platform_device *pdev, struct request *req,
|
||||
struct ice_data_setting *setting)
|
||||
static int qcom_ice_config_start(struct platform_device *pdev,
|
||||
struct request *req,
|
||||
struct ice_data_setting *setting, bool async)
|
||||
{
|
||||
struct ice_crypto_setting *crypto_data;
|
||||
struct ice_crypto_setting pfk_crypto_data = {0};
|
||||
|
@ -1392,7 +1393,7 @@ static int qcom_ice_config(struct platform_device *pdev, struct request *req,
|
|||
return 0;
|
||||
}
|
||||
|
||||
ret = pfk_load_key_start(req->bio, &pfk_crypto_data, &is_pfe, false);
|
||||
ret = pfk_load_key_start(req->bio, &pfk_crypto_data, &is_pfe, async);
|
||||
if (is_pfe) {
|
||||
if (ret) {
|
||||
if (ret != -EBUSY && ret != -EAGAIN)
|
||||
|
@ -1436,6 +1437,7 @@ static int qcom_ice_config(struct platform_device *pdev, struct request *req,
|
|||
*/
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(qcom_ice_config_start);
|
||||
|
||||
static int qcom_ice_config_end(struct request *req)
|
||||
{
|
||||
|
@ -1497,7 +1499,7 @@ struct qcom_ice_variant_ops qcom_ice_ops = {
|
|||
.reset = qcom_ice_reset,
|
||||
.resume = qcom_ice_resume,
|
||||
.suspend = qcom_ice_suspend,
|
||||
.config = qcom_ice_config,
|
||||
.config_start = qcom_ice_config_start,
|
||||
.config_end = qcom_ice_config_end,
|
||||
.status = qcom_ice_status,
|
||||
.debug = qcom_ice_debug,
|
||||
|
|
|
@ -226,10 +226,10 @@ int ufs_qcom_ice_req_setup(struct ufs_qcom_host *qcom_host,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (qcom_host->ice.vops->config) {
|
||||
if (qcom_host->ice.vops->config_start) {
|
||||
memset(&ice_set, 0, sizeof(ice_set));
|
||||
err = qcom_host->ice.vops->config(qcom_host->ice.pdev,
|
||||
cmd->request, &ice_set);
|
||||
err = qcom_host->ice.vops->config_start(qcom_host->ice.pdev,
|
||||
cmd->request, &ice_set, true);
|
||||
if (err) {
|
||||
dev_err(qcom_host->hba->dev,
|
||||
"%s: error in ice_vops->config %d\n",
|
||||
|
@ -249,7 +249,8 @@ int ufs_qcom_ice_req_setup(struct ufs_qcom_host *qcom_host,
|
|||
}
|
||||
|
||||
/**
|
||||
* ufs_qcom_ice_cfg() - configures UFS's ICE registers for an ICE transaction
|
||||
* ufs_qcom_ice_cfg_start() - starts configuring UFS's ICE registers
|
||||
* for an ICE transaction
|
||||
* @qcom_host: Pointer to a UFS QCom internal host structure.
|
||||
* qcom_host, qcom_host->hba and qcom_host->hba->dev should all
|
||||
* be valid pointers.
|
||||
|
@ -259,7 +260,8 @@ int ufs_qcom_ice_req_setup(struct ufs_qcom_host *qcom_host,
|
|||
* Return: -EINVAL in-case of an error
|
||||
* 0 otherwise
|
||||
*/
|
||||
int ufs_qcom_ice_cfg(struct ufs_qcom_host *qcom_host, struct scsi_cmnd *cmd)
|
||||
int ufs_qcom_ice_cfg_start(struct ufs_qcom_host *qcom_host,
|
||||
struct scsi_cmnd *cmd)
|
||||
{
|
||||
struct device *dev = qcom_host->hba->dev;
|
||||
int err = 0;
|
||||
|
@ -294,10 +296,9 @@ int ufs_qcom_ice_cfg(struct ufs_qcom_host *qcom_host, struct scsi_cmnd *cmd)
|
|||
}
|
||||
|
||||
memset(&ice_set, 0, sizeof(ice_set));
|
||||
if (qcom_host->ice.vops->config) {
|
||||
err = qcom_host->ice.vops->config(qcom_host->ice.pdev,
|
||||
req, &ice_set);
|
||||
|
||||
if (qcom_host->ice.vops->config_start) {
|
||||
err = qcom_host->ice.vops->config_start(qcom_host->ice.pdev,
|
||||
req, &ice_set, true);
|
||||
if (err) {
|
||||
dev_err(dev, "%s: error in ice_vops->config %d\n",
|
||||
__func__, err);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -74,7 +74,10 @@ int ufs_qcom_ice_get_dev(struct ufs_qcom_host *qcom_host);
|
|||
int ufs_qcom_ice_init(struct ufs_qcom_host *qcom_host);
|
||||
int ufs_qcom_ice_req_setup(struct ufs_qcom_host *qcom_host,
|
||||
struct scsi_cmnd *cmd, u8 *cc_index, bool *enable);
|
||||
int ufs_qcom_ice_cfg(struct ufs_qcom_host *qcom_host, struct scsi_cmnd *cmd);
|
||||
int ufs_qcom_ice_cfg_start(struct ufs_qcom_host *qcom_host,
|
||||
struct scsi_cmnd *cmd);
|
||||
int ufs_qcom_ice_cfg_end(struct ufs_qcom_host *qcom_host,
|
||||
struct request *req);
|
||||
int ufs_qcom_ice_reset(struct ufs_qcom_host *qcom_host);
|
||||
int ufs_qcom_ice_resume(struct ufs_qcom_host *qcom_host);
|
||||
int ufs_qcom_ice_suspend(struct ufs_qcom_host *qcom_host);
|
||||
|
@ -93,8 +96,13 @@ inline int ufs_qcom_ice_init(struct ufs_qcom_host *qcom_host)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
inline int ufs_qcom_ice_cfg(struct ufs_qcom_host *qcom_host,
|
||||
struct scsi_cmnd *cmd)
|
||||
inline int ufs_qcom_ice_cfg_start(struct ufs_qcom_host *qcom_host,
|
||||
struct scsi_cmnd *cmd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
inline int ufs_qcom_ice_cfg_end(struct ufs_qcom_host *qcom_host,
|
||||
struct request *req)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -708,7 +708,7 @@ static int ufs_qcom_crypto_req_setup(struct ufs_hba *hba,
|
|||
}
|
||||
|
||||
static
|
||||
int ufs_qcom_crytpo_engine_cfg(struct ufs_hba *hba, unsigned int task_tag)
|
||||
int ufs_qcom_crytpo_engine_cfg_start(struct ufs_hba *hba, unsigned int task_tag)
|
||||
{
|
||||
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
|
||||
struct ufshcd_lrb *lrbp = &hba->lrb[task_tag];
|
||||
|
@ -718,7 +718,22 @@ int ufs_qcom_crytpo_engine_cfg(struct ufs_hba *hba, unsigned int task_tag)
|
|||
!lrbp->cmd || lrbp->command_type != UTP_CMD_TYPE_SCSI)
|
||||
goto out;
|
||||
|
||||
err = ufs_qcom_ice_cfg(host, lrbp->cmd);
|
||||
err = ufs_qcom_ice_cfg_start(host, lrbp->cmd);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static
|
||||
int ufs_qcom_crytpo_engine_cfg_end(struct ufs_hba *hba,
|
||||
struct ufshcd_lrb *lrbp, struct request *req)
|
||||
{
|
||||
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
|
||||
int err = 0;
|
||||
|
||||
if (!host->ice.pdev || lrbp->command_type != UTP_CMD_TYPE_SCSI)
|
||||
goto out;
|
||||
|
||||
err = ufs_qcom_ice_cfg_end(host, req);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
@ -748,7 +763,8 @@ static int ufs_qcom_crypto_engine_get_status(struct ufs_hba *hba, u32 *status)
|
|||
}
|
||||
#else /* !CONFIG_SCSI_UFS_QCOM_ICE */
|
||||
#define ufs_qcom_crypto_req_setup NULL
|
||||
#define ufs_qcom_crytpo_engine_cfg NULL
|
||||
#define ufs_qcom_crytpo_engine_cfg_start NULL
|
||||
#define ufs_qcom_crytpo_engine_cfg_end NULL
|
||||
#define ufs_qcom_crytpo_engine_reset NULL
|
||||
#define ufs_qcom_crypto_engine_get_status NULL
|
||||
#endif /* CONFIG_SCSI_UFS_QCOM_ICE */
|
||||
|
@ -2345,7 +2361,8 @@ static struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
|
|||
|
||||
static struct ufs_hba_crypto_variant_ops ufs_hba_crypto_variant_ops = {
|
||||
.crypto_req_setup = ufs_qcom_crypto_req_setup,
|
||||
.crypto_engine_cfg = ufs_qcom_crytpo_engine_cfg,
|
||||
.crypto_engine_cfg_start = ufs_qcom_crytpo_engine_cfg_start,
|
||||
.crypto_engine_cfg_end = ufs_qcom_crytpo_engine_cfg_end,
|
||||
.crypto_engine_reset = ufs_qcom_crytpo_engine_reset,
|
||||
.crypto_engine_get_status = ufs_qcom_crypto_engine_get_status,
|
||||
};
|
||||
|
|
|
@ -1954,7 +1954,7 @@ int ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = ufshcd_vops_crypto_engine_cfg(hba, task_tag);
|
||||
ret = ufshcd_vops_crypto_engine_cfg_start(hba, task_tag);
|
||||
if (ret) {
|
||||
dev_err(hba->dev,
|
||||
"%s: failed to configure crypto engine %d\n",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* This code is based on drivers/scsi/ufs/ufshcd.h
|
||||
* Copyright (C) 2011-2013 Samsung India Software Operations
|
||||
* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Authors:
|
||||
* Santosh Yaraganavi <santosh.sy@samsung.com>
|
||||
|
@ -341,14 +341,20 @@ struct ufs_hba_variant_ops {
|
|||
* struct ufs_hba_crypto_variant_ops - variant specific crypto callbacks
|
||||
* @crypto_req_setup: retreieve the necessary cryptographic arguments to setup
|
||||
a requests's transfer descriptor.
|
||||
* @crypto_engine_cfg: configure cryptographic engine according to tag parameter
|
||||
* @crypto_engine_cfg_start: start configuring cryptographic engine
|
||||
* according to tag
|
||||
* parameter
|
||||
* @crypto_engine_cfg_end: end configuring cryptographic engine
|
||||
* according to tag parameter
|
||||
* @crypto_engine_reset: perform reset to the cryptographic engine
|
||||
* @crypto_engine_get_status: get errors status of the cryptographic engine
|
||||
*/
|
||||
struct ufs_hba_crypto_variant_ops {
|
||||
int (*crypto_req_setup)(struct ufs_hba *, struct ufshcd_lrb *lrbp,
|
||||
u8 *cc_index, bool *enable, u64 *dun);
|
||||
int (*crypto_engine_cfg)(struct ufs_hba *, unsigned int);
|
||||
int (*crypto_engine_cfg_start)(struct ufs_hba *, unsigned int);
|
||||
int (*crypto_engine_cfg_end)(struct ufs_hba *, struct ufshcd_lrb *,
|
||||
struct request *);
|
||||
int (*crypto_engine_reset)(struct ufs_hba *);
|
||||
int (*crypto_engine_get_status)(struct ufs_hba *, u32 *);
|
||||
};
|
||||
|
@ -1233,12 +1239,24 @@ static inline int ufshcd_vops_crypto_req_setup(struct ufs_hba *hba,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int ufshcd_vops_crypto_engine_cfg(struct ufs_hba *hba,
|
||||
unsigned int task_tag)
|
||||
static inline int ufshcd_vops_crypto_engine_cfg_start(struct ufs_hba *hba,
|
||||
unsigned int task_tag)
|
||||
{
|
||||
if (hba->var && hba->var->crypto_vops &&
|
||||
hba->var->crypto_vops->crypto_engine_cfg)
|
||||
return hba->var->crypto_vops->crypto_engine_cfg(hba, task_tag);
|
||||
hba->var->crypto_vops->crypto_engine_cfg_start)
|
||||
return hba->var->crypto_vops->crypto_engine_cfg_start
|
||||
(hba, task_tag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int ufshcd_vops_crypto_engine_cfg_end(struct ufs_hba *hba,
|
||||
struct ufshcd_lrb *lrbp,
|
||||
struct request *req)
|
||||
{
|
||||
if (hba->var && hba->var->crypto_vops &&
|
||||
hba->var->crypto_vops->crypto_engine_cfg_end)
|
||||
return hba->var->crypto_vops->crypto_engine_cfg_end
|
||||
(hba, lrbp, req);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ struct qcom_ice_variant_ops {
|
|||
int (*reset)(struct platform_device *);
|
||||
int (*resume)(struct platform_device *);
|
||||
int (*suspend)(struct platform_device *);
|
||||
int (*config)(struct platform_device *, struct request *,
|
||||
struct ice_data_setting *);
|
||||
int (*config_start)(struct platform_device *, struct request *,
|
||||
struct ice_data_setting *, bool);
|
||||
int (*config_end)(struct request *);
|
||||
int (*status)(struct platform_device *);
|
||||
void (*debug)(struct platform_device *);
|
||||
|
|
Loading…
Add table
Reference in a new issue