提交 a68b31bd 编写于 作者: Y Yang Shen 提交者: Zheng Zengkai

crypto: hisilicon/qm - fix deadlock for remove driver

mainline inclusion
from mainline-v5.16-rc1
commit fc6c01f0
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4W3EG
CVE: NA

--------------------------------

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: NYang Shen <shenyang39@huawei.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: NYang Shen <shenyang39@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 0a41ddf2
...@@ -3406,6 +3406,7 @@ void hisi_qm_uninit(struct hisi_qm *qm) ...@@ -3406,6 +3406,7 @@ void hisi_qm_uninit(struct hisi_qm *qm)
dma_free_coherent(dev, qm->qdma.size, dma_free_coherent(dev, qm->qdma.size,
qm->qdma.va, qm->qdma.dma); qm->qdma.va, qm->qdma.dma);
} }
up_write(&qm->qps_lock);
hisi_qm_set_state(qm, VF_NOT_READY); hisi_qm_set_state(qm, VF_NOT_READY);
...@@ -3415,8 +3416,6 @@ void hisi_qm_uninit(struct hisi_qm *qm) ...@@ -3415,8 +3416,6 @@ void hisi_qm_uninit(struct hisi_qm *qm)
uacce_remove(qm->uacce); uacce_remove(qm->uacce);
qm->uacce = NULL; qm->uacce = NULL;
} }
up_write(&qm->qps_lock);
} }
EXPORT_SYMBOL_GPL(hisi_qm_uninit); EXPORT_SYMBOL_GPL(hisi_qm_uninit);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册