From: Xinghai Cen cenxinghai@h-partners.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IBIXIN CVE: NA
----------------------------------------------------------------------
This reverts commit a31744454c28ff2bc6bbfec17fd3fb216649c000. This reverts commit 2b39c452903342e0821b767e2b7fbd0f2d02c25a
Fixes: a31744454c28 ("RDMA/hns: Fix flush cqe error when racing with destroy qp") Fixes: 2b39c4529033 ("RDMA/hns: Fix flush cqe error when racing with destroy qp") Signed-off-by: Xinghai Cen cenxinghai@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_device.h | 2 -- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 12 ------------ drivers/infiniband/hw/hns/hns_roce_qp.c | 15 ++------------- 3 files changed, 2 insertions(+), 27 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h index f12e56969fd3..f20054b36dc6 100644 --- a/drivers/infiniband/hw/hns/hns_roce_device.h +++ b/drivers/infiniband/hw/hns/hns_roce_device.h @@ -717,7 +717,6 @@ struct hns_roce_dev;
enum { HNS_ROCE_FLUSH_FLAG = 0, - HNS_ROCE_STOP_FLUSH_FLAG = 1, };
struct hns_roce_work { @@ -778,7 +777,6 @@ struct hns_roce_qp { bool delayed_destroy_flag; struct hns_roce_mtr_node *mtr_node; struct hns_roce_dip *dip; - spinlock_t flush_lock; };
struct hns_roce_ib_iboe { diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index d3b0dccf7c48..bd27795d33c1 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -6330,23 +6330,11 @@ int hns_roce_v2_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) { struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device); struct hns_roce_qp *hr_qp = to_hr_qp(ibqp); - unsigned long flags; int ret; - /* Make sure flush_cqe() is completed */ - spin_lock_irqsave(&hr_qp->flush_lock, flags); - set_bit(HNS_ROCE_STOP_FLUSH_FLAG, &hr_qp->flush_flag); - spin_unlock_irqrestore(&hr_qp->flush_lock, flags); - flush_work(&hr_qp->flush_work.work);
if (hr_qp->congest_type == HNS_ROCE_CONGEST_TYPE_DIP) put_dip_ctx_idx(hr_dev, hr_qp);
- /* Make sure flush_cqe() is completed */ - spin_lock_irqsave(&hr_qp->flush_lock, flags); - set_bit(HNS_ROCE_STOP_FLUSH_FLAG, &hr_qp->flush_flag); - spin_unlock_irqrestore(&hr_qp->flush_lock, flags); - flush_work(&hr_qp->flush_work.work); - ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, udata); if (ret) ibdev_err_ratelimited(&hr_dev->ib_dev, diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c index a3eb05e8471e..f6fa66340c3e 100644 --- a/drivers/infiniband/hw/hns/hns_roce_qp.c +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c @@ -90,18 +90,11 @@ static void flush_work_handle(struct work_struct *work) void init_flush_work(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp) { struct hns_roce_work *flush_work = &hr_qp->flush_work; - unsigned long flags; - - spin_lock_irqsave(&hr_qp->flush_lock, flags); - /* Exit directly after destroy_qp() */ - if (test_bit(HNS_ROCE_STOP_FLUSH_FLAG, &hr_qp->flush_flag)) { - spin_unlock_irqrestore(&hr_qp->flush_lock, flags); - return; - }
+ flush_work->hr_dev = hr_dev; + INIT_WORK(&flush_work->work, flush_work_handle); refcount_inc(&hr_qp->refcount); queue_work(hr_dev->irq_workq, &flush_work->work); - spin_unlock_irqrestore(&hr_qp->flush_lock, flags); }
void flush_cqe(struct hns_roce_dev *dev, struct hns_roce_qp *qp) @@ -1371,7 +1364,6 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, struct ib_udata *udata, struct hns_roce_qp *hr_qp) { - struct hns_roce_work *flush_work = &hr_qp->flush_work; struct hns_roce_ib_create_qp_resp resp = {}; struct ib_device *ibdev = &hr_dev->ib_dev; struct hns_roce_ib_create_qp ucmd = {}; @@ -1380,12 +1372,9 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, mutex_init(&hr_qp->mutex); spin_lock_init(&hr_qp->sq.lock); spin_lock_init(&hr_qp->rq.lock); - spin_lock_init(&hr_qp->flush_lock);
hr_qp->state = IB_QPS_RESET; hr_qp->flush_flag = 0; - flush_work->hr_dev = hr_dev; - INIT_WORK(&flush_work->work, flush_work_handle);
ret = set_qp_param(hr_dev, hr_qp, init_attr, udata, &ucmd); if (ret) {