Re: [PATCH v3 03/16] iommufd/viommu: Add IOMMU_VDEVICE_ALLOC ioctl

2024-10-21 Thread Nicolin Chen
On Mon, Oct 21, 2024 at 09:22:48AM -0300, Jason Gunthorpe wrote: > On Sat, Oct 19, 2024 at 06:42:30PM -0700, Nicolin Chen wrote: > > > But be mindful of this abort, it doesn't want to be inside the lock if > > > it also gets the lock.. fail_nth should be updated to cover these new > > > ioctls to l

Re: [PATCH v3 03/16] iommufd/viommu: Add IOMMU_VDEVICE_ALLOC ioctl

2024-10-21 Thread Jason Gunthorpe
On Sat, Oct 19, 2024 at 06:42:30PM -0700, Nicolin Chen wrote: > > But be mindful of this abort, it doesn't want to be inside the lock if > > it also gets the lock.. fail_nth should be updated to cover these new > > ioctls to look for tricky things like that > > I added an abort() beside destroy():

Re: [PATCH v3 03/16] iommufd/viommu: Add IOMMU_VDEVICE_ALLOC ioctl

2024-10-19 Thread Nicolin Chen
On Thu, Oct 17, 2024 at 03:52:30PM -0300, Jason Gunthorpe wrote: > > + if (viommu->ops && viommu->ops->vdevice_alloc) > > + vdev = viommu->ops->vdevice_alloc(viommu, idev->dev, virt_id); > > + else > > + vdev = __iommufd_vdevice_alloc(ucmd->ictx, sizeof(*vdev)); > > + if (

Re: [PATCH v3 03/16] iommufd/viommu: Add IOMMU_VDEVICE_ALLOC ioctl

2024-10-17 Thread Jason Gunthorpe
On Wed, Oct 09, 2024 at 09:38:15AM -0700, Nicolin Chen wrote: > +void iommufd_vdevice_destroy(struct iommufd_object *obj) > +{ > + struct iommufd_vdevice *old, *vdev = > + container_of(obj, struct iommufd_vdevice, obj); > + struct iommufd_viommu *viommu = vdev->viommu; > + s

[PATCH v3 03/16] iommufd/viommu: Add IOMMU_VDEVICE_ALLOC ioctl

2024-10-09 Thread Nicolin Chen
Introduce a new ioctl to allocate a vDEVICE object. Since a vDEVICE object is a connection of an iommufd_iommufd object and an iommufd_viommu object, require both as the ioctl inputs and take refcounts in the ioctl handler. Add to the vIOMMU object a "vdevs" xarray, indexed by a per-vIOMMU virtual