* [PATCH] crypto: hisilicon/qm - fix deadlock for remove driver
@ 2021-12-11 8:56 Yang Shen
2021-12-17 8:39 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Yang Shen @ 2021-12-11 8:56 UTC (permalink / raw)
To: herbert, davem; +Cc: linux-kernel, linux-crypto, wangzhou1, liulongfang
When remove the driver and executing the task occur at the same time,
the following deadlock will be triggered:
Chain exists of:
sva_lock --> uacce_mutex --> &qm->qps_lock
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&qm->qps_lock);
lock(uacce_mutex);
lock(&qm->qps_lock);
lock(sva_lock);
And the lock 'qps_lock' is used to protect qp. Therefore, it's reasonable
cycle is to continue until the qp memory is released. So move the release
lock infront of 'uacce_remove'.
Signed-off-by: Yang Shen <shenyang39@huawei.com>
---
drivers/crypto/hisilicon/qm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index 896255aec87f..bea8622d80e6 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -3425,6 +3425,7 @@ void hisi_qm_uninit(struct hisi_qm *qm)
dma_free_coherent(dev, qm->qdma.size,
qm->qdma.va, qm->qdma.dma);
}
+ up_write(&qm->qps_lock);
qm_irq_unregister(qm);
hisi_qm_pci_uninit(qm);
@@ -3432,8 +3433,6 @@ void hisi_qm_uninit(struct hisi_qm *qm)
uacce_remove(qm->uacce);
qm->uacce = NULL;
}
-
- up_write(&qm->qps_lock);
}
EXPORT_SYMBOL_GPL(hisi_qm_uninit);
--
2.33.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: hisilicon/qm - fix deadlock for remove driver
2021-12-11 8:56 [PATCH] crypto: hisilicon/qm - fix deadlock for remove driver Yang Shen
@ 2021-12-17 8:39 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2021-12-17 8:39 UTC (permalink / raw)
To: Yang Shen; +Cc: davem, linux-kernel, linux-crypto, wangzhou1, liulongfang
On Sat, Dec 11, 2021 at 04:56:55PM +0800, Yang Shen wrote:
> When remove the driver and executing the task occur at the same time,
> the following deadlock will be triggered:
>
> Chain exists of:
> sva_lock --> uacce_mutex --> &qm->qps_lock
> Possible unsafe locking scenario:
> CPU0 CPU1
> ---- ----
> lock(&qm->qps_lock);
> lock(uacce_mutex);
> lock(&qm->qps_lock);
> lock(sva_lock);
>
> And the lock 'qps_lock' is used to protect qp. Therefore, it's reasonable
> cycle is to continue until the qp memory is released. So move the release
> lock infront of 'uacce_remove'.
>
> Signed-off-by: Yang Shen <shenyang39@huawei.com>
> ---
> drivers/crypto/hisilicon/qm.c | 3 +--
> 1 file changed, 1 insertion(+), 2 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:[~2021-12-17 8:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-11 8:56 [PATCH] crypto: hisilicon/qm - fix deadlock for remove driver Yang Shen
2021-12-17 8:39 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®