* [PATCH v2] crypto: hisilicon - Kunpeng916 crypto driver don't sleep when in softirq
@ 2022-06-30 12:42 Zhengchao Shao
2022-07-08 8:00 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Zhengchao Shao @ 2022-06-30 12:42 UTC (permalink / raw)
To: linux-crypto, linux-kernel, herbert, davem
Cc: weiyongjun1, yuehaibing, shaozhengchao
When kunpeng916 encryption driver is used to deencrypt and decrypt
packets during the softirq, it is not allowed to use mutex lock.
v1: use spin_lock will cause soft lockup
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
drivers/crypto/hisilicon/sec/sec_algs.c | 14 +++++++-------
drivers/crypto/hisilicon/sec/sec_drv.h | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/crypto/hisilicon/sec/sec_algs.c b/drivers/crypto/hisilicon/sec/sec_algs.c
index 0a3c8f019b02..490e1542305e 100644
--- a/drivers/crypto/hisilicon/sec/sec_algs.c
+++ b/drivers/crypto/hisilicon/sec/sec_algs.c
@@ -449,7 +449,7 @@ static void sec_skcipher_alg_callback(struct sec_bd_info *sec_resp,
*/
}
- mutex_lock(&ctx->queue->queuelock);
+ spin_lock_bh(&ctx->queue->queuelock);
/* Put the IV in place for chained cases */
switch (ctx->cipher_alg) {
case SEC_C_AES_CBC_128:
@@ -509,7 +509,7 @@ static void sec_skcipher_alg_callback(struct sec_bd_info *sec_resp,
list_del(&backlog_req->backlog_head);
}
}
- mutex_unlock(&ctx->queue->queuelock);
+ spin_unlock_bh(&ctx->queue->queuelock);
mutex_lock(&sec_req->lock);
list_del(&sec_req_el->head);
@@ -798,7 +798,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
*/
/* Grab a big lock for a long time to avoid concurrency issues */
- mutex_lock(&queue->queuelock);
+ spin_lock_bh(&queue->queuelock);
/*
* Can go on to queue if we have space in either:
@@ -814,15 +814,15 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
ret = -EBUSY;
if ((skreq->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) {
list_add_tail(&sec_req->backlog_head, &ctx->backlog);
- mutex_unlock(&queue->queuelock);
+ spin_unlock_bh(&queue->queuelock);
goto out;
}
- mutex_unlock(&queue->queuelock);
+ spin_unlock_bh(&queue->queuelock);
goto err_free_elements;
}
ret = sec_send_request(sec_req, queue);
- mutex_unlock(&queue->queuelock);
+ spin_unlock_bh(&queue->queuelock);
if (ret)
goto err_free_elements;
@@ -881,7 +881,7 @@ static int sec_alg_skcipher_init(struct crypto_skcipher *tfm)
if (IS_ERR(ctx->queue))
return PTR_ERR(ctx->queue);
- mutex_init(&ctx->queue->queuelock);
+ spin_lock_init(&ctx->queue->queuelock);
ctx->queue->havesoftqueue = false;
return 0;
diff --git a/drivers/crypto/hisilicon/sec/sec_drv.h b/drivers/crypto/hisilicon/sec/sec_drv.h
index 179a8250d691..e2a50bf2234b 100644
--- a/drivers/crypto/hisilicon/sec/sec_drv.h
+++ b/drivers/crypto/hisilicon/sec/sec_drv.h
@@ -347,7 +347,7 @@ struct sec_queue {
DECLARE_BITMAP(unprocessed, SEC_QUEUE_LEN);
DECLARE_KFIFO_PTR(softqueue, typeof(struct sec_request_el *));
bool havesoftqueue;
- struct mutex queuelock;
+ spinlock_t queuelock;
void *shadow[SEC_QUEUE_LEN];
};
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] crypto: hisilicon - Kunpeng916 crypto driver don't sleep when in softirq
2022-06-30 12:42 [PATCH v2] crypto: hisilicon - Kunpeng916 crypto driver don't sleep when in softirq Zhengchao Shao
@ 2022-07-08 8:00 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2022-07-08 8:00 UTC (permalink / raw)
To: Zhengchao Shao; +Cc: linux-crypto, linux-kernel, davem, weiyongjun1, yuehaibing
On Thu, Jun 30, 2022 at 08:42:30PM +0800, Zhengchao Shao wrote:
> When kunpeng916 encryption driver is used to deencrypt and decrypt
> packets during the softirq, it is not allowed to use mutex lock.
>
> v1: use spin_lock will cause soft lockup
>
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
> drivers/crypto/hisilicon/sec/sec_algs.c | 14 +++++++-------
> drivers/crypto/hisilicon/sec/sec_drv.h | 2 +-
> 2 files changed, 8 insertions(+), 8 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-08 8:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 12:42 [PATCH v2] crypto: hisilicon - Kunpeng916 crypto driver don't sleep when in softirq Zhengchao Shao
2022-07-08 8:00 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.