Commit a03a5a67 authored by Roland Dreier's avatar Roland Dreier Committed by Linus Torvalds

[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: default avatarRoland Dreier <roland@topspin.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a852092e
...@@ -918,9 +918,9 @@ void mthca_free_cq(struct mthca_dev *dev, ...@@ -918,9 +918,9 @@ void mthca_free_cq(struct mthca_dev *dev,
if (mthca_is_memfree(dev)) { if (mthca_is_memfree(dev)) {
mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index); mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index);
mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index); mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index);
mthca_table_put(dev, dev->cq_table.table, cq->cqn);
} }
mthca_table_put(dev, dev->cq_table.table, cq->cqn);
mthca_free(&dev->cq_table.alloc, cq->cqn); mthca_free(&dev->cq_table.alloc, cq->cqn);
kfree(mailbox); kfree(mailbox);
} }
......
...@@ -179,9 +179,14 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob ...@@ -179,9 +179,14 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob
void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj) void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj)
{ {
int i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE; int i;
u8 status; u8 status;
if (!mthca_is_memfree(dev))
return;
i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE;
down(&table->mutex); down(&table->mutex);
if (--table->icm[i]->refcount == 0) { 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,6 +261,9 @@ void mthca_table_put_range(struct mthca_dev *dev, struct mthca_icm_table *table,
{ {
int i; int i;
if (!mthca_is_memfree(dev))
return;
for (i = start; i <= end; i += MTHCA_TABLE_CHUNK_SIZE / table->obj_size) for (i = start; i <= end; i += MTHCA_TABLE_CHUNK_SIZE / table->obj_size)
mthca_table_put(dev, table, i); mthca_table_put(dev, table, i);
} }
......
...@@ -195,8 +195,6 @@ static void mthca_free_mtt(struct mthca_dev *dev, u32 seg, int order, ...@@ -195,8 +195,6 @@ static void mthca_free_mtt(struct mthca_dev *dev, u32 seg, int order,
struct mthca_buddy* buddy) struct mthca_buddy* buddy)
{ {
mthca_buddy_free(buddy, seg, order); mthca_buddy_free(buddy, seg, order);
if (mthca_is_memfree(dev))
mthca_table_put_range(dev, dev->mr_table.mtt_table, seg, mthca_table_put_range(dev, dev->mr_table.mtt_table, seg,
seg + (1 << order) - 1); seg + (1 << order) - 1);
} }
...@@ -299,7 +297,6 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd, ...@@ -299,7 +297,6 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
return err; return err;
err_out_table: err_out_table:
if (mthca_is_memfree(dev))
mthca_table_put(dev, dev->mr_table.mpt_table, key); mthca_table_put(dev, dev->mr_table.mpt_table, key);
err_out_mpt_free: err_out_mpt_free:
...@@ -437,7 +434,6 @@ int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd, ...@@ -437,7 +434,6 @@ int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
mthca_free_mtt(dev, mr->first_seg, mr->order, &dev->mr_table.mtt_buddy); mthca_free_mtt(dev, mr->first_seg, mr->order, &dev->mr_table.mtt_buddy);
err_out_table: err_out_table:
if (mthca_is_memfree(dev))
mthca_table_put(dev, dev->mr_table.mpt_table, key); mthca_table_put(dev, dev->mr_table.mpt_table, key);
err_out_mpt_free: err_out_mpt_free:
...@@ -452,7 +448,6 @@ static void mthca_free_region(struct mthca_dev *dev, u32 lkey, int order, ...@@ -452,7 +448,6 @@ static void mthca_free_region(struct mthca_dev *dev, u32 lkey, int order,
if (order >= 0) if (order >= 0)
mthca_free_mtt(dev, first_seg, order, buddy); mthca_free_mtt(dev, first_seg, order, buddy);
if (mthca_is_memfree(dev))
mthca_table_put(dev, dev->mr_table.mpt_table, mthca_table_put(dev, dev->mr_table.mpt_table,
arbel_key_to_hw_index(lkey)); arbel_key_to_hw_index(lkey));
...@@ -596,7 +591,6 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd, ...@@ -596,7 +591,6 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
dev->mr_table.fmr_mtt_buddy); dev->mr_table.fmr_mtt_buddy);
err_out_table: err_out_table:
if (mthca_is_memfree(dev))
mthca_table_put(dev, dev->mr_table.mpt_table, key); mthca_table_put(dev, dev->mr_table.mpt_table, key);
err_out_mpt_free: err_out_mpt_free:
......
...@@ -1111,11 +1111,12 @@ static void mthca_free_memfree(struct mthca_dev *dev, ...@@ -1111,11 +1111,12 @@ static void mthca_free_memfree(struct mthca_dev *dev,
if (mthca_is_memfree(dev)) { if (mthca_is_memfree(dev)) {
mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index); mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index);
mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index); mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
}
mthca_table_put(dev, dev->qp_table.rdb_table, mthca_table_put(dev, dev->qp_table.rdb_table,
qp->qpn << dev->qp_table.rdb_shift); qp->qpn << dev->qp_table.rdb_shift);
mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn); mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn); mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn);
}
} }
static void mthca_wq_init(struct mthca_wq* wq) static void mthca_wq_init(struct mthca_wq* wq)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment