Roland,<br>
<br>
Thanks.  Tested this out.. Works like a charm...<br>
<br>
-Viswa<br>
<br><br><div><span class="gmail_quote">On 9/21/05, <b class="gmail_sendername">Roland Dreier</b> <<a href="mailto:rolandd@cisco.com">rolandd@cisco.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks very much for the excellent test case.  The following patch<br>(already checked into svn and queued in git for merging into 2.6.14)<br>should fix things -- on my system, your test case ran successfully for<br>many hundreds of iterations.
<br><br>--- linux-kernel/infiniband/hw/mthca/mthca_memfree.c    (revision 3500)<br>+++ linux-kernel/infiniband/hw/mthca/mthca_memfree.c    (working copy)<br>@@ -529,12 +529,25 @@ int mthca_alloc_db(struct mthca_dev *dev<br>
                        goto
found;<br>                }<br><br>+       for (i = start; i != end; i += dir)<br>+               if (!dev->db_tab->page[i].db_rec) {<br>+                      
page = dev->db_tab->page + i;<br>+                      
goto alloc;<br>+               }<br>+<br>        if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) {<br>                ret = -ENOMEM;<br>                goto out;<br>        }<br><br>+       if (group == 0)
<br>+               ++dev->db_tab->max_group1;<br>+       else<br>+               --dev->db_tab->min_group2;<br>+<br>        page = dev->db_tab->page + end;<br>+<br>+alloc:<br>        page->db_rec = dma_alloc_coherent(&dev->pdev->dev, 4096,
<br>                                          &page->mapping,
GFP_KERNEL);<br>        if (!page->db_rec) {<br>@@ -554,10 +567,6 @@ int mthca_alloc_db(struct mthca_dev *dev<br>        }<br><br>        bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE);<br>-       if (group == 0)<br>
-               ++dev->db_tab->max_group1;<br>-       else<br>-               --dev->db_tab->min_group2;<br><br> found:<br>        j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE);<br></blockquote>
</div><br>