[PATCH rdma-core 3/7] libhns: Bugfix for assigning sl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Lijun Ou <oulijun@xxxxxxxxxx>

Only the field that corresponding mask is set can be modified, or its
original value may be covered.

Fixes: c24583975044 ("libhns: Add verbs of qp support")
Signed-off-by: Lijun Ou <oulijun@xxxxxxxxxx>
Signed-off-by: Weihang Li <liweihang@xxxxxxxxxxxxx>
---
 providers/hns/hns_roce_u_hw_v2.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
index 931f59d..b473f07 100644
--- a/providers/hns/hns_roce_u_hw_v2.c
+++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -1103,8 +1103,10 @@ static int hns_roce_u_v2_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
 		pthread_spin_unlock(&hr_qp->sq.lock);
 	}
 
-	if (!ret && (attr_mask & IBV_QP_STATE) &&
-	    attr->qp_state == IBV_QPS_RESET) {
+	if (ret)
+		return ret;
+
+	if ((attr_mask & IBV_QP_STATE) && attr->qp_state == IBV_QPS_RESET) {
 		hns_roce_v2_cq_clean(to_hr_cq(qp->recv_cq), qp->qp_num,
 				     qp->srq ? to_hr_srq(qp->srq) : NULL);
 		if (qp->send_cq != qp->recv_cq)
@@ -1114,10 +1116,11 @@ static int hns_roce_u_v2_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
 		hns_roce_init_qp_indices(to_hr_qp(qp));
 	}
 
-	if (!ret && (attr_mask & IBV_QP_PORT))
+	if (attr_mask & IBV_QP_PORT)
 		hr_qp->port_num = attr->port_num;
 
-	hr_qp->sl = attr->ah_attr.sl;
+	if (attr_mask & IBV_QP_AV)
+		hr_qp->sl = attr->ah_attr.sl;
 
 	return ret;
 }
-- 
2.8.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux