diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2017-03-22 00:21:49 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-03-30 06:42:11 -0400 |
commit | 11edf116e3a6352cfee6b1437d41603c9aff79c9 (patch) | |
tree | 2c9da60b682697828e6f88e5f3e1f3965d5ad3ad /arch/powerpc/platforms | |
parent | a540aa56ba3d29084f28710c8b93cc9c3c422943 (diff) |
powerpc/iommu/vfio_spapr_tce: Cleanup iommu_table disposal
At the moment iommu_table can be disposed by either calling
iommu_table_free() directly or it_ops::free(); the only implementation
of free() is in IODA2 - pnv_ioda2_table_free() - and it calls
iommu_table_free() anyway.
As we are going to have reference counting on tables, we need an unified
way of disposing tables.
This moves it_ops::free() call into iommu_free_table() and makes use
of the latter. The free() callback now handles only platform-specific
data.
As from now on the iommu_free_table() calls it_ops->free(), we need
to have it_ops initialized before calling iommu_free_table() so this
moves this initialization in pnv_pci_ioda2_create_table().
This should cause no behavioral change.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r-- | arch/powerpc/platforms/powernv/pci-ioda.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 572e9c9f1ea0..5dae54cb11e3 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c | |||
@@ -1424,7 +1424,6 @@ static void pnv_pci_ioda2_release_dma_pe(struct pci_dev *dev, struct pnv_ioda_pe | |||
1424 | iommu_group_put(pe->table_group.group); | 1424 | iommu_group_put(pe->table_group.group); |
1425 | BUG_ON(pe->table_group.group); | 1425 | BUG_ON(pe->table_group.group); |
1426 | } | 1426 | } |
1427 | pnv_pci_ioda2_table_free_pages(tbl); | ||
1428 | iommu_free_table(tbl, of_node_full_name(dev->dev.of_node)); | 1427 | iommu_free_table(tbl, of_node_full_name(dev->dev.of_node)); |
1429 | } | 1428 | } |
1430 | 1429 | ||
@@ -2040,7 +2039,6 @@ static void pnv_ioda2_tce_free(struct iommu_table *tbl, long index, | |||
2040 | static void pnv_ioda2_table_free(struct iommu_table *tbl) | 2039 | static void pnv_ioda2_table_free(struct iommu_table *tbl) |
2041 | { | 2040 | { |
2042 | pnv_pci_ioda2_table_free_pages(tbl); | 2041 | pnv_pci_ioda2_table_free_pages(tbl); |
2043 | iommu_free_table(tbl, "pnv"); | ||
2044 | } | 2042 | } |
2045 | 2043 | ||
2046 | static struct iommu_table_ops pnv_ioda2_iommu_ops = { | 2044 | static struct iommu_table_ops pnv_ioda2_iommu_ops = { |
@@ -2317,6 +2315,8 @@ static long pnv_pci_ioda2_create_table(struct iommu_table_group *table_group, | |||
2317 | if (!tbl) | 2315 | if (!tbl) |
2318 | return -ENOMEM; | 2316 | return -ENOMEM; |
2319 | 2317 | ||
2318 | tbl->it_ops = &pnv_ioda2_iommu_ops; | ||
2319 | |||
2320 | ret = pnv_pci_ioda2_table_alloc_pages(nid, | 2320 | ret = pnv_pci_ioda2_table_alloc_pages(nid, |
2321 | bus_offset, page_shift, window_size, | 2321 | bus_offset, page_shift, window_size, |
2322 | levels, tbl); | 2322 | levels, tbl); |
@@ -2325,8 +2325,6 @@ static long pnv_pci_ioda2_create_table(struct iommu_table_group *table_group, | |||
2325 | return ret; | 2325 | return ret; |
2326 | } | 2326 | } |
2327 | 2327 | ||
2328 | tbl->it_ops = &pnv_ioda2_iommu_ops; | ||
2329 | |||
2330 | *ptbl = tbl; | 2328 | *ptbl = tbl; |
2331 | 2329 | ||
2332 | return 0; | 2330 | return 0; |
@@ -2367,7 +2365,7 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe) | |||
2367 | if (rc) { | 2365 | if (rc) { |
2368 | pe_err(pe, "Failed to configure 32-bit TCE table, err %ld\n", | 2366 | pe_err(pe, "Failed to configure 32-bit TCE table, err %ld\n", |
2369 | rc); | 2367 | rc); |
2370 | pnv_ioda2_table_free(tbl); | 2368 | iommu_free_table(tbl, ""); |
2371 | return rc; | 2369 | return rc; |
2372 | } | 2370 | } |
2373 | 2371 | ||
@@ -2455,7 +2453,7 @@ static void pnv_ioda2_take_ownership(struct iommu_table_group *table_group) | |||
2455 | pnv_pci_ioda2_unset_window(&pe->table_group, 0); | 2453 | pnv_pci_ioda2_unset_window(&pe->table_group, 0); |
2456 | if (pe->pbus) | 2454 | if (pe->pbus) |
2457 | pnv_ioda_setup_bus_dma(pe, pe->pbus, false); | 2455 | pnv_ioda_setup_bus_dma(pe, pe->pbus, false); |
2458 | pnv_ioda2_table_free(tbl); | 2456 | iommu_free_table(tbl, "pnv"); |
2459 | } | 2457 | } |
2460 | 2458 | ||
2461 | static void pnv_ioda2_release_ownership(struct iommu_table_group *table_group) | 2459 | static void pnv_ioda2_release_ownership(struct iommu_table_group *table_group) |