Skip to content

Commit b18301b

Browse files
yiliu1765joergroedel
authored andcommitted
iommu: Detaching pasid by attaching to the blocked_domain
The iommu drivers are on the way to detach pasid by attaching to the blocked domain. However, this cannot be done in one shot. During the transition, iommu core would select between the remove_dev_pasid op and the blocked domain. Suggested-by: Kevin Tian <[email protected]> Suggested-by: Jason Gunthorpe <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Reviewed-by: Vasant Hegde <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Lu Baolu <[email protected]> Signed-off-by: Yi Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 1fbf734 commit b18301b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/iommu/iommu.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3316,8 +3316,18 @@ static void iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
33163316
struct iommu_domain *domain)
33173317
{
33183318
const struct iommu_ops *ops = dev_iommu_ops(dev);
3319+
struct iommu_domain *blocked_domain = ops->blocked_domain;
3320+
int ret = 1;
33193321

3320-
ops->remove_dev_pasid(dev, pasid, domain);
3322+
if (blocked_domain && blocked_domain->ops->set_dev_pasid) {
3323+
ret = blocked_domain->ops->set_dev_pasid(blocked_domain,
3324+
dev, pasid, domain);
3325+
} else {
3326+
ops->remove_dev_pasid(dev, pasid, domain);
3327+
ret = 0;
3328+
}
3329+
3330+
WARN_ON(ret);
33213331
}
33223332

33233333
static int __iommu_set_group_pasid(struct iommu_domain *domain,
@@ -3380,7 +3390,9 @@ int iommu_attach_device_pasid(struct iommu_domain *domain,
33803390
ops = dev_iommu_ops(dev);
33813391

33823392
if (!domain->ops->set_dev_pasid ||
3383-
!ops->remove_dev_pasid)
3393+
(!ops->remove_dev_pasid &&
3394+
(!ops->blocked_domain ||
3395+
!ops->blocked_domain->ops->set_dev_pasid)))
33843396
return -EOPNOTSUPP;
33853397

33863398
if (ops != domain->owner || pasid == IOMMU_NO_PASID)

0 commit comments

Comments
 (0)