提交 22af4859 编写于 作者: A Alexey Kardashevskiy 提交者: Michael Ellerman

vfio: powerpc/spapr: Rework groups attaching

This is to make extended ownership and multiple groups support patches
simpler for review.

This should cause no behavioural change.
Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
[aw: for the vfio related changes]
Acked-by: NAlex Williamson <alex.williamson@redhat.com>
Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
Reviewed-by: NGavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
上级 649354b7
...@@ -460,16 +460,21 @@ static int tce_iommu_attach_group(void *iommu_data, ...@@ -460,16 +460,21 @@ static int tce_iommu_attach_group(void *iommu_data,
iommu_group_id(container->tbl->it_group), iommu_group_id(container->tbl->it_group),
iommu_group_id(iommu_group)); iommu_group_id(iommu_group));
ret = -EBUSY; ret = -EBUSY;
} else if (container->enabled) { goto unlock_exit;
}
if (container->enabled) {
pr_err("tce_vfio: attaching group #%u to enabled container\n", pr_err("tce_vfio: attaching group #%u to enabled container\n",
iommu_group_id(iommu_group)); iommu_group_id(iommu_group));
ret = -EBUSY; ret = -EBUSY;
} else { goto unlock_exit;
ret = iommu_take_ownership(tbl);
if (!ret)
container->tbl = tbl;
} }
ret = iommu_take_ownership(tbl);
if (!ret)
container->tbl = tbl;
unlock_exit:
mutex_unlock(&container->lock); mutex_unlock(&container->lock);
return ret; return ret;
...@@ -487,19 +492,22 @@ static void tce_iommu_detach_group(void *iommu_data, ...@@ -487,19 +492,22 @@ static void tce_iommu_detach_group(void *iommu_data,
pr_warn("tce_vfio: detaching group #%u, expected group is #%u\n", pr_warn("tce_vfio: detaching group #%u, expected group is #%u\n",
iommu_group_id(iommu_group), iommu_group_id(iommu_group),
iommu_group_id(tbl->it_group)); iommu_group_id(tbl->it_group));
} else { goto unlock_exit;
if (container->enabled) { }
pr_warn("tce_vfio: detaching group #%u from enabled container, forcing disable\n",
iommu_group_id(tbl->it_group));
tce_iommu_disable(container);
}
/* pr_debug("tce_vfio: detaching group #%u from iommu %p\n", if (container->enabled) {
iommu_group_id(iommu_group), iommu_group); */ pr_warn("tce_vfio: detaching group #%u from enabled container, forcing disable\n",
container->tbl = NULL; iommu_group_id(tbl->it_group));
tce_iommu_clear(container, tbl, tbl->it_offset, tbl->it_size); tce_iommu_disable(container);
iommu_release_ownership(tbl);
} }
/* pr_debug("tce_vfio: detaching group #%u from iommu %p\n",
iommu_group_id(iommu_group), iommu_group); */
container->tbl = NULL;
tce_iommu_clear(container, tbl, tbl->it_offset, tbl->it_size);
iommu_release_ownership(tbl);
unlock_exit:
mutex_unlock(&container->lock); mutex_unlock(&container->lock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册