Commit ac9a5889 authored by Alexey Kardashevskiy's avatar Alexey Kardashevskiy Committed by Michael Ellerman

powerpc/iommu: Put IOMMU group explicitly

So far an iommu_table lifetime was the same as PE. Dynamic DMA windows
will change this and iommu_free_table() will not always require
the group to be released.

This moves iommu_group_put() out of iommu_free_table().

This adds a iommu_pseries_free_table() helper which does
iommu_group_put() and iommu_free_table(). Later it will be
changed to receive a table_group and we will have to change less
lines then.

This should cause no behavioural change.
Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent c5773822
...@@ -726,13 +726,6 @@ void iommu_free_table(struct iommu_table *tbl, const char *node_name) ...@@ -726,13 +726,6 @@ void iommu_free_table(struct iommu_table *tbl, const char *node_name)
if (tbl->it_offset == 0) if (tbl->it_offset == 0)
clear_bit(0, tbl->it_map); clear_bit(0, tbl->it_map);
#ifdef CONFIG_IOMMU_API
if (tbl->it_group) {
iommu_group_put(tbl->it_group);
BUG_ON(tbl->it_group);
}
#endif
/* verify that table contains no entries */ /* verify that table contains no entries */
if (!bitmap_empty(tbl->it_map, tbl->it_size)) if (!bitmap_empty(tbl->it_map, tbl->it_size))
pr_warn("%s: Unexpected TCEs for %s\n", __func__, node_name); pr_warn("%s: Unexpected TCEs for %s\n", __func__, node_name);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/msi.h> #include <linux/msi.h>
#include <linux/memblock.h> #include <linux/memblock.h>
#include <linux/iommu.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -1310,6 +1311,10 @@ static void pnv_pci_ioda2_release_dma_pe(struct pci_dev *dev, struct pnv_ioda_pe ...@@ -1310,6 +1311,10 @@ static void pnv_pci_ioda2_release_dma_pe(struct pci_dev *dev, struct pnv_ioda_pe
if (rc) if (rc)
pe_warn(pe, "OPAL error %ld release DMA window\n", rc); pe_warn(pe, "OPAL error %ld release DMA window\n", rc);
if (tbl->it_group) {
iommu_group_put(tbl->it_group);
BUG_ON(tbl->it_group);
}
iommu_free_table(tbl, of_node_full_name(dev->dev.of_node)); iommu_free_table(tbl, of_node_full_name(dev->dev.of_node));
free_pages(addr, get_order(TCE32_TABLE_SIZE)); free_pages(addr, get_order(TCE32_TABLE_SIZE));
pe->tce32_table = NULL; pe->tce32_table = NULL;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/crash_dump.h> #include <linux/crash_dump.h>
#include <linux/memory.h> #include <linux/memory.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/iommu.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/rtas.h> #include <asm/rtas.h>
...@@ -51,6 +52,18 @@ ...@@ -51,6 +52,18 @@
#include "pseries.h" #include "pseries.h"
static void iommu_pseries_free_table(struct iommu_table *tbl,
const char *node_name)
{
#ifdef CONFIG_IOMMU_API
if (tbl->it_group) {
iommu_group_put(tbl->it_group);
BUG_ON(tbl->it_group);
}
#endif
iommu_free_table(tbl, node_name);
}
static void tce_invalidate_pSeries_sw(struct iommu_table *tbl, static void tce_invalidate_pSeries_sw(struct iommu_table *tbl,
__be64 *startp, __be64 *endp) __be64 *startp, __be64 *endp)
{ {
...@@ -1271,7 +1284,8 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti ...@@ -1271,7 +1284,8 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti
*/ */
remove_ddw(np, false); remove_ddw(np, false);
if (pci && pci->iommu_table) if (pci && pci->iommu_table)
iommu_free_table(pci->iommu_table, np->full_name); iommu_pseries_free_table(pci->iommu_table,
np->full_name);
spin_lock(&direct_window_list_lock); spin_lock(&direct_window_list_lock);
list_for_each_entry(window, &direct_window_list, list) { list_for_each_entry(window, &direct_window_list, list) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment