]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[MTHCA] fixed a bug in release resources
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 10 Apr 2006 17:52:50 +0000 (17:52 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 10 Apr 2006 17:52:50 +0000 (17:52 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@305 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/hw/mthca/kernel/mthca_memfree.c

index ad469f0b7ae3d6ab54e843011df6f8df3a7e0d82..6949da6f8b40a64c991b5d8d3141bf279001a828 100644 (file)
@@ -456,6 +456,8 @@ out:
 void mthca_unmap_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
                         struct mthca_user_db_table *db_tab, int index)
 {
+       u8 status;
+       int ix = index / MTHCA_DB_REC_PER_PAGE;
        UNREFERENCED_PARAMETER(uar);
        
        if (!mthca_is_memfree(dev))
@@ -468,7 +470,12 @@ void mthca_unmap_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
 
        down(&db_tab->mutex);
 
-       --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount;
+       if (!--db_tab->page[ix].refcount) {
+               mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, ix), 1, &status);
+               pci_unmap_sg(dev, &db_tab->page[ix].mem, 1, PCI_DMA_TODEVICE);
+               put_page(&db_tab->page[ix].mem);
+               db_tab->page[ix].uvirt = 0;
+       }
 
        up(&db_tab->mutex);
 }