[Intel-gfx] [PATCH v7 16/22] iommufd/device: Add iommufd_access_detach() API
Tian, Kevin
kevin.tian at intel.com
Fri Mar 17 02:10:37 UTC 2023
> From: Liu, Yi L <yi.l.liu at intel.com>
> Sent: Thursday, March 16, 2023 8:55 PM
>
> From: Nicolin Chen <nicolinc at nvidia.com>
>
> Previously, the detach routine is only done by the destroy(). And it was
> called by vfio_iommufd_emulated_unbind() when the device runs close(), so
> all the mappings in iopt were cleaned in that setup, when the call trace
> reaches this detach() routine.
>
> Now, there's a need of a detach uAPI, meaning that it does not only need
> a new iommufd_access_detach() API, but also requires access->ops->unmap()
> call as a cleanup. So add one.
>
> However, leaving that unprotected can introduce some potential of a race
> condition during the pin_/unpin_pages() call, where access->ioas->iopt is
> getting referenced. So, add an ioas_lock to protect the context of iopt
> referencings.
>
> Also, to allow the iommufd_access_unpin_pages() callback to happen via
> this unmap() call, add an ioas_unpin pointer, so the unpin routine won't
> be affected by the "access->ioas = NULL" trick.
>
> Signed-off-by: Nicolin Chen <nicolinc at nvidia.com>
> Signed-off-by: Yi Liu <yi.l.liu at intel.com>
Reviewed-by: Kevin Tian <kevin.tian at intel.com>
More information about the Intel-gfx
mailing list