Commit 6384c56c authored by Zhangfei Gao's avatar Zhangfei Gao Committed by Joerg Roedel

iommu/sva: Fix SVA handle sharing in multi device case

iommu_sva_bind_device will directly goto out in multi-device
case when found existing domain, ignoring list_add handle,
which causes the handle to fail to be shared.

Fixes: 65d4418c ("iommu/sva: Restore SVA handle sharing")
Signed-off-by: default avatarZhangfei Gao <zhangfei.gao@linaro.org>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20240227064821.128-1-zhangfei.gao@linaro.orgSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent d206a76d
...@@ -117,11 +117,11 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm ...@@ -117,11 +117,11 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm
if (ret) if (ret)
goto out_free_domain; goto out_free_domain;
domain->users = 1; domain->users = 1;
refcount_set(&handle->users, 1);
list_add(&domain->next, &mm->iommu_mm->sva_domains); list_add(&domain->next, &mm->iommu_mm->sva_domains);
list_add(&handle->handle_item, &mm->iommu_mm->sva_handles);
out: out:
refcount_set(&handle->users, 1);
list_add(&handle->handle_item, &mm->iommu_mm->sva_handles);
mutex_unlock(&iommu_sva_lock); mutex_unlock(&iommu_sva_lock);
handle->dev = dev; handle->dev = dev;
handle->domain = domain; handle->domain = domain;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment