aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_mr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_mr.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mr.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
index a85b503b8522..8960fc2306be 100644
--- a/drivers/infiniband/hw/mthca/mthca_mr.c
+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
@@ -181,7 +181,7 @@ static u32 mthca_alloc_mtt(struct mthca_dev *dev, int order,
181 if (seg == -1) 181 if (seg == -1)
182 return -1; 182 return -1;
183 183
184 if (dev->hca_type == ARBEL_NATIVE) 184 if (mthca_is_memfree(dev))
185 if (mthca_table_get_range(dev, dev->mr_table.mtt_table, seg, 185 if (mthca_table_get_range(dev, dev->mr_table.mtt_table, seg,
186 seg + (1 << order) - 1)) { 186 seg + (1 << order) - 1)) {
187 mthca_buddy_free(buddy, seg, order); 187 mthca_buddy_free(buddy, seg, order);
@@ -196,7 +196,7 @@ static void mthca_free_mtt(struct mthca_dev *dev, u32 seg, int order,
196{ 196{
197 mthca_buddy_free(buddy, seg, order); 197 mthca_buddy_free(buddy, seg, order);
198 198
199 if (dev->hca_type == ARBEL_NATIVE) 199 if (mthca_is_memfree(dev))
200 mthca_table_put_range(dev, dev->mr_table.mtt_table, seg, 200 mthca_table_put_range(dev, dev->mr_table.mtt_table, seg,
201 seg + (1 << order) - 1); 201 seg + (1 << order) - 1);
202} 202}
@@ -223,7 +223,7 @@ static inline u32 arbel_key_to_hw_index(u32 key)
223 223
224static inline u32 hw_index_to_key(struct mthca_dev *dev, u32 ind) 224static inline u32 hw_index_to_key(struct mthca_dev *dev, u32 ind)
225{ 225{
226 if (dev->hca_type == ARBEL_NATIVE) 226 if (mthca_is_memfree(dev))
227 return arbel_hw_index_to_key(ind); 227 return arbel_hw_index_to_key(ind);
228 else 228 else
229 return tavor_hw_index_to_key(ind); 229 return tavor_hw_index_to_key(ind);
@@ -231,7 +231,7 @@ static inline u32 hw_index_to_key(struct mthca_dev *dev, u32 ind)
231 231
232static inline u32 key_to_hw_index(struct mthca_dev *dev, u32 key) 232static inline u32 key_to_hw_index(struct mthca_dev *dev, u32 key)
233{ 233{
234 if (dev->hca_type == ARBEL_NATIVE) 234 if (mthca_is_memfree(dev))
235 return arbel_key_to_hw_index(key); 235 return arbel_key_to_hw_index(key);
236 else 236 else
237 return tavor_key_to_hw_index(key); 237 return tavor_key_to_hw_index(key);
@@ -254,7 +254,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
254 return -ENOMEM; 254 return -ENOMEM;
255 mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key); 255 mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key);
256 256
257 if (dev->hca_type == ARBEL_NATIVE) { 257 if (mthca_is_memfree(dev)) {
258 err = mthca_table_get(dev, dev->mr_table.mpt_table, key); 258 err = mthca_table_get(dev, dev->mr_table.mpt_table, key);
259 if (err) 259 if (err)
260 goto err_out_mpt_free; 260 goto err_out_mpt_free;
@@ -299,7 +299,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
299 return err; 299 return err;
300 300
301err_out_table: 301err_out_table:
302 if (dev->hca_type == ARBEL_NATIVE) 302 if (mthca_is_memfree(dev))
303 mthca_table_put(dev, dev->mr_table.mpt_table, key); 303 mthca_table_put(dev, dev->mr_table.mpt_table, key);
304 304
305err_out_mpt_free: 305err_out_mpt_free:
@@ -329,7 +329,7 @@ int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
329 return -ENOMEM; 329 return -ENOMEM;
330 mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key); 330 mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key);
331 331
332 if (dev->hca_type == ARBEL_NATIVE) { 332 if (mthca_is_memfree(dev)) {
333 err = mthca_table_get(dev, dev->mr_table.mpt_table, key); 333 err = mthca_table_get(dev, dev->mr_table.mpt_table, key);
334 if (err) 334 if (err)
335 goto err_out_mpt_free; 335 goto err_out_mpt_free;
@@ -437,7 +437,7 @@ err_out_free_mtt:
437 mthca_free_mtt(dev, mr->first_seg, mr->order, &dev->mr_table.mtt_buddy); 437 mthca_free_mtt(dev, mr->first_seg, mr->order, &dev->mr_table.mtt_buddy);
438 438
439err_out_table: 439err_out_table:
440 if (dev->hca_type == ARBEL_NATIVE) 440 if (mthca_is_memfree(dev))
441 mthca_table_put(dev, dev->mr_table.mpt_table, key); 441 mthca_table_put(dev, dev->mr_table.mpt_table, key);
442 442
443err_out_mpt_free: 443err_out_mpt_free:
@@ -452,7 +452,7 @@ static void mthca_free_region(struct mthca_dev *dev, u32 lkey, int order,
452 if (order >= 0) 452 if (order >= 0)
453 mthca_free_mtt(dev, first_seg, order, buddy); 453 mthca_free_mtt(dev, first_seg, order, buddy);
454 454
455 if (dev->hca_type == ARBEL_NATIVE) 455 if (mthca_is_memfree(dev))
456 mthca_table_put(dev, dev->mr_table.mpt_table, 456 mthca_table_put(dev, dev->mr_table.mpt_table,
457 arbel_key_to_hw_index(lkey)); 457 arbel_key_to_hw_index(lkey));
458 458
@@ -498,7 +498,7 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
498 return -EINVAL; 498 return -EINVAL;
499 499
500 /* For Arbel, all MTTs must fit in the same page. */ 500 /* For Arbel, all MTTs must fit in the same page. */
501 if (dev->hca_type == ARBEL_NATIVE && 501 if (mthca_is_memfree(dev) &&
502 mr->attr.max_pages * sizeof *mr->mem.arbel.mtts > PAGE_SIZE) 502 mr->attr.max_pages * sizeof *mr->mem.arbel.mtts > PAGE_SIZE)
503 return -EINVAL; 503 return -EINVAL;
504 504
@@ -511,7 +511,7 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
511 idx = key & (dev->limits.num_mpts - 1); 511 idx = key & (dev->limits.num_mpts - 1);
512 mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key); 512 mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key);
513 513
514 if (dev->hca_type == ARBEL_NATIVE) { 514 if (mthca_is_memfree(dev)) {
515 err = mthca_table_get(dev, dev->mr_table.mpt_table, key); 515 err = mthca_table_get(dev, dev->mr_table.mpt_table, key);
516 if (err) 516 if (err)
517 goto err_out_mpt_free; 517 goto err_out_mpt_free;
@@ -534,7 +534,7 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
534 534
535 mtt_seg = mr->first_seg * MTHCA_MTT_SEG_SIZE; 535 mtt_seg = mr->first_seg * MTHCA_MTT_SEG_SIZE;
536 536
537 if (dev->hca_type == ARBEL_NATIVE) { 537 if (mthca_is_memfree(dev)) {
538 mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table, 538 mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table,
539 mr->first_seg); 539 mr->first_seg);
540 BUG_ON(!mr->mem.arbel.mtts); 540 BUG_ON(!mr->mem.arbel.mtts);
@@ -596,7 +596,7 @@ err_out_free_mtt:
596 dev->mr_table.fmr_mtt_buddy); 596 dev->mr_table.fmr_mtt_buddy);
597 597
598err_out_table: 598err_out_table:
599 if (dev->hca_type == ARBEL_NATIVE) 599 if (mthca_is_memfree(dev))
600 mthca_table_put(dev, dev->mr_table.mpt_table, key); 600 mthca_table_put(dev, dev->mr_table.mpt_table, key);
601 601
602err_out_mpt_free: 602err_out_mpt_free:
@@ -765,7 +765,7 @@ int __devinit mthca_init_mr_table(struct mthca_dev *dev)
765 if (err) 765 if (err)
766 return err; 766 return err;
767 767
768 if (dev->hca_type != ARBEL_NATIVE && 768 if (!mthca_is_memfree(dev) &&
769 (dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) 769 (dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN))
770 dev->limits.fmr_reserved_mtts = 0; 770 dev->limits.fmr_reserved_mtts = 0;
771 else 771 else