Skip to contentSkip to conversation

iommu: return early when devices in a group require different domain type

PATCH Superseded Yuan Can 3 participants 3 messages Aug 16, 2022 – Aug 17, 2022 IOMMU

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yuan Can

author
#0 lore raw

PATCH 1/1 iommu: return early when devices in a group require different domain type

When alloc default domain for an iommu_group in probe_alloc_default_domain, the expected domain type of each device in the iommu_group is checked in a loop, if two devices require different types, the loop can be breaked since the default domain will be set to iommu_def_domain_type. Return 1 when this happened to break the loop in __iommu_group_for_each_dev.

---
 drivers/iommu/iommu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/iommu.c +1 -0
index 74bc9111c7be..0d4d78946d31 100644
@@ -1653,6 +1653,7 @@ static int probe_get_default_domain_type(struct device *dev, void *data)
 				 dev_name(gtype->dev),
 				 iommu_domain_type_str(gtype->type));
 			gtype->type = 0;
+			return 1; /* end the outer loop */
 		}
 
 		if (!gtype->dev) {
Signature · 1 line
2.17.1
#1 lore raw

Yuan,

Quoted 5 lines · Yuan Can

When alloc default domain for an iommu_group in probe_alloc_default_domain, the expected domain type of each device in the iommu_group is checked in a loop, if two devices require different types, the loop can be breaked since the default domain

s/breaked/broken

Quoted 14 lines

will be set to iommu_def_domain_type. Return 1 when this happened to break the loop in __iommu_group_for_each_dev.

---
  drivers/iommu/iommu.c | 1 +
  1 file changed, 1 insertion(+)
drivers/iommu/iommu.c +0 -0
index 74bc9111c7be..0d4d78946d31 100644

drivers/iommu/iommu.c static int probe_get_default_domain_type(struct device *dev, void *data) · line 1659

Quoted 7 lines
drivers/iommu/iommu.c +1 -0
@@ -1653,6 +1653,7 @@ static int probe_get_default_domain_type(struct device *dev, void *data)
  				 dev_name(gtype->dev),
  				 iommu_domain_type_str(gtype->type));
  			gtype->type = 0;
+			return 1; /* end the outer loop */
  		}
 
  		if (!gtype->dev) {

Thanks,

Ethan

Signature · 1 line
"firm, enduring, strong, and long-lived"
Reviewed-by on v1 1/1
#2 lore raw
In reply to Yuan Can
Quoted 10 lines · Yuan Can

When alloc default domain for an iommu_group in probe_alloc_default_domain, the expected domain type of each device in the iommu_group is checked in a loop, if two devices require different types, the loop can be breaked since the default domain will be set to iommu_def_domain_type. Return 1 when this happened to break the loop in __iommu_group_for_each_dev.

Nit:
Try to use up the allowed number of characters per line before wrapping and use "./scripts/checkpatch.pl --strict --codespell _your_patch_file" to check the patch.

For the change:

Best regards,
baolu

Quoted 16 lines
---
  drivers/iommu/iommu.c | 1 +
  1 file changed, 1 insertion(+)
drivers/iommu/iommu.c +1 -0
index 74bc9111c7be..0d4d78946d31 100644
@@ -1653,6 +1653,7 @@ static int probe_get_default_domain_type(struct device *dev, void *data)
  				 dev_name(gtype->dev),
  				 iommu_domain_type_str(gtype->type));
  			gtype->type = 0;
+			return 1; /* end the outer loop */
  		}
 
  		if (!gtype->dev) {