aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <roland@topspin.com>2005-04-21 17:53:08 +0000
committerRoland Dreier <rolandd@cisco.com>2006-11-09 19:57:01 -0800
commit80245d02b8adf70bd2ab48633d3fb9617efd1915 (patch)
treecaac77aca04bcbe6b5227ceaa18125d07270d368
parent1dcaaf925b4e7d615a9a579efd0ea7143f06cc90 (diff)
downloadlibmthca-80245d02b8adf70bd2ab48633d3fb9617efd1915.tar.gz
Switch from using memalign() to posix_memalign()
Signed-off-by: Roland Dreier <roland@topspin.com>
-rw-r--r--src/ah.c5
-rw-r--r--src/cq.c10
-rw-r--r--src/memfree.c6
-rw-r--r--src/qp.c6
-rw-r--r--src/verbs.c6
5 files changed, 20 insertions, 13 deletions
diff --git a/src/ah.c b/src/ah.c
index e803555..72a7559 100644
--- a/src/ah.c
+++ b/src/ah.c
@@ -36,7 +36,7 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
-#include <malloc.h>
+#include <stdlib.h>
#include <netinet/in.h>
#include <pthread.h>
@@ -59,8 +59,7 @@ static struct mthca_ah_page *__add_page(struct mthca_pd *pd, int page_size, int
if (!page)
return NULL;
- page->buf = memalign(page_size, page_size);
- if (!page->buf) {
+ if (posix_memalign(&page->buf, page_size, page_size)) {
free(page);
return NULL;
}
diff --git a/src/cq.c b/src/cq.c
index daf4bab..3fc777c 100644
--- a/src/cq.c
+++ b/src/cq.c
@@ -281,6 +281,12 @@ static inline int mthca_poll_one(struct mthca_cq *cq,
if (!cqe)
return CQ_EMPTY;
+ /*
+ * Make sure we read CQ entry contents after we've checked the
+ * ownership bit.
+ */
+ mb();
+
qpn = ntohl(cqe->my_qpn);
is_error = (cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) ==
@@ -423,8 +429,10 @@ int mthca_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
break;
}
- if (freed)
+ if (freed) {
+ mb();
update_cons_index(cq, freed);
+ }
pthread_spin_unlock(&cq->lock);
diff --git a/src/memfree.c b/src/memfree.c
index 66e84d5..f00a969 100644
--- a/src/memfree.c
+++ b/src/memfree.c
@@ -36,7 +36,7 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
-#include <malloc.h>
+#include <stdlib.h>
#include <netinet/in.h>
#include <pthread.h>
@@ -98,8 +98,8 @@ int mthca_alloc_db(struct mthca_db_table *db_tab, enum mthca_db_type type,
goto out;
}
- db_tab->page[i].db_rec = memalign(MTHCA_DB_REC_PAGE_SIZE, MTHCA_DB_REC_PAGE_SIZE);
- if (!db_tab->page[i].db_rec) {
+ if (posix_memalign((void **) &db_tab->page[i].db_rec, MTHCA_DB_REC_PAGE_SIZE,
+ MTHCA_DB_REC_PAGE_SIZE)) {
ret = -1;
goto out;
}
diff --git a/src/qp.c b/src/qp.c
index f5bfe66..f53e8b0 100644
--- a/src/qp.c
+++ b/src/qp.c
@@ -37,7 +37,7 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
-#include <malloc.h>
+#include <stdlib.h>
#include <netinet/in.h>
#include <pthread.h>
@@ -755,9 +755,9 @@ int mthca_alloc_qp_buf(struct ibv_pd *pd, struct mthca_qp *qp)
1 << qp->sq.wqe_shift);
qp->buf_size = qp->send_wqe_offset + (qp->sq.max << qp->sq.wqe_shift);
- qp->buf = memalign(to_mdev(pd->context->device)->page_size, qp->buf_size);
- if (!qp->buf) {
+ if (posix_memalign(&qp->buf, to_mdev(pd->context->device)->page_size,
+ align(qp->buf_size, to_mdev(pd->context->device)->page_size))) {
free(qp->wrid);
return -1;
}
diff --git a/src/verbs.c b/src/verbs.c
index 41b80d9..65ecb67 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -36,6 +36,7 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
+#include <stdlib.h>
#include <strings.h>
#include <pthread.h>
#include <netinet/in.h>
@@ -148,9 +149,8 @@ struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe)
for (nent = 1; nent <= cqe; nent <<= 1)
; /* nothing */
- cq->buf = memalign(to_mdev(context->device)->page_size,
- nent * MTHCA_CQ_ENTRY_SIZE);
- if (!cq->buf)
+ if (posix_memalign(&cq->buf, to_mdev(context->device)->page_size,
+ align(nent * MTHCA_CQ_ENTRY_SIZE, to_mdev(context->device)->page_size)))
goto err;
mthca_init_cq_buf(cq, nent);