iommufd: Add iommufd_access_change_ioas(_id) helpers
authorNicolin Chen <nicolinc@nvidia.com>
Fri, 28 Jul 2023 06:33:25 +0000 (23:33 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 28 Jul 2023 16:31:24 +0000 (13:31 -0300)
commit9227da7816dd1a42e20d41e2244cb63c205477ca
tree00a7579b73a263b3bd7d1085df972df2e868c855
parent5d5c85ff6246c1b70b3b75a0b9d9fe749d0a5652
iommufd: Add iommufd_access_change_ioas(_id) helpers

The complication of the mutex and refcount will be amplified after we
introduce the replace support for accesses. So, add a preparatory change
of a constitutive helper iommufd_access_change_ioas() and its wrapper
iommufd_access_change_ioas_id(). They can simply take care of existing
iommufd_access_attach() and iommufd_access_detach(), properly sequencing
the refcount puts so that they are truely at the end of the sequence after
we know the IOAS pointer is not required any more.

Link: https://lore.kernel.org/r/da0c462532193b447329c4eb975a596f47e49b70.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>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/device.c