[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/trunk@305 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/kernel/mthca_memfree.c

index ad469f0..6949da6 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);
 }