summaryrefslogtreecommitdiff
path: root/drivers/vfio/vfio_main.c
diff options
context:
space:
mode:
authorYi Liu <yi.l.liu@intel.com>2023-03-27 02:33:51 -0700
committerJason Gunthorpe <jgg@nvidia.com>2023-03-31 13:43:32 -0300
commit7d12578c5d508050554bcd9ca3d2331914d86d71 (patch)
treeabfc6e7ae9aa91eca9d630fdd1577d91cce48074 /drivers/vfio/vfio_main.c
parent0a782d15e1d406e8074954405b1dc143a7645344 (diff)
vfio: Check the presence for iommufd callbacks in __vfio_register_dev()
After making the no-DMA drivers (samples/vfio-mdev) providing iommufd callbacks, __vfio_register_dev() should check the presence of the iommufd callbacks if CONFIG_IOMMUFD is enabled. Link: https://lore.kernel.org/r/20230327093351.44505-7-yi.l.liu@intel.com Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Tested-by: Terrence Xu <terrence.xu@intel.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Acked-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/vfio/vfio_main.c')
-rw-r--r--drivers/vfio/vfio_main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
index 43bd6b76e2b6..89497c933490 100644
--- a/drivers/vfio/vfio_main.c
+++ b/drivers/vfio/vfio_main.c
@@ -255,8 +255,9 @@ static int __vfio_register_dev(struct vfio_device *device,
{
int ret;
- if (WARN_ON(device->ops->bind_iommufd &&
- (!device->ops->unbind_iommufd ||
+ if (WARN_ON(IS_ENABLED(CONFIG_IOMMUFD) &&
+ (!device->ops->bind_iommufd ||
+ !device->ops->unbind_iommufd ||
!device->ops->attach_ioas)))
return -EINVAL;