From: Sven Auhagen <Sven.Auhagen@xxxxxxxxxxxx> --- drivers/crypto/inside-secure/safexcel.h | 1 + drivers/crypto/inside-secure/safexcel_cipher.c | 6 +++++- drivers/crypto/inside-secure/safexcel_hash.c | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/inside-secure/safexcel.h b/drivers/crypto/inside-secure/safexcel.h index a7ab1183a723..7341f047cb2f 100644 --- a/drivers/crypto/inside-secure/safexcel.h +++ b/drivers/crypto/inside-secure/safexcel.h @@ -40,6 +40,7 @@ /* Static configuration */ #define EIP197_DEFAULT_RING_SIZE 400 +#define EIP197_DEFAULT_RING_ROTATE 50 #define EIP197_EMB_TOKENS 4 /* Pad CD to 16 dwords */ #define EIP197_MAX_TOKENS 16 #define EIP197_MAX_RINGS 4 diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c index 2018b7f3942d..2c4bda960ee6 100644 --- a/drivers/crypto/inside-secure/safexcel_cipher.c +++ b/drivers/crypto/inside-secure/safexcel_cipher.c @@ -1218,7 +1218,11 @@ static int safexcel_queue_req(struct crypto_async_request *base, ring = ctx->base.ring; - printk("Ring %d queue length %d\n", ring, priv->ring[ring].queue->qlen); + // Rotate ring if full + if (priv->ring[ring].queue.qlen > EIP197_DEFAULT_RING_ROTATE) { + ctx->base.ring = safexcel_select_ring(priv); + ring = ctx->base.ring; + } spin_lock_bh(&priv->ring[ring].queue_lock); ret = crypto_enqueue_request(&priv->ring[ring].queue, base); diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c index e1d65788bf41..55a573bbb3ae 100644 --- a/drivers/crypto/inside-secure/safexcel_hash.c +++ b/drivers/crypto/inside-secure/safexcel_hash.c @@ -744,6 +744,12 @@ static int safexcel_ahash_enqueue(struct ahash_request *areq) ring = ctx->base.ring; + // Rotate ring if full + if (priv->ring[ring].queue.qlen > EIP197_DEFAULT_RING_ROTATE) { + ctx->base.ring = safexcel_select_ring(priv); + ring = ctx->base.ring; + } + spin_lock_bh(&priv->ring[ring].queue_lock); ret = crypto_enqueue_request(&priv->ring[ring].queue, &areq->base); spin_unlock_bh(&priv->ring[ring].queue_lock); -- 2.24.3 (Apple Git-128)