diff options
| -rw-r--r-- | drivers/infiniband/hw/mthca/mthca_memfree.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 1827400f189b..d0c41fe046f0 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
| @@ -529,12 +529,25 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db) | |||
| 529 | goto found; | 529 | goto found; |
| 530 | } | 530 | } |
| 531 | 531 | ||
| 532 | for (i = start; i != end; i += dir) | ||
| 533 | if (!dev->db_tab->page[i].db_rec) { | ||
| 534 | page = dev->db_tab->page + i; | ||
| 535 | goto alloc; | ||
| 536 | } | ||
| 537 | |||
| 532 | if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) { | 538 | if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) { |
| 533 | ret = -ENOMEM; | 539 | ret = -ENOMEM; |
| 534 | goto out; | 540 | goto out; |
| 535 | } | 541 | } |
| 536 | 542 | ||
| 543 | if (group == 0) | ||
| 544 | ++dev->db_tab->max_group1; | ||
| 545 | else | ||
| 546 | --dev->db_tab->min_group2; | ||
| 547 | |||
| 537 | page = dev->db_tab->page + end; | 548 | page = dev->db_tab->page + end; |
| 549 | |||
| 550 | alloc: | ||
| 538 | page->db_rec = dma_alloc_coherent(&dev->pdev->dev, 4096, | 551 | page->db_rec = dma_alloc_coherent(&dev->pdev->dev, 4096, |
| 539 | &page->mapping, GFP_KERNEL); | 552 | &page->mapping, GFP_KERNEL); |
| 540 | if (!page->db_rec) { | 553 | if (!page->db_rec) { |
| @@ -554,10 +567,6 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db) | |||
| 554 | } | 567 | } |
| 555 | 568 | ||
| 556 | bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE); | 569 | bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE); |
| 557 | if (group == 0) | ||
| 558 | ++dev->db_tab->max_group1; | ||
| 559 | else | ||
| 560 | --dev->db_tab->min_group2; | ||
| 561 | 570 | ||
| 562 | found: | 571 | found: |
| 563 | j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE); | 572 | j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE); |
