aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitko Haralanov <mitko.haralanov@intel.com>2016-12-07 22:33:27 -0500
committerDoug Ledford <dledford@redhat.com>2016-12-11 15:29:42 -0500
commitb777f154a0c21e1187c1806ababf9c5ba3e49eea (patch)
tree908c8eb00b5a369c9eac775c42ec8a91f3714459
parentfcb29a6668a254104d38c0132d1853d0644af066 (diff)
IB/hfi1: Remove usage of qp->s_cur_sge
The s_cur_sge field in the qp structure holds a pointer to the SGE of the currently processed WQE. It assumes the protection of the RVT_S_BUSY flag to prevent the changing of this field while the send engine is using it. This scheme works as long as there is only one instance of the send engine running at a time. Scaling of the send engine to multiple cores would break this assumption as there could be multiple instances of the send engine running on different CPUs. This opens a window where the QP's RVT_S_BUSY flag is not set but the send engine is still running. To prevent accidental changing of the s_cur_sge pointer, the QP's dependence on it is removed. The SGE pointer is now stored in the verbs_txreq, which is a per-packet data structure. This ensures that each individual packet has it's own pointer, which is setup while the RVT_S_BUSY flag is set. Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/infiniband/hw/hfi1/rc.c10
-rw-r--r--drivers/infiniband/hw/hfi1/uc.c2
-rw-r--r--drivers/infiniband/hw/hfi1/ud.c2
-rw-r--r--drivers/infiniband/hw/hfi1/verbs.c14
4 files changed, 13 insertions, 15 deletions
diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c
index e69161e007db..c996a373837e 100644
--- a/drivers/infiniband/hw/hfi1/rc.c
+++ b/drivers/infiniband/hw/hfi1/rc.c
@@ -276,7 +276,7 @@ static int make_rc_ack(struct hfi1_ibdev *dev, struct rvt_qp *qp,
276 rvt_get_mr(ps->s_txreq->mr); 276 rvt_get_mr(ps->s_txreq->mr);
277 qp->s_ack_rdma_sge.sge = e->rdma_sge; 277 qp->s_ack_rdma_sge.sge = e->rdma_sge;
278 qp->s_ack_rdma_sge.num_sge = 1; 278 qp->s_ack_rdma_sge.num_sge = 1;
279 qp->s_cur_sge = &qp->s_ack_rdma_sge; 279 ps->s_txreq->ss = &qp->s_ack_rdma_sge;
280 if (len > pmtu) { 280 if (len > pmtu) {
281 len = pmtu; 281 len = pmtu;
282 qp->s_ack_state = OP(RDMA_READ_RESPONSE_FIRST); 282 qp->s_ack_state = OP(RDMA_READ_RESPONSE_FIRST);
@@ -290,7 +290,7 @@ static int make_rc_ack(struct hfi1_ibdev *dev, struct rvt_qp *qp,
290 bth2 = mask_psn(qp->s_ack_rdma_psn++); 290 bth2 = mask_psn(qp->s_ack_rdma_psn++);
291 } else { 291 } else {
292 /* COMPARE_SWAP or FETCH_ADD */ 292 /* COMPARE_SWAP or FETCH_ADD */
293 qp->s_cur_sge = NULL; 293 ps->s_txreq->ss = NULL;
294 len = 0; 294 len = 0;
295 qp->s_ack_state = OP(ATOMIC_ACKNOWLEDGE); 295 qp->s_ack_state = OP(ATOMIC_ACKNOWLEDGE);
296 ohdr->u.at.aeth = hfi1_compute_aeth(qp); 296 ohdr->u.at.aeth = hfi1_compute_aeth(qp);
@@ -306,7 +306,7 @@ static int make_rc_ack(struct hfi1_ibdev *dev, struct rvt_qp *qp,
306 qp->s_ack_state = OP(RDMA_READ_RESPONSE_MIDDLE); 306 qp->s_ack_state = OP(RDMA_READ_RESPONSE_MIDDLE);
307 /* FALLTHROUGH */ 307 /* FALLTHROUGH */
308 case OP(RDMA_READ_RESPONSE_MIDDLE): 308 case OP(RDMA_READ_RESPONSE_MIDDLE):
309 qp->s_cur_sge = &qp->s_ack_rdma_sge; 309 ps->s_txreq->ss = &qp->s_ack_rdma_sge;
310 ps->s_txreq->mr = qp->s_ack_rdma_sge.sge.mr; 310 ps->s_txreq->mr = qp->s_ack_rdma_sge.sge.mr;
311 if (ps->s_txreq->mr) 311 if (ps->s_txreq->mr)
312 rvt_get_mr(ps->s_txreq->mr); 312 rvt_get_mr(ps->s_txreq->mr);
@@ -335,7 +335,7 @@ normal:
335 */ 335 */
336 qp->s_ack_state = OP(SEND_ONLY); 336 qp->s_ack_state = OP(SEND_ONLY);
337 qp->s_flags &= ~RVT_S_ACK_PENDING; 337 qp->s_flags &= ~RVT_S_ACK_PENDING;
338 qp->s_cur_sge = NULL; 338 ps->s_txreq->ss = NULL;
339 if (qp->s_nak_state) 339 if (qp->s_nak_state)
340 ohdr->u.aeth = 340 ohdr->u.aeth =
341 cpu_to_be32((qp->r_msn & HFI1_MSN_MASK) | 341 cpu_to_be32((qp->r_msn & HFI1_MSN_MASK) |
@@ -801,7 +801,7 @@ int hfi1_make_rc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
801 qp->s_len -= len; 801 qp->s_len -= len;
802 qp->s_hdrwords = hwords; 802 qp->s_hdrwords = hwords;
803 ps->s_txreq->sde = priv->s_sde; 803 ps->s_txreq->sde = priv->s_sde;
804 qp->s_cur_sge = ss; 804 ps->s_txreq->ss = ss;
805 ps->s_txreq->s_cur_size = len; 805 ps->s_txreq->s_cur_size = len;
806 hfi1_make_ruc_header( 806 hfi1_make_ruc_header(
807 qp, 807 qp,
diff --git a/drivers/infiniband/hw/hfi1/uc.c b/drivers/infiniband/hw/hfi1/uc.c
index d062c3537f7c..b141a78ae38b 100644
--- a/drivers/infiniband/hw/hfi1/uc.c
+++ b/drivers/infiniband/hw/hfi1/uc.c
@@ -258,7 +258,7 @@ int hfi1_make_uc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
258 qp->s_len -= len; 258 qp->s_len -= len;
259 qp->s_hdrwords = hwords; 259 qp->s_hdrwords = hwords;
260 ps->s_txreq->sde = priv->s_sde; 260 ps->s_txreq->sde = priv->s_sde;
261 qp->s_cur_sge = &qp->s_sge; 261 ps->s_txreq->ss = &qp->s_sge;
262 ps->s_txreq->s_cur_size = len; 262 ps->s_txreq->s_cur_size = len;
263 hfi1_make_ruc_header(qp, ohdr, bth0 | (qp->s_state << 24), 263 hfi1_make_ruc_header(qp, ohdr, bth0 | (qp->s_state << 24),
264 mask_psn(qp->s_psn++), middle, ps); 264 mask_psn(qp->s_psn++), middle, ps);
diff --git a/drivers/infiniband/hw/hfi1/ud.c b/drivers/infiniband/hw/hfi1/ud.c
index d742ac1af947..c071955c0272 100644
--- a/drivers/infiniband/hw/hfi1/ud.c
+++ b/drivers/infiniband/hw/hfi1/ud.c
@@ -355,7 +355,7 @@ int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
355 /* header size in 32-bit words LRH+BTH+DETH = (8+12+8)/4. */ 355 /* header size in 32-bit words LRH+BTH+DETH = (8+12+8)/4. */
356 qp->s_hdrwords = 7; 356 qp->s_hdrwords = 7;
357 ps->s_txreq->s_cur_size = wqe->length; 357 ps->s_txreq->s_cur_size = wqe->length;
358 qp->s_cur_sge = &qp->s_sge; 358 ps->s_txreq->ss = &qp->s_sge;
359 qp->s_srate = ah_attr->static_rate; 359 qp->s_srate = ah_attr->static_rate;
360 qp->srate_mbps = ib_rate_to_mbps(qp->s_srate); 360 qp->srate_mbps = ib_rate_to_mbps(qp->s_srate);
361 qp->s_wqe = wqe; 361 qp->s_wqe = wqe;
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 65f2f1d76fc8..3b7bfd817647 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -790,10 +790,10 @@ static int wait_kmem(struct hfi1_ibdev *dev,
790 */ 790 */
791static noinline int build_verbs_ulp_payload( 791static noinline int build_verbs_ulp_payload(
792 struct sdma_engine *sde, 792 struct sdma_engine *sde,
793 struct rvt_sge_state *ss,
794 u32 length, 793 u32 length,
795 struct verbs_txreq *tx) 794 struct verbs_txreq *tx)
796{ 795{
796 struct rvt_sge_state *ss = tx->ss;
797 struct rvt_sge *sg_list = ss->sg_list; 797 struct rvt_sge *sg_list = ss->sg_list;
798 struct rvt_sge sge = ss->sge; 798 struct rvt_sge sge = ss->sge;
799 u8 num_sge = ss->num_sge; 799 u8 num_sge = ss->num_sge;
@@ -837,7 +837,6 @@ bail_txadd:
837/* New API */ 837/* New API */
838static int build_verbs_tx_desc( 838static int build_verbs_tx_desc(
839 struct sdma_engine *sde, 839 struct sdma_engine *sde,
840 struct rvt_sge_state *ss,
841 u32 length, 840 u32 length,
842 struct verbs_txreq *tx, 841 struct verbs_txreq *tx,
843 struct hfi1_ahg_info *ahg_info, 842 struct hfi1_ahg_info *ahg_info,
@@ -881,9 +880,9 @@ static int build_verbs_tx_desc(
881 goto bail_txadd; 880 goto bail_txadd;
882 } 881 }
883 882
884 /* add the ulp payload - if any. ss can be NULL for acks */ 883 /* add the ulp payload - if any. tx->ss can be NULL for acks */
885 if (ss) 884 if (tx->ss)
886 ret = build_verbs_ulp_payload(sde, ss, length, tx); 885 ret = build_verbs_ulp_payload(sde, length, tx);
887bail_txadd: 886bail_txadd:
888 return ret; 887 return ret;
889} 888}
@@ -894,7 +893,6 @@ int hfi1_verbs_send_dma(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
894 struct hfi1_qp_priv *priv = qp->priv; 893 struct hfi1_qp_priv *priv = qp->priv;
895 struct hfi1_ahg_info *ahg_info = priv->s_ahg; 894 struct hfi1_ahg_info *ahg_info = priv->s_ahg;
896 u32 hdrwords = qp->s_hdrwords; 895 u32 hdrwords = qp->s_hdrwords;
897 struct rvt_sge_state *ss = qp->s_cur_sge;
898 u32 len = ps->s_txreq->s_cur_size; 896 u32 len = ps->s_txreq->s_cur_size;
899 u32 plen = hdrwords + ((len + 3) >> 2) + 2; /* includes pbc */ 897 u32 plen = hdrwords + ((len + 3) >> 2) + 2; /* includes pbc */
900 struct hfi1_ibdev *dev = ps->dev; 898 struct hfi1_ibdev *dev = ps->dev;
@@ -920,7 +918,7 @@ int hfi1_verbs_send_dma(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
920 plen); 918 plen);
921 } 919 }
922 tx->wqe = qp->s_wqe; 920 tx->wqe = qp->s_wqe;
923 ret = build_verbs_tx_desc(tx->sde, ss, len, tx, ahg_info, pbc); 921 ret = build_verbs_tx_desc(tx->sde, len, tx, ahg_info, pbc);
924 if (unlikely(ret)) 922 if (unlikely(ret))
925 goto bail_build; 923 goto bail_build;
926 } 924 }
@@ -1011,7 +1009,7 @@ int hfi1_verbs_send_pio(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
1011{ 1009{
1012 struct hfi1_qp_priv *priv = qp->priv; 1010 struct hfi1_qp_priv *priv = qp->priv;
1013 u32 hdrwords = qp->s_hdrwords; 1011 u32 hdrwords = qp->s_hdrwords;
1014 struct rvt_sge_state *ss = qp->s_cur_sge; 1012 struct rvt_sge_state *ss = ps->s_txreq->ss;
1015 u32 len = ps->s_txreq->s_cur_size; 1013 u32 len = ps->s_txreq->s_cur_size;
1016 u32 dwords = (len + 3) >> 2; 1014 u32 dwords = (len + 3) >> 2;
1017 u32 plen = hdrwords + dwords + 2; /* includes pbc */ 1015 u32 plen = hdrwords + dwords + 2; /* includes pbc */