From: Jason Gunthorpe jgg@nvidia.com Sent: Friday, November 4, 2022 9:01 AM
The only way I can see to solve this is to hold a serializing lock across iommufd_access_pin_pages() so that neither iommufd_test_access_unmap() can progress until both the pin is completed and the record of the pin is stored.
same as gvt does which maintains an internal mapping cache and conducts pin/unmap with cache update under the mutex protection.
Fortunately in the iommufd design we can hold a lock like this across these calls, and in the op callback, without deadlocking. I can't recall if vfio can do the same, I suspect not since I had in my mind I needed to avoid that kind of locking for deadlock reasons..
I think so. iiuc vfio relies on driver to ensure serialization in this scenario.