Thread (43 messages) 43 messages, 4 authors, 2025-11-07

Re: [PATCH v1 02/20] iommu: Introduce a test_dev domain op and an internal helper

From: Nicolin Chen <hidden>
Date: 2025-10-27 23:19:03
Also in: asahi, linux-arm-msm, linux-iommu, linux-mediatek, linux-patches, linux-riscv, linux-rockchip, linux-s390, linux-sunxi, linux-tegra, lkml, virtualization

On Sun, Oct 12, 2025 at 05:04:59PM -0700, Nicolin Chen wrote:
quoted hunk ↗ jump to hunk
@@ -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.
quoted hunk ↗ jump to hunk
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help