On Wed, Mar 27, 2024 at 05:54:32AM -0700, Yi Liu wrote: > Existing remove_dev_pasid() callbacks of the underlying iommu drivers get > the attached domain from the group->pasid_array. However, the domains > stored in group->pasid_array are not always correct. For example, the > set_dev_pasid() path updates group->pasid_array first and then invoke > remove_dev_pasid() callback when error happened. The remove_dev_pasid() > callback would get the updated domain. This is not correct for the > devices that are still attached with an old domain or just no attached > domain. > > To avoid the above problem, passing the attached domain to the > remove_dev_pasid() callback is more reliable. I've relaized we have the same issue with set_dev_pasid, there is no way for the driver to get the old domain since the xarray was updated before calling set_dev_pasid. This is unlike the RID path. Meaning drivers can't implement PASID replace. So we need another patch to pass the old domain into set_dev_pasid too... This looks fine Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Jason