Skip to content

Commit b142743

Browse files
committed
Merge tag 'iommu-fixes-v6.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux
Pull iommu fix from Joerg Roedel: - core: skip PASID validation for devices without PASID support * tag 'iommu-fixes-v6.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux: iommu: Skip PASID validation for devices without PASID capability
2 parents 4856ebd + b3f6fcd commit b142743

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

drivers/iommu/iommu.c

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,10 +3366,12 @@ static int __iommu_set_group_pasid(struct iommu_domain *domain,
33663366
int ret;
33673367

33683368
for_each_group_device(group, device) {
3369-
ret = domain->ops->set_dev_pasid(domain, device->dev,
3370-
pasid, old);
3371-
if (ret)
3372-
goto err_revert;
3369+
if (device->dev->iommu->max_pasids > 0) {
3370+
ret = domain->ops->set_dev_pasid(domain, device->dev,
3371+
pasid, old);
3372+
if (ret)
3373+
goto err_revert;
3374+
}
33733375
}
33743376

33753377
return 0;
@@ -3379,15 +3381,18 @@ static int __iommu_set_group_pasid(struct iommu_domain *domain,
33793381
for_each_group_device(group, device) {
33803382
if (device == last_gdev)
33813383
break;
3382-
/*
3383-
* If no old domain, undo the succeeded devices/pasid.
3384-
* Otherwise, rollback the succeeded devices/pasid to the old
3385-
* domain. And it is a driver bug to fail attaching with a
3386-
* previously good domain.
3387-
*/
3388-
if (!old || WARN_ON(old->ops->set_dev_pasid(old, device->dev,
3384+
if (device->dev->iommu->max_pasids > 0) {
3385+
/*
3386+
* If no old domain, undo the succeeded devices/pasid.
3387+
* Otherwise, rollback the succeeded devices/pasid to
3388+
* the old domain. And it is a driver bug to fail
3389+
* attaching with a previously good domain.
3390+
*/
3391+
if (!old ||
3392+
WARN_ON(old->ops->set_dev_pasid(old, device->dev,
33893393
pasid, domain)))
3390-
iommu_remove_dev_pasid(device->dev, pasid, domain);
3394+
iommu_remove_dev_pasid(device->dev, pasid, domain);
3395+
}
33913396
}
33923397
return ret;
33933398
}
@@ -3398,8 +3403,10 @@ static void __iommu_remove_group_pasid(struct iommu_group *group,
33983403
{
33993404
struct group_device *device;
34003405

3401-
for_each_group_device(group, device)
3402-
iommu_remove_dev_pasid(device->dev, pasid, domain);
3406+
for_each_group_device(group, device) {
3407+
if (device->dev->iommu->max_pasids > 0)
3408+
iommu_remove_dev_pasid(device->dev, pasid, domain);
3409+
}
34033410
}
34043411

34053412
/*
@@ -3440,7 +3447,13 @@ int iommu_attach_device_pasid(struct iommu_domain *domain,
34403447

34413448
mutex_lock(&group->mutex);
34423449
for_each_group_device(group, device) {
3443-
if (pasid >= device->dev->iommu->max_pasids) {
3450+
/*
3451+
* Skip PASID validation for devices without PASID support
3452+
* (max_pasids = 0). These devices cannot issue transactions
3453+
* with PASID, so they don't affect group's PASID usage.
3454+
*/
3455+
if ((device->dev->iommu->max_pasids > 0) &&
3456+
(pasid >= device->dev->iommu->max_pasids)) {
34443457
ret = -EINVAL;
34453458
goto out_unlock;
34463459
}

0 commit comments

Comments
 (0)