diff options
author | Roland Dreier <rolandd@cisco.com> | 2005-09-22 00:40:12 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-09-26 12:38:26 -0400 |
commit | 018771f435388f22f388eb8658c652086fb3633e (patch) | |
tree | d18f3929acf5acff74a786f233ba8421bfe95c84 | |
parent | 8ddec7460d2f5db3ac35812c03676b1473d1d668 (diff) |
[IB] mthca: Fix doorbell record resource leak
If we allocate a bunch of doorbell records and then free them, we'll
end up with completely empty pages, which we then free. However, when
we come back to allocate more doorbell pages, we have to reallocate
those empty pages rather than always trying to take a slot that we've
never used. If we don't, we eventually use up every slot and fail to
allocate a doorbell record, even though we have plenty of free space.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-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); |