diff options
author | Nicolin Chen <nicolinc@nvidia.com> | 2023-07-28 08:33:27 +0200 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2023-07-28 18:31:24 +0200 |
commit | 70c16123d865046899c36e3655b2d611f38f51a3 (patch) | |
tree | e5c25fcd721a5141d37966c544fc7832b2776f16 /drivers/iommu/iommufd/device.c | |
parent | iommufd: Use iommufd_access_change_ioas in iommufd_access_destroy_object (diff) | |
download | linux-70c16123d865046899c36e3655b2d611f38f51a3.tar.xz linux-70c16123d865046899c36e3655b2d611f38f51a3.zip |
iommufd: Add iommufd_access_replace() API
Taking advantage of the new iommufd_access_change_ioas_id helper, add an
iommufd_access_replace() API for the VFIO emulated pathway to use.
Link: https://lore.kernel.org/r/a3267b924fd5f45e0d3a1dd13a9237e923563862.1690523699.git.nicolinc@nvidia.com
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/iommu/iommufd/device.c')
-rw-r--r-- | drivers/iommu/iommufd/device.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index c0b9cd97ec58..4c37eeea2bcd 100644 --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -849,6 +849,21 @@ int iommufd_access_attach(struct iommufd_access *access, u32 ioas_id) } EXPORT_SYMBOL_NS_GPL(iommufd_access_attach, IOMMUFD); +int iommufd_access_replace(struct iommufd_access *access, u32 ioas_id) +{ + int rc; + + mutex_lock(&access->ioas_lock); + if (!access->ioas) { + mutex_unlock(&access->ioas_lock); + return -ENOENT; + } + rc = iommufd_access_change_ioas_id(access, ioas_id); + mutex_unlock(&access->ioas_lock); + return rc; +} +EXPORT_SYMBOL_NS_GPL(iommufd_access_replace, IOMMUFD); + /** * iommufd_access_notify_unmap - Notify users of an iopt to stop using it * @iopt: iopt to work on |