aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/inside-secure/safexcel_cipher.c
diff options
context:
space:
mode:
authorAntoine Ténart <antoine.tenart@free-electrons.com>2017-06-15 09:56:24 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2017-06-20 11:21:45 +0800
commit86671abbbbfc959c4e4cbd2c618d5868a6f8dcf2 (patch)
tree3531857f16fedde5f69a04c26e888ace08b218cf /drivers/crypto/inside-secure/safexcel_cipher.c
parentcrypto: inside-secure - update the context and request later (diff)
downloadlinux-dev-86671abbbbfc959c4e4cbd2c618d5868a6f8dcf2.tar.xz
linux-dev-86671abbbbfc959c4e4cbd2c618d5868a6f8dcf2.zip
crypto: inside-secure - use one queue per hw ring
Update the inside-secure safexcel driver from using one global queue to one queue per hw ring. This ease the request management and keep the hw in sync with what's done in sw. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/inside-secure/safexcel_cipher.c')
-rw-r--r--drivers/crypto/inside-secure/safexcel_cipher.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c
index 6037cdfc1f16..d2207ac5ba19 100644
--- a/drivers/crypto/inside-secure/safexcel_cipher.c
+++ b/drivers/crypto/inside-secure/safexcel_cipher.c
@@ -339,18 +339,21 @@ static int safexcel_handle_inv_result(struct safexcel_crypto_priv *priv,
return ndesc;
}
+ ring = safexcel_select_ring(priv);
+ ctx->base.ring = ring;
ctx->base.needs_inv = false;
- ctx->base.ring = safexcel_select_ring(priv);
ctx->base.send = safexcel_aes_send;
- spin_lock_bh(&priv->lock);
- enq_ret = crypto_enqueue_request(&priv->queue, async);
- spin_unlock_bh(&priv->lock);
+ spin_lock_bh(&priv->ring[ring].queue_lock);
+ enq_ret = crypto_enqueue_request(&priv->ring[ring].queue, async);
+ spin_unlock_bh(&priv->ring[ring].queue_lock);
if (enq_ret != -EINPROGRESS)
*ret = enq_ret;
- priv->need_dequeue = true;
+ if (!priv->ring[ring].need_dequeue)
+ safexcel_dequeue(priv, ring);
+
*should_complete = false;
return ndesc;
@@ -384,6 +387,7 @@ static int safexcel_cipher_exit_inv(struct crypto_tfm *tfm)
struct safexcel_crypto_priv *priv = ctx->priv;
struct skcipher_request req;
struct safexcel_inv_result result = { 0 };
+ int ring = ctx->base.ring;
memset(&req, 0, sizeof(struct skcipher_request));
@@ -397,12 +401,12 @@ static int safexcel_cipher_exit_inv(struct crypto_tfm *tfm)
ctx->base.exit_inv = true;
ctx->base.send = safexcel_cipher_send_inv;
- spin_lock_bh(&priv->lock);
- crypto_enqueue_request(&priv->queue, &req.base);
- spin_unlock_bh(&priv->lock);
+ spin_lock_bh(&priv->ring[ring].queue_lock);
+ crypto_enqueue_request(&priv->ring[ring].queue, &req.base);
+ spin_unlock_bh(&priv->ring[ring].queue_lock);
- if (!priv->need_dequeue)
- safexcel_dequeue(priv);
+ if (!priv->ring[ring].need_dequeue)
+ safexcel_dequeue(priv, ring);
wait_for_completion_interruptible(&result.completion);
@@ -421,7 +425,7 @@ static int safexcel_aes(struct skcipher_request *req,
{
struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
struct safexcel_crypto_priv *priv = ctx->priv;
- int ret;
+ int ret, ring;
ctx->direction = dir;
ctx->mode = mode;
@@ -440,12 +444,14 @@ static int safexcel_aes(struct skcipher_request *req,
return -ENOMEM;
}
- spin_lock_bh(&priv->lock);
- ret = crypto_enqueue_request(&priv->queue, &req->base);
- spin_unlock_bh(&priv->lock);
+ ring = ctx->base.ring;
+
+ spin_lock_bh(&priv->ring[ring].queue_lock);
+ ret = crypto_enqueue_request(&priv->ring[ring].queue, &req->base);
+ spin_unlock_bh(&priv->ring[ring].queue_lock);
- if (!priv->need_dequeue)
- safexcel_dequeue(priv);
+ if (!priv->ring[ring].need_dequeue)
+ safexcel_dequeue(priv, ring);
return ret;
}