summaryrefslogtreecommitdiff
path: root/drivers/crypto
diff options
context:
space:
mode:
authorMallikarjun Kasoju <mkasoju@nvidia.com>2012-09-14 18:26:23 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 00:48:25 -0700
commit2a6d247c824b1ac9bd83db8931be49466ccd064a (patch)
tree8bcaa23abe362662847706915968f6117124f296 /drivers/crypto
parent601814bc60d18d2318f14193e6f1b3c32d7ea9ee (diff)
crypto: tegra-se: issue NOP after context save
Issue NOP command after lp0 context save so that RSA can be performed if any. Bug 946811 Signed-off-by: Mallikarjun Kasoju <mkasoju@nvidia.com> Reviewed-on: http://git-master/r/132652 (cherry picked from commit d28ee9a7c6e2ad426f373a86b12b845422dd28c1) Signed-off-by: Mallikarjun Kasoju <mkasoju@nvidia.com> Change-Id: I77f2c5f71dac44ed89e638dc23dc6abcb844400d Reviewed-on: http://git-master/r/146654 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Bitan Biswas <bbiswas@nvidia.com> Rebase-Id: Ra19f263610c3688c1c9c3ab41d7976d5d2af9224
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/tegra-se.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/drivers/crypto/tegra-se.c b/drivers/crypto/tegra-se.c
index 235cfca26ae9..5200efc041f6 100644
--- a/drivers/crypto/tegra-se.c
+++ b/drivers/crypto/tegra-se.c
@@ -2936,7 +2936,8 @@ static int tegra_se_lp_iv_context_save(struct tegra_se_dev *se_dev,
static int tegra_se_save_SRK(struct tegra_se_dev *se_dev)
{
- int ret = 0;
+ int ret;
+ int val;
mutex_lock(&se_hw_lock);
pm_runtime_get_sync(se_dev->dev);
@@ -2945,10 +2946,45 @@ static int tegra_se_save_SRK(struct tegra_se_dev *se_dev)
SE_CONTEXT_SAVE_CONFIG_REG_OFFSET);
ret = tegra_se_start_operation(se_dev, 0, true);
+ if (ret < 0) {
+ dev_err(se_dev->dev, "\n LP SRK operation failed\n");
+ pm_runtime_put(se_dev->dev);
+ mutex_unlock(&se_hw_lock);
+ return ret;
+ }
+
+ if (se_dev->chipdata->drbg_supported) {
+ /* clear any pending interrupts */
+ val = se_readl(se_dev, SE_INT_STATUS_REG_OFFSET);
+ se_writel(se_dev, val, SE_INT_STATUS_REG_OFFSET);
+
+ /* enable interupts */
+ val = SE_INT_ERROR(INT_ENABLE) | SE_INT_OP_DONE(INT_ENABLE);
+ se_writel(se_dev, val, SE_INT_ENABLE_REG_OFFSET);
+
+ val = SE_CONFIG_ENC_ALG(ALG_NOP) |
+ SE_CONFIG_DEC_ALG(ALG_NOP);
+ se_writel(se_dev, val, SE_CRYPTO_REG_OFFSET);
+
+ INIT_COMPLETION(se_dev->complete);
+
+ se_writel(se_dev, SE_OPERATION(OP_CTX_SAVE),
+ SE_OPERATION_REG_OFFSET);
+ ret = wait_for_completion_timeout(&se_dev->complete,
+ msecs_to_jiffies(1000));
+
+ if (ret == 0) {
+ dev_err(se_dev->dev, "\n LP SRK timed out no interrupt\n");
+ pm_runtime_put(se_dev->dev);
+ mutex_unlock(&se_hw_lock);
+ return -ETIMEDOUT;
+ }
+ }
+
pm_runtime_put(se_dev->dev);
mutex_unlock(&se_hw_lock);
- return ret;
+ return 0;
}
static int tegra_se_suspend(struct device *dev)
@@ -3055,7 +3091,7 @@ static int tegra_se_suspend(struct device *dev)
/* Saves SRK in secure scratch */
err = tegra_se_save_SRK(se_dev);
- if (err) {
+ if (err < 0) {
dev_err(se_dev->dev, "LP SRK save failure\n");
goto out;
}