On Sun, Oct 12, 2025 at 05:04:59PM -0700, Nicolin Chen wrote:
> @@ -3479,38 +3545,19 @@ int iommu_attach_device_pasid(struct iommu_domain
> *domain,
...
> - for_each_group_device(group, device) {
> - /*
> - * 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;
> - }
> - }
> +
> + ret = __iommu_domain_test_device(domain, dev, pasid, NULL);
I realized that here it needs to be under for_each_group_device,
as its following __iommu_set_group_pasid() calls attach_dev() on
every group_device. So, the new code should run a test_dev() on
every group_device to keep the consistency.
> @@ -3615,6 +3657,11 @@ int iommu_replace_device_pasid(struct iommu_domain
> *domain,
> ret = 0;
>
> if (curr_domain != domain) {
> + ret = __iommu_domain_test_device(domain, dev, pasid,
> + curr_domain);
> + if (ret)
> + goto out_unlock;
> +
> ret = __iommu_set_group_pasid(domain, group,
> pasid, curr_domain);
Needs the same fix above.
Nicolin