Skip to content

Commit 930a42d

Browse files
aikawilliam
authored andcommitted
vfio/spapr_tce: Set window when adding additional groups to container
If a container already has a group attached, attaching a new group should just program already created IOMMU tables to the hardware via the iommu_table_group_ops::set_window() callback. However commit 6f01cc6 ("vfio/spapr: Add a helper to create default DMA window") did not just simplify the code but also removed the set_window() calls in the case of attaching groups to a container which already has tables so it broke VFIO PCI hotplug. This reverts set_window() bits in tce_iommu_take_ownership_ddw(). Fixes: 6f01cc6 ("vfio/spapr: Add a helper to create default DMA window") Signed-off-by: Alexey Kardashevskiy <[email protected]> Reviewed-by: David Gibson <[email protected]> Signed-off-by: Alex Williamson <[email protected]>
1 parent d5adbfc commit 930a42d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/vfio/vfio_iommu_spapr_tce.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,8 @@ static void tce_iommu_release_ownership_ddw(struct tce_container *container,
12451245
static long tce_iommu_take_ownership_ddw(struct tce_container *container,
12461246
struct iommu_table_group *table_group)
12471247
{
1248+
long i, ret = 0;
1249+
12481250
if (!table_group->ops->create_table || !table_group->ops->set_window ||
12491251
!table_group->ops->release_ownership) {
12501252
WARN_ON_ONCE(1);
@@ -1253,7 +1255,27 @@ static long tce_iommu_take_ownership_ddw(struct tce_container *container,
12531255

12541256
table_group->ops->take_ownership(table_group);
12551257

1258+
/* Set all windows to the new group */
1259+
for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i) {
1260+
struct iommu_table *tbl = container->tables[i];
1261+
1262+
if (!tbl)
1263+
continue;
1264+
1265+
ret = table_group->ops->set_window(table_group, i, tbl);
1266+
if (ret)
1267+
goto release_exit;
1268+
}
1269+
12561270
return 0;
1271+
1272+
release_exit:
1273+
for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i)
1274+
table_group->ops->unset_window(table_group, i);
1275+
1276+
table_group->ops->release_ownership(table_group);
1277+
1278+
return ret;
12571279
}
12581280

12591281
static int tce_iommu_attach_group(void *iommu_data,

0 commit comments

Comments
 (0)