Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3341,9 +3341,11 @@ static int __iommu_set_group_pasid(struct iommu_domain *domain,
int ret;

for_each_group_device(group, device) {
ret = domain->ops->set_dev_pasid(domain, device->dev, pasid);
if (ret)
goto err_revert;
if (device->dev->iommu->max_pasids > 0) {
ret = domain->ops->set_dev_pasid(domain, device->dev, pasid);
if (ret)
goto err_revert;
}
}

return 0;
Expand All @@ -3355,7 +3357,8 @@ static int __iommu_set_group_pasid(struct iommu_domain *domain,

if (device == last_gdev)
break;
ops->remove_dev_pasid(device->dev, pasid, domain);
if (device->dev->iommu->max_pasids > 0)
ops->remove_dev_pasid(device->dev, pasid, domain);
}
return ret;
}
Expand All @@ -3368,8 +3371,10 @@ static void __iommu_remove_group_pasid(struct iommu_group *group,
const struct iommu_ops *ops;

for_each_group_device(group, device) {
ops = dev_iommu_ops(device->dev);
ops->remove_dev_pasid(device->dev, pasid, domain);
if (device->dev->iommu->max_pasids > 0) {
ops = dev_iommu_ops(device->dev);
ops->remove_dev_pasid(device->dev, pasid, domain);
}
}
}

Expand Down Expand Up @@ -3403,7 +3408,13 @@ int iommu_attach_device_pasid(struct iommu_domain *domain,

mutex_lock(&group->mutex);
for_each_group_device(group, device) {
if (pasid >= device->dev->iommu->max_pasids) {
/*
* Skip PASID validation for devices without PASID support
* (max_pasids = 0). These devices cannot issue transactions
* with PASID, so they don't affect group's PASID usage.
*/
if ((device->dev->iommu->max_pasids > 0) &&
(pasid >= device->dev->iommu->max_pasids)) {
ret = -EINVAL;
goto out_unlock;
}
Expand Down