aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2005-08-31 22:52:26 +0000
committerRoland Dreier <rolandd@cisco.com>2006-11-09 19:57:02 -0800
commit1a51c56ae7852e1ae2971e9e5aeaa9fd0effbd84 (patch)
treecfa165af04294402fbf67543fc4009752c4e9e98
parent78422a08ec9efada33305cebc1b6a7595233dd46 (diff)
downloadlibmthca-1a51c56ae7852e1ae2971e9e5aeaa9fd0effbd84.tar.gz
Fix a couple of bugs in handling of mem-free doorbell records
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--src/memfree.c10
-rw-r--r--src/mthca.h2
-rw-r--r--src/verbs.c8
3 files changed, 11 insertions, 9 deletions
diff --git a/src/memfree.c b/src/memfree.c
index f00a969..ae0ca5b 100644
--- a/src/memfree.c
+++ b/src/memfree.c
@@ -42,8 +42,10 @@
#include "mthca.h"
+#define MTHCA_FREE_MAP_SIZE (MTHCA_DB_REC_PER_PAGE / (SIZEOF_LONG * 8))
+
struct mthca_db_page {
- unsigned long free[MTHCA_DB_REC_PER_PAGE / (SIZEOF_LONG * 8)];
+ unsigned long free[MTHCA_FREE_MAP_SIZE];
uint64_t *db_rec;
};
@@ -89,7 +91,7 @@ int mthca_alloc_db(struct mthca_db_table *db_tab, enum mthca_db_type type,
for (i = start; i != end; i += dir)
if (db_tab->page[i].db_rec)
- for (j = 0; j < MTHCA_DB_REC_PER_PAGE / SIZEOF_LONG; ++j)
+ for (j = 0; j < MTHCA_FREE_MAP_SIZE; ++j)
if (db_tab->page[i].free[j])
goto found;
@@ -113,7 +115,7 @@ int mthca_alloc_db(struct mthca_db_table *db_tab, enum mthca_db_type type,
--db_tab->min_group2;
found:
- for (j = 0; j < MTHCA_DB_REC_PER_PAGE / SIZEOF_LONG; ++j) {
+ for (j = 0; j < MTHCA_FREE_MAP_SIZE; ++j) {
k = ffsl(db_tab->page[i].free[j]);
if (k)
break;
@@ -125,7 +127,7 @@ found:
}
--k;
- db_tab->page[i].free[j] &= ~(1ULL << k);
+ db_tab->page[i].free[j] &= ~(1UL << k);
j = j * SIZEOF_LONG * 8 + k;
if (group == 1)
diff --git a/src/mthca.h b/src/mthca.h
index 69bbce8..be6faf4 100644
--- a/src/mthca.h
+++ b/src/mthca.h
@@ -297,7 +297,7 @@ extern struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, enum ibv_access_flags access);
extern int mthca_dereg_mr(struct ibv_mr *mr);
-struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe);
+extern struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe);
extern int mthca_destroy_cq(struct ibv_cq *cq);
extern int mthca_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
extern int mthca_tavor_arm_cq(struct ibv_cq *cq, int solicited);
diff --git a/src/verbs.c b/src/verbs.c
index 4728788..e8cfc22 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -222,13 +222,13 @@ struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe)
err_arm_db:
if (mthca_is_memfree(context))
- mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_SET_CI,
- cq->set_ci_db_index);
+ mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_ARM,
+ cq->arm_db_index);
err_set_db:
if (mthca_is_memfree(context))
- mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_ARM,
- cq->arm_db_index);
+ mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_SET_CI,
+ cq->set_ci_db_index);
err_unreg:
mthca_dereg_mr(cq->mr);