Re: [PATCH kernel] vfio: Only check for bus IOMMU when NOIOMMU is selected

From: Alex Williamson
Date: Fri Jan 22 2016 - 12:24:27 EST


On Fri, 2016-01-22 at 17:34 +1100, Alexey Kardashevskiy wrote:
> Recent change 03a76b60 "vfio: Include No-IOMMU mode" disabled VFIO
> on systems which do not implement iommu_ops for the PCI bus even
> though
> there is an VFIO IOMMU driver for it such as SPAPR TCE driver for
> PPC64/powernv platform.
>
> This moves iommu_present() call under #ifdef CONFIG_VFIO_NOIOMMU as
> it is done in the rest of the file to re-enable VFIO on powernv.
>
> Signed-off-by: Alexey Kardashevskiy <aik@xxxxxxxxx>
> ---
> Âdrivers/vfio/vfio.c | 5 ++++-
> Â1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
> index 82f25cc..3f8060e 100644
> --- a/drivers/vfio/vfio.c
> +++ b/drivers/vfio/vfio.c
> @@ -343,7 +343,6 @@ static struct vfio_group
> *vfio_create_group(struct iommu_group *iommu_group,
> Â atomic_set(&group->opened, 0);
> Â group->iommu_group = iommu_group;
> Â group->noiommu = !iommu_present;
> -
> Â group->nb.notifier_call = vfio_iommu_group_notifier;
> Â
> Â /*
> @@ -767,7 +766,11 @@ int vfio_add_group_dev(struct device *dev,
> Â
> Â group = vfio_group_get_from_iommu(iommu_group);
> Â if (!group) {
> +#ifdef CONFIG_VFIO_NOIOMMU
> Â group = vfio_create_group(iommu_group,
> iommu_present(dev->bus));
> +#else
> + group = vfio_create_group(iommu_group, true);
> +#endif
> Â if (IS_ERR(group)) {
> Â iommu_group_put(iommu_group);
> Â return PTR_ERR(group);


A serious problem indeed, but this isn't the right solution. ÂI've
copied you on a patch that I think fixes it. ÂPlease verify. ÂThanks,

Alex