[ofa-general] [PATCH] IB/libipathverbs - add barrier before updating head index in shared memory
Ralph Campbell
ralph.campbell at qlogic.com
Fri Jun 22 09:36:19 PDT 2007
Add a barrier to make sure the CPU doesn't reorder writes
to shared kernel memory when posting WQEs or reorder reads
when polling CQs.
Signed-off-by: Ralph Campbell <ralph.campbell at qlogic.com>
diff --git a/src/verbs.c b/src/verbs.c
index b2324d8..57c78dd 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -290,6 +290,8 @@ int ipath_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
for (npolled = 0; npolled < ne; ++npolled, ++wc) {
if (tail == q->head)
break;
+ /* Make sure entry is read after head index is read. */
+ rmb();
memcpy(wc, &q->queue[tail], sizeof(*wc));
if (tail == cq->ibv_cq.cqe)
tail = 0;
@@ -441,6 +443,8 @@ static int post_recv(struct ipath_rq *rq, struct ibv_recv_wr *wr,
wqe->num_sge = i->num_sge;
for (n = 0; n < wqe->num_sge; n++)
wqe->sg_list[n] = i->sg_list[n];
+ /* Make sure queue entry is written before the head index. */
+ wmb();
rwq->head = head;
}
ret = 0;
More information about the general
mailing list