aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_memfree.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-22 17:50:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-22 17:50:12 -0400
commitece236ce2fad9c27a6fd2530f899289025194bce (patch)
tree474b793205872206a2a3f7d409ff9b1f81f3a9a8 /drivers/infiniband/hw/mthca/mthca_memfree.c
parent441c196e84b11aad3123baa9320eee7abc6b5c98 (diff)
parent4460207561290c3be7e6c7538f22690028170c1d (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband: (26 commits) IB/qib: Defer HCA error events to tasklet mlx4_core: Bump the driver version to 1.0 RDMA/cxgb4: Use printk_ratelimited() instead of printk_ratelimit() IB/mlx4: Support PMA counters for IBoE IB/mlx4: Use flow counters on IBoE ports IB/pma: Add include file for IBA performance counters definitions mlx4_core: Add network flow counters mlx4_core: Fix location of counter index in QP context struct mlx4_core: Read extended capabilities into the flags field mlx4_core: Extend capability flags to 64 bits IB/mlx4: Generate GID change events in IBoE code IB/core: Add GID change event RDMA/cma: Don't allow IPoIB port space for IBoE RDMA: Allow for NULL .modify_device() and .modify_port() methods IB/qib: Update active link width IB/qib: Fix potential deadlock with link down interrupt IB/qib: Add sysfs interface to read free contexts IB/mthca: Remove unnecessary read of PCI_CAP_ID_EXP IB/qib: Remove double define IB/qib: Remove unnecessary read of PCI_CAP_ID_EXP ...
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_memfree.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 8c2a83732b5..7d2e42dd692 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -223,7 +223,6 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob
223{ 223{
224 int i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE; 224 int i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE;
225 int ret = 0; 225 int ret = 0;
226 u8 status;
227 226
228 mutex_lock(&table->mutex); 227 mutex_lock(&table->mutex);
229 228
@@ -240,8 +239,8 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob
240 goto out; 239 goto out;
241 } 240 }
242 241
243 if (mthca_MAP_ICM(dev, table->icm[i], table->virt + i * MTHCA_TABLE_CHUNK_SIZE, 242 if (mthca_MAP_ICM(dev, table->icm[i],
244 &status) || status) { 243 table->virt + i * MTHCA_TABLE_CHUNK_SIZE)) {
245 mthca_free_icm(dev, table->icm[i], table->coherent); 244 mthca_free_icm(dev, table->icm[i], table->coherent);
246 table->icm[i] = NULL; 245 table->icm[i] = NULL;
247 ret = -ENOMEM; 246 ret = -ENOMEM;
@@ -258,7 +257,6 @@ out:
258void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj) 257void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj)
259{ 258{
260 int i; 259 int i;
261 u8 status;
262 260
263 if (!mthca_is_memfree(dev)) 261 if (!mthca_is_memfree(dev))
264 return; 262 return;
@@ -269,8 +267,7 @@ void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int o
269 267
270 if (--table->icm[i]->refcount == 0) { 268 if (--table->icm[i]->refcount == 0) {
271 mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, 269 mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE,
272 MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, 270 MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE);
273 &status);
274 mthca_free_icm(dev, table->icm[i], table->coherent); 271 mthca_free_icm(dev, table->icm[i], table->coherent);
275 table->icm[i] = NULL; 272 table->icm[i] = NULL;
276 } 273 }
@@ -366,7 +363,6 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
366 int num_icm; 363 int num_icm;
367 unsigned chunk_size; 364 unsigned chunk_size;
368 int i; 365 int i;
369 u8 status;
370 366
371 obj_per_chunk = MTHCA_TABLE_CHUNK_SIZE / obj_size; 367 obj_per_chunk = MTHCA_TABLE_CHUNK_SIZE / obj_size;
372 num_icm = DIV_ROUND_UP(nobj, obj_per_chunk); 368 num_icm = DIV_ROUND_UP(nobj, obj_per_chunk);
@@ -396,8 +392,8 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
396 __GFP_NOWARN, use_coherent); 392 __GFP_NOWARN, use_coherent);
397 if (!table->icm[i]) 393 if (!table->icm[i])
398 goto err; 394 goto err;
399 if (mthca_MAP_ICM(dev, table->icm[i], virt + i * MTHCA_TABLE_CHUNK_SIZE, 395 if (mthca_MAP_ICM(dev, table->icm[i],
400 &status) || status) { 396 virt + i * MTHCA_TABLE_CHUNK_SIZE)) {
401 mthca_free_icm(dev, table->icm[i], table->coherent); 397 mthca_free_icm(dev, table->icm[i], table->coherent);
402 table->icm[i] = NULL; 398 table->icm[i] = NULL;
403 goto err; 399 goto err;
@@ -416,8 +412,7 @@ err:
416 for (i = 0; i < num_icm; ++i) 412 for (i = 0; i < num_icm; ++i)
417 if (table->icm[i]) { 413 if (table->icm[i]) {
418 mthca_UNMAP_ICM(dev, virt + i * MTHCA_TABLE_CHUNK_SIZE, 414 mthca_UNMAP_ICM(dev, virt + i * MTHCA_TABLE_CHUNK_SIZE,
419 MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, 415 MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE);
420 &status);
421 mthca_free_icm(dev, table->icm[i], table->coherent); 416 mthca_free_icm(dev, table->icm[i], table->coherent);
422 } 417 }
423 418
@@ -429,13 +424,12 @@ err:
429void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table) 424void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table)
430{ 425{
431 int i; 426 int i;
432 u8 status;
433 427
434 for (i = 0; i < table->num_icm; ++i) 428 for (i = 0; i < table->num_icm; ++i)
435 if (table->icm[i]) { 429 if (table->icm[i]) {
436 mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, 430 mthca_UNMAP_ICM(dev,
437 MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE, 431 table->virt + i * MTHCA_TABLE_CHUNK_SIZE,
438 &status); 432 MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE);
439 mthca_free_icm(dev, table->icm[i], table->coherent); 433 mthca_free_icm(dev, table->icm[i], table->coherent);
440 } 434 }
441 435
@@ -454,7 +448,6 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
454{ 448{
455 struct page *pages[1]; 449 struct page *pages[1];
456 int ret = 0; 450 int ret = 0;
457 u8 status;
458 int i; 451 int i;
459 452
460 if (!mthca_is_memfree(dev)) 453 if (!mthca_is_memfree(dev))
@@ -494,9 +487,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
494 } 487 }
495 488
496 ret = mthca_MAP_ICM_page(dev, sg_dma_address(&db_tab->page[i].mem), 489 ret = mthca_MAP_ICM_page(dev, sg_dma_address(&db_tab->page[i].mem),
497 mthca_uarc_virt(dev, uar, i), &status); 490 mthca_uarc_virt(dev, uar, i));
498 if (!ret && status)
499 ret = -EINVAL;
500 if (ret) { 491 if (ret) {
501 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); 492 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
502 put_page(sg_page(&db_tab->page[i].mem)); 493 put_page(sg_page(&db_tab->page[i].mem));
@@ -557,14 +548,13 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar,
557 struct mthca_user_db_table *db_tab) 548 struct mthca_user_db_table *db_tab)
558{ 549{
559 int i; 550 int i;
560 u8 status;
561 551
562 if (!mthca_is_memfree(dev)) 552 if (!mthca_is_memfree(dev))
563 return; 553 return;
564 554
565 for (i = 0; i < dev->uar_table.uarc_size / MTHCA_ICM_PAGE_SIZE; ++i) { 555 for (i = 0; i < dev->uar_table.uarc_size / MTHCA_ICM_PAGE_SIZE; ++i) {
566 if (db_tab->page[i].uvirt) { 556 if (db_tab->page[i].uvirt) {
567 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1, &status); 557 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1);
568 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); 558 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
569 put_page(sg_page(&db_tab->page[i].mem)); 559 put_page(sg_page(&db_tab->page[i].mem));
570 } 560 }
@@ -581,7 +571,6 @@ int mthca_alloc_db(struct mthca_dev *dev, enum mthca_db_type type,
581 int i, j; 571 int i, j;
582 struct mthca_db_page *page; 572 struct mthca_db_page *page;
583 int ret = 0; 573 int ret = 0;
584 u8 status;
585 574
586 mutex_lock(&dev->db_tab->mutex); 575 mutex_lock(&dev->db_tab->mutex);
587 576
@@ -644,9 +633,7 @@ alloc:
644 memset(page->db_rec, 0, MTHCA_ICM_PAGE_SIZE); 633 memset(page->db_rec, 0, MTHCA_ICM_PAGE_SIZE);
645 634
646 ret = mthca_MAP_ICM_page(dev, page->mapping, 635 ret = mthca_MAP_ICM_page(dev, page->mapping,
647 mthca_uarc_virt(dev, &dev->driver_uar, i), &status); 636 mthca_uarc_virt(dev, &dev->driver_uar, i));
648 if (!ret && status)
649 ret = -EINVAL;
650 if (ret) { 637 if (ret) {
651 dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE, 638 dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
652 page->db_rec, page->mapping); 639 page->db_rec, page->mapping);
@@ -678,7 +665,6 @@ void mthca_free_db(struct mthca_dev *dev, int type, int db_index)
678{ 665{
679 int i, j; 666 int i, j;
680 struct mthca_db_page *page; 667 struct mthca_db_page *page;
681 u8 status;
682 668
683 i = db_index / MTHCA_DB_REC_PER_PAGE; 669 i = db_index / MTHCA_DB_REC_PER_PAGE;
684 j = db_index % MTHCA_DB_REC_PER_PAGE; 670 j = db_index % MTHCA_DB_REC_PER_PAGE;
@@ -694,7 +680,7 @@ void mthca_free_db(struct mthca_dev *dev, int type, int db_index)
694 680
695 if (bitmap_empty(page->used, MTHCA_DB_REC_PER_PAGE) && 681 if (bitmap_empty(page->used, MTHCA_DB_REC_PER_PAGE) &&
696 i >= dev->db_tab->max_group1 - 1) { 682 i >= dev->db_tab->max_group1 - 1) {
697 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1, &status); 683 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1);
698 684
699 dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE, 685 dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
700 page->db_rec, page->mapping); 686 page->db_rec, page->mapping);
@@ -745,7 +731,6 @@ int mthca_init_db_tab(struct mthca_dev *dev)
745void mthca_cleanup_db_tab(struct mthca_dev *dev) 731void mthca_cleanup_db_tab(struct mthca_dev *dev)
746{ 732{
747 int i; 733 int i;
748 u8 status;
749 734
750 if (!mthca_is_memfree(dev)) 735 if (!mthca_is_memfree(dev))
751 return; 736 return;
@@ -763,7 +748,7 @@ void mthca_cleanup_db_tab(struct mthca_dev *dev)
763 if (!bitmap_empty(dev->db_tab->page[i].used, MTHCA_DB_REC_PER_PAGE)) 748 if (!bitmap_empty(dev->db_tab->page[i].used, MTHCA_DB_REC_PER_PAGE))
764 mthca_warn(dev, "Kernel UARC page %d not empty\n", i); 749 mthca_warn(dev, "Kernel UARC page %d not empty\n", i);
765 750
766 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1, &status); 751 mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1);
767 752
768 dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE, 753 dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
769 dev->db_tab->page[i].db_rec, 754 dev->db_tab->page[i].db_rec,