Skip to content

Commit 70c1612

Browse files
nicolincjgunthorpe
authored andcommitted
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>
1 parent 6129b59 commit 70c1612

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/iommu/iommufd/device.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,21 @@ int iommufd_access_attach(struct iommufd_access *access, u32 ioas_id)
849849
}
850850
EXPORT_SYMBOL_NS_GPL(iommufd_access_attach, IOMMUFD);
851851

852+
int iommufd_access_replace(struct iommufd_access *access, u32 ioas_id)
853+
{
854+
int rc;
855+
856+
mutex_lock(&access->ioas_lock);
857+
if (!access->ioas) {
858+
mutex_unlock(&access->ioas_lock);
859+
return -ENOENT;
860+
}
861+
rc = iommufd_access_change_ioas_id(access, ioas_id);
862+
mutex_unlock(&access->ioas_lock);
863+
return rc;
864+
}
865+
EXPORT_SYMBOL_NS_GPL(iommufd_access_replace, IOMMUFD);
866+
852867
/**
853868
* iommufd_access_notify_unmap - Notify users of an iopt to stop using it
854869
* @iopt: iopt to work on

include/linux/iommufd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ iommufd_access_create(struct iommufd_ctx *ictx,
4949
const struct iommufd_access_ops *ops, void *data, u32 *id);
5050
void iommufd_access_destroy(struct iommufd_access *access);
5151
int iommufd_access_attach(struct iommufd_access *access, u32 ioas_id);
52+
int iommufd_access_replace(struct iommufd_access *access, u32 ioas_id);
5253
void iommufd_access_detach(struct iommufd_access *access);
5354

5455
void iommufd_ctx_get(struct iommufd_ctx *ictx);

0 commit comments

Comments
 (0)