]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
vfio/spapr_tce: Skip unsetting already unset table
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 11 Feb 2019 07:49:17 +0000 (18:49 +1100)
committerAlex Williamson <alex.williamson@redhat.com>
Wed, 13 Feb 2019 20:08:12 +0000 (13:08 -0700)
VFIO TCE IOMMU v2 owns IOMMU tables. When we detach an IOMMU group from
a container, we need to unset these tables from the group which we do by
calling unset_window(). We also unset tables when removing a DMA window
via the VFIO_IOMMU_SPAPR_TCE_REMOVE ioctl.

The window removal checks if the table actually exists (hidden inside
tce_iommu_find_table()) but the group detaching does not so the user
may see duplicating messages:
pci 0009:03     : [PE# fd] Removing DMA window #0
pci 0009:03     : [PE# fd] Removing DMA window #1
pci 0009:03     : [PE# fd] Removing DMA window #0
pci 0009:03     : [PE# fd] Removing DMA window #1

At the moment this is not a problem as the second invocation
of unset_window() writes zeroes to the HW registers again and exits early
as there is no table.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio_iommu_spapr_tce.c

index c424913324e3e7da4e8a96b1b482c38d91d7b639..8dbb270998f47121dc0886151cb6e47da8a8e211 100644 (file)
@@ -1235,7 +1235,8 @@ static void tce_iommu_release_ownership_ddw(struct tce_container *container,
        }
 
        for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i)
-               table_group->ops->unset_window(table_group, i);
+               if (container->tables[i])
+                       table_group->ops->unset_window(table_group, i);
 
        table_group->ops->release_ownership(table_group);
 }