Skip to content

Commit 9bc18d2

Browse files
yiliu1765joergroedel
authored andcommitted
iommu/vt-d: Make identity_domain_set_dev_pasid() to handle domain replacement
Let identity_domain_set_dev_pasid() call the pasid replace helpers hence be able to do domain replacement. Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Link: https://lore.kernel.org/r/20241107122234.7424-11-yi.l.liu@intel.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent cfb31f1 commit 9bc18d2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,17 @@ static int domain_setup_second_level(struct intel_iommu *iommu,
17781778
pasid);
17791779
}
17801780

1781+
static int domain_setup_passthrough(struct intel_iommu *iommu,
1782+
struct device *dev, ioasid_t pasid,
1783+
struct iommu_domain *old)
1784+
{
1785+
if (!old)
1786+
return intel_pasid_setup_pass_through(iommu, dev, pasid);
1787+
return intel_pasid_replace_pass_through(iommu, dev,
1788+
iommu_domain_did(old, iommu),
1789+
pasid);
1790+
}
1791+
17811792
static int domain_setup_first_level(struct intel_iommu *iommu,
17821793
struct dmar_domain *domain,
17831794
struct device *dev,
@@ -4423,11 +4434,17 @@ static int identity_domain_set_dev_pasid(struct iommu_domain *domain,
44234434
{
44244435
struct device_domain_info *info = dev_iommu_priv_get(dev);
44254436
struct intel_iommu *iommu = info->iommu;
4437+
int ret;
44264438

44274439
if (!pasid_supported(iommu) || dev_is_real_dma_subdevice(dev))
44284440
return -EOPNOTSUPP;
44294441

4430-
return intel_pasid_setup_pass_through(iommu, dev, pasid);
4442+
ret = domain_setup_passthrough(iommu, dev, pasid, old);
4443+
if (ret)
4444+
return ret;
4445+
4446+
domain_remove_dev_pasid(old, dev, pasid);
4447+
return 0;
44314448
}
44324449

44334450
static struct iommu_domain identity_domain = {

0 commit comments

Comments
 (0)