aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw
diff options
context:
space:
mode:
authorRoland Dreier <roland@topspin.com>2005-06-27 17:36:43 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-27 18:11:45 -0400
commita03a5a67b243e9a24805ee18272ad25e5b2ca92c (patch)
tree5e4a1d3ec8482a482caa6697cba12a819ef6aa8a /drivers/infiniband/hw
parenta852092e8cb305595ff630dfc3e9b25966a98276 (diff)
[PATCH] IB/mthca: Move mthca_is_memfree checks
Make mthca_table_put() and mthca_table_put_range() NOPs if the device is not mem-free, so that we don't have to have "if (mthca_is_memfree())" tests in the callers of these functions. This makes our code more readable and maintainable, and saves a couple dozen bytes of text in ib_mthca.ko as well. Signed-off-by: Roland Dreier <roland@topspin.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c10
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mr.c20
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c9
4 files changed, 22 insertions, 19 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 5dae5b5dc8e7..505d059216e9 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -918,9 +918,9 @@ void mthca_free_cq(struct mthca_dev *dev,
918 if (mthca_is_memfree(dev)) { 918 if (mthca_is_memfree(dev)) {
919 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index); 919 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index);
920 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index); 920 mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index);
921 mthca_table_put(dev, dev->cq_table.table, cq->cqn);
922 } 921 }
923 922
923 mthca_table_put(dev, dev->cq_table.table, cq->cqn);
924 mthca_free(&dev->cq_table.alloc, cq->cqn); 924 mthca_free(&dev->cq_table.alloc, cq->cqn);
925 kfree(mailbox); 925 kfree(mailbox);
926} 926}
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 637b30e35592..6d3b05dd9e3f 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -179,9 +179,14 @@ out:
179 179
180void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj) 180void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj)
181{ 181{
182 int i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE; 182 int i;
183 u8 status; 183 u8 status;
184 184
185 if (!mthca_is_memfree(dev))
186 return;
187
188 i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE;
189
185 down(&table->mutex); 190 down(&table->mutex);
186 191
187 if (--table->icm[i]->refcount == 0) { 192 if (--table->icm[i]->refcount == 0) {
@@ -256,6 +261,9 @@ void mthca_table_put_range(struct mthca_dev *dev, struct mthca_icm_table *table,
256{ 261{
257 int i; 262 int i;
258 263
264 if (!mthca_is_memfree(dev))
265 return;
266
259 for (i = start; i <= end; i += MTHCA_TABLE_CHUNK_SIZE / table->obj_size) 267 for (i = start; i <= end; i += MTHCA_TABLE_CHUNK_SIZE / table->obj_size)
260 mthca_table_put(dev, table, i); 268 mthca_table_put(dev, table, i);
261} 269}
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
index 8960fc2306be..29e5fe708b83 100644
--- a/drivers/infiniband/hw/mthca/mthca_mr.c
+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
@@ -195,10 +195,8 @@ static void mthca_free_mtt(struct mthca_dev *dev, u32 seg, int order,
195 struct mthca_buddy* buddy) 195 struct mthca_buddy* buddy)
196{ 196{
197 mthca_buddy_free(buddy, seg, order); 197 mthca_buddy_free(buddy, seg, order);
198 198 mthca_table_put_range(dev, dev->mr_table.mtt_table, seg,
199 if (mthca_is_memfree(dev)) 199 seg + (1 << order) - 1);
200 mthca_table_put_range(dev, dev->mr_table.mtt_table, seg,
201 seg + (1 << order) - 1);
202} 200}
203 201
204static inline u32 tavor_hw_index_to_key(u32 ind) 202static inline u32 tavor_hw_index_to_key(u32 ind)
@@ -299,8 +297,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
299 return err; 297 return err;
300 298
301err_out_table: 299err_out_table:
302 if (mthca_is_memfree(dev)) 300 mthca_table_put(dev, dev->mr_table.mpt_table, key);
303 mthca_table_put(dev, dev->mr_table.mpt_table, key);
304 301
305err_out_mpt_free: 302err_out_mpt_free:
306 mthca_free(&dev->mr_table.mpt_alloc, key); 303 mthca_free(&dev->mr_table.mpt_alloc, key);
@@ -437,8 +434,7 @@ err_out_free_mtt:
437 mthca_free_mtt(dev, mr->first_seg, mr->order, &dev->mr_table.mtt_buddy); 434 mthca_free_mtt(dev, mr->first_seg, mr->order, &dev->mr_table.mtt_buddy);
438 435
439err_out_table: 436err_out_table:
440 if (mthca_is_memfree(dev)) 437 mthca_table_put(dev, dev->mr_table.mpt_table, key);
441 mthca_table_put(dev, dev->mr_table.mpt_table, key);
442 438
443err_out_mpt_free: 439err_out_mpt_free:
444 mthca_free(&dev->mr_table.mpt_alloc, key); 440 mthca_free(&dev->mr_table.mpt_alloc, key);
@@ -452,9 +448,8 @@ static void mthca_free_region(struct mthca_dev *dev, u32 lkey, int order,
452 if (order >= 0) 448 if (order >= 0)
453 mthca_free_mtt(dev, first_seg, order, buddy); 449 mthca_free_mtt(dev, first_seg, order, buddy);
454 450
455 if (mthca_is_memfree(dev)) 451 mthca_table_put(dev, dev->mr_table.mpt_table,
456 mthca_table_put(dev, dev->mr_table.mpt_table, 452 arbel_key_to_hw_index(lkey));
457 arbel_key_to_hw_index(lkey));
458 453
459 mthca_free(&dev->mr_table.mpt_alloc, key_to_hw_index(dev, lkey)); 454 mthca_free(&dev->mr_table.mpt_alloc, key_to_hw_index(dev, lkey));
460} 455}
@@ -596,8 +591,7 @@ err_out_free_mtt:
596 dev->mr_table.fmr_mtt_buddy); 591 dev->mr_table.fmr_mtt_buddy);
597 592
598err_out_table: 593err_out_table:
599 if (mthca_is_memfree(dev)) 594 mthca_table_put(dev, dev->mr_table.mpt_table, key);
600 mthca_table_put(dev, dev->mr_table.mpt_table, key);
601 595
602err_out_mpt_free: 596err_out_mpt_free:
603 mthca_free(&dev->mr_table.mpt_alloc, mr->ibmr.lkey); 597 mthca_free(&dev->mr_table.mpt_alloc, mr->ibmr.lkey);
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index c62e7cf0ca3c..a92e870dfb97 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -1111,11 +1111,12 @@ static void mthca_free_memfree(struct mthca_dev *dev,
1111 if (mthca_is_memfree(dev)) { 1111 if (mthca_is_memfree(dev)) {
1112 mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index); 1112 mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index);
1113 mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index); 1113 mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
1114 mthca_table_put(dev, dev->qp_table.rdb_table,
1115 qp->qpn << dev->qp_table.rdb_shift);
1116 mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
1117 mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn);
1118 } 1114 }
1115
1116 mthca_table_put(dev, dev->qp_table.rdb_table,
1117 qp->qpn << dev->qp_table.rdb_shift);
1118 mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
1119 mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn);
1119} 1120}
1120 1121
1121static void mthca_wq_init(struct mthca_wq* wq) 1122static void mthca_wq_init(struct mthca_wq* wq)