From 01635695dee3442a9d7d8f32cbb0c435057c9821 Mon Sep 17 00:00:00 2001 From: Yangyang Li Date: Fri, 5 Jul 2019 13:40:52 +0800 Subject: [PATCH] RDMA/hns: Ensure that the flush work is completed before qp release driver inclusion category: bugfix bugzilla: NA CVE: NA Ensure that the flush work is completed before qp release. Feature or Bugfix:Bugfix Signed-off-by: Yangyang Li Signed-off-by: liyangyang (M) Signed-off-by: Weihang Li Reviewed-by: liuyixian Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- drivers/infiniband/hw/hns/hns_roce_qp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c index d803be622e68..28f1534bb5cf 100644 --- a/drivers/infiniband/hw/hns/hns_roce_qp.c +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c @@ -60,6 +60,8 @@ static void flush_work_handle(struct work_struct *work) dev_err(dev, "Modify qp to err for flush cqe fail(%d)\n", ret); kfree(flush_work); + if (atomic_dec_and_test(&hr_qp->refcount)) + complete(&hr_qp->free); } void init_flush_work(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp) @@ -73,6 +75,7 @@ void init_flush_work(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp) flush_work->hr_dev = hr_dev; flush_work->hr_qp = hr_qp; INIT_WORK(&flush_work->work, flush_work_handle); + atomic_inc(&hr_qp->refcount); queue_work(hr_dev->flush_workq, &flush_work->work); } EXPORT_SYMBOL_GPL(init_flush_work); -- GitLab