On Fri, Apr 12, 2024 at 01:21:19AM -0700, Yi Liu wrote: > +int vfio_iommufd_physical_pasid_attach_ioas(struct vfio_device *vdev, > + u32 pasid, u32 *pt_id) > +{ > + int rc; > + > + lockdep_assert_held(&vdev->dev_set->lock); > + > + if (WARN_ON(!vdev->iommufd_device)) > + return -EINVAL; > + > + rc = ida_get_lowest(&vdev->pasids, pasid, pasid); A helper inline bool ida_is_allocate(&ida, id) Would be nicer for that > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > index cb5b7f865d58..e0198851ffd2 100644 > --- a/drivers/vfio/pci/vfio_pci.c > +++ b/drivers/vfio/pci/vfio_pci.c > @@ -142,6 +142,8 @@ static const struct vfio_device_ops vfio_pci_ops = { > .unbind_iommufd = vfio_iommufd_physical_unbind, > .attach_ioas = vfio_iommufd_physical_attach_ioas, > .detach_ioas = vfio_iommufd_physical_detach_ioas, > + .pasid_attach_ioas = vfio_iommufd_physical_pasid_attach_ioas, > + .pasid_detach_ioas = vfio_iommufd_physical_pasid_detach_ioas, > }; This should be copied into mlx5 and nvgrace-gpu at least as well Jason