]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - arch/powerpc/platforms/powernv/pci-ioda.c
powerpc/iommu/vfio_spapr_tce: Cleanup iommu_table disposal
[mirror_ubuntu-zesty-kernel.git] / arch / powerpc / platforms / powernv / pci-ioda.c
index 3c44a792c0b7f574b9006b8362c0a0ec2b1f94a8..0b1bb56a30b8dda7a2fcc7461ee31c2bb2c145ee 100644 (file)
@@ -1424,7 +1424,6 @@ static void pnv_pci_ioda2_release_dma_pe(struct pci_dev *dev, struct pnv_ioda_pe
                iommu_group_put(pe->table_group.group);
                BUG_ON(pe->table_group.group);
        }
-       pnv_pci_ioda2_table_free_pages(tbl);
        iommu_free_table(tbl, of_node_full_name(dev->dev.of_node));
 }
 
@@ -2049,7 +2048,6 @@ static void pnv_ioda2_tce_free(struct iommu_table *tbl, long index,
 static void pnv_ioda2_table_free(struct iommu_table *tbl)
 {
        pnv_pci_ioda2_table_free_pages(tbl);
-       iommu_free_table(tbl, "pnv");
 }
 
 static struct iommu_table_ops pnv_ioda2_iommu_ops = {
@@ -2326,6 +2324,8 @@ static long pnv_pci_ioda2_create_table(struct iommu_table_group *table_group,
        if (!tbl)
                return -ENOMEM;
 
+       tbl->it_ops = &pnv_ioda2_iommu_ops;
+
        ret = pnv_pci_ioda2_table_alloc_pages(nid,
                        bus_offset, page_shift, window_size,
                        levels, tbl);
@@ -2334,8 +2334,6 @@ static long pnv_pci_ioda2_create_table(struct iommu_table_group *table_group,
                return ret;
        }
 
-       tbl->it_ops = &pnv_ioda2_iommu_ops;
-
        *ptbl = tbl;
 
        return 0;
@@ -2376,7 +2374,7 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe)
        if (rc) {
                pe_err(pe, "Failed to configure 32-bit TCE table, err %ld\n",
                                rc);
-               pnv_ioda2_table_free(tbl);
+               iommu_free_table(tbl, "");
                return rc;
        }
 
@@ -2464,7 +2462,7 @@ static void pnv_ioda2_take_ownership(struct iommu_table_group *table_group)
        pnv_pci_ioda2_unset_window(&pe->table_group, 0);
        if (pe->pbus)
                pnv_ioda_setup_bus_dma(pe, pe->pbus, false);
-       pnv_ioda2_table_free(tbl);
+       iommu_free_table(tbl, "pnv");
 }
 
 static void pnv_ioda2_release_ownership(struct iommu_table_group *table_group)