[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240115171852.GK734935@nvidia.com>
Date: Mon, 15 Jan 2024 13:18:52 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Yi Liu <yi.l.liu@...el.com>
Cc: joro@...tes.org, alex.williamson@...hat.com, kevin.tian@...el.com,
robin.murphy@....com, baolu.lu@...ux.intel.com, cohuck@...hat.com,
eric.auger@...hat.com, nicolinc@...dia.com, kvm@...r.kernel.org,
mjrosato@...ux.ibm.com, chao.p.peng@...ux.intel.com,
yi.y.sun@...ux.intel.com, peterx@...hat.com, jasowang@...hat.com,
shameerali.kolothum.thodi@...wei.com, lulu@...hat.com,
suravee.suthikulpanit@....com, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
zhenzhong.duan@...el.com, joao.m.martins@...cle.com,
xin.zeng@...el.com, yan.y.zhao@...el.com
Subject: Re: [PATCH 1/3] vfio-iommufd: Support pasid [at|de]tach for physical
VFIO devices
On Sun, Nov 26, 2023 at 10:39:07PM -0800, Yi Liu wrote:
> @@ -168,6 +180,42 @@ void vfio_iommufd_physical_detach_ioas(struct vfio_device *vdev)
> }
> EXPORT_SYMBOL_GPL(vfio_iommufd_physical_detach_ioas);
>
> +int vfio_iommufd_physical_pasid_attach_ioas(struct vfio_device *vdev,
> + u32 pasid, u32 *pt_id)
> +{
> + void *entry;
> + int rc;
> +
> + lockdep_assert_held(&vdev->dev_set->lock);
> +
> + if (WARN_ON(!vdev->iommufd_device))
> + return -EINVAL;
> +
> + entry = xa_load(&vdev->pasid_pts, pasid);
> + if (xa_is_value(entry))
> + rc = iommufd_device_pasid_replace(vdev->iommufd_device, pasid, pt_id);
> + else
> + rc = iommufd_device_pasid_attach(vdev->iommufd_device, pasid, pt_id);
An ida is a more approriate data structure if the only point is to
keep track if a pasid is in use or not..
Jason
Powered by blists - more mailing lists