Skip to contentSkip to conversation

iommu: set group default domain before creating direct mappings

PATCH Applied Jerry Snitselaar 3 participants 3 messages Dec 10, 2019 – Dec 17, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: set group default domain before creating direct mappings

iommu_group_create_direct_mappings uses group->default_domain, but right after it is called, request_default_domain_for_dev calls iommu_domain_free for the default domain, and sets the group default domain to a different domain. Move the iommu_group_create_direct_mappings call to after the group default domain is set, so the direct mappings get associated with that domain.

Cc Joerg Roedel <[email protected]>
Cc Lu Baolu <[email protected]>
Fixes 7423e01741dd ("iommu: Add API to request DMA domain for device")
---
 drivers/iommu/iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/iommu.c +2 -2
index db7bfd4f2d20..fa908179b80b 100644
@@ -2282,13 +2282,13 @@ request_default_domain_for_dev(struct device *dev, unsigned long type)
 		goto out;
 	}
 
-	iommu_group_create_direct_mappings(group, dev);
-
 	/* Make the domain the default for this group */
 	if (group->default_domain)
 		iommu_domain_free(group->default_domain);
 	group->default_domain = domain;
 
+	iommu_group_create_direct_mappings(group, dev);
+
 	dev_info(dev, "Using iommu %s mapping\n",
 		 type == IOMMU_DOMAIN_DMA ? "dma" : "direct");
 
Signature · 1 line
2.24.0
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 9 lines · Jerry Snitselaar

iommu_group_create_direct_mappings uses group->default_domain, but right after it is called, request_default_domain_for_dev calls iommu_domain_free for the default domain, and sets the group default domain to a different domain. Move the iommu_group_create_direct_mappings call to after the group default domain is set, so the direct mappings get associated with that domain.

Cc Joerg Roedel <[email protected]>
Cc Lu Baolu <[email protected]>

This fix looks good to me.

Best regards,
baolu

Quoted 29 lines
Fixes 7423e01741dd ("iommu: Add API to request DMA domain for device")
---
  drivers/iommu/iommu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/iommu.c +2 -2
index db7bfd4f2d20..fa908179b80b 100644
@@ -2282,13 +2282,13 @@ request_default_domain_for_dev(struct device *dev, unsigned long type)
  		goto out;
  	}
 
-	iommu_group_create_direct_mappings(group, dev);
-
  	/* Make the domain the default for this group */
  	if (group->default_domain)
  		iommu_domain_free(group->default_domain);
  	group->default_domain = domain;
 
+	iommu_group_create_direct_mappings(group, dev);
+
  	dev_info(dev, "Using iommu %s mapping\n",
  		 type == IOMMU_DOMAIN_DMA ? "dma" : "direct");
 
Applied
#2 lore raw
Quoted 8 lines · Lu Baolu
Quoted 7 lines · Jerry Snitselaar

iommu_group_create_direct_mappings uses group->default_domain, but right after it is called, request_default_domain_for_dev calls iommu_domain_free for the default domain, and sets the group default domain to a different domain. Move the iommu_group_create_direct_mappings call to after the group default domain is set, so the direct mappings get associated with that domain.

Quoted 6 lines
Quoted 2 lines
Cc Joerg Roedel <[email protected]>
Cc Lu Baolu <[email protected]>

This fix looks good to me.

Applied, thanks.