Skip to contentSkip to conversation

iommu/vt-d: Fix kdump boot with VT-d enabled

PATCH In review Joerg Roedel 5 participants 19 messages Feb 17, 2020 – Feb 19, 2020 IOMMU

lore
Share & tools
lore
author maintainer
#5 lore raw

PATCH 2/5 iommu/vt-d: Move deferred device attachment into helper function

In reply to Joerg Roedel

From: Joerg Roedel <[email protected]>

Move the code that does the deferred device attachment into a separate helper function.

---
 drivers/iommu/intel-iommu.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/iommu/intel-iommu.c +12 -8
index 80f2332a5466..42cdcce1602e 100644
@@ -2529,16 +2529,20 @@ struct dmar_domain *find_domain(struct device *dev)
 	return NULL;
 }
 
-static struct dmar_domain *deferred_attach_domain(struct device *dev)
+static void do_deferred_attach(struct device *dev)
 {
-	if (unlikely(attach_deferred(dev))) {
-		struct iommu_domain *domain;
+	struct iommu_domain *domain;
 
-		dev->archdata.iommu = NULL;
-		domain = iommu_get_domain_for_dev(dev);
-		if (domain)
-			intel_iommu_attach_device(domain, dev);
-	}
+	dev->archdata.iommu = NULL;
+	domain = iommu_get_domain_for_dev(dev);
+	if (domain)
+		intel_iommu_attach_device(domain, dev);
+}
+
+static struct dmar_domain *deferred_attach_domain(struct device *dev)
+{
+	if (unlikely(attach_deferred(dev)))
+		do_deferred_attach(dev);
 
 	return find_domain(dev);
 }
Signature · 1 line
2.17.1

Joerg Roedel

author maintainer
#0 lore raw

cover iommu/vt-d: Fix kdump boot with VT-d enabled

Hi,

booting into a crashdump kernel with Intel IOMMU enabled and configured into passthrough mode does not succeed with the current kernel. The reason is that the check for identity mappings happen before the check for deferred device attachments. That results in wrong results returned from iommu_need_mapping() and subsequently in a wrong domain-type used in __intel_map_single(). A stripped oops is in the commit-message of patch 3.

The patch-set fixes the issue and does a few code cleanups along the way. I have not yet researched the stable and fixes tags, but when the patches are fine I will add the tags before applying the patches.

Please review.

Thanks,

Joerg

Joerg Roedel (5):
iommu/vt-d: Add attach_deferred() helper
iommu/vt-d: Move deferred device attachment into helper function iommu/vt-d: Do deferred attachment in iommu_need_mapping() iommu/vt-d: Remove deferred_attach_domain() iommu/vt-d: Simplify check in identity_mapping()

 drivers/iommu/intel-iommu.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
author maintainer
#15 lore raw

PATCH 4/5 iommu/vt-d: Remove deferred_attach_domain()

From: Joerg Roedel <[email protected]>

The function is now only a wrapper around find_domain(). Remove the function and call find_domain() directly at the call-sites.

---
 drivers/iommu/intel-iommu.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/iommu/intel-iommu.c +3 -8
index 32f43695a22b..16e47ca505eb 100644
@@ -2539,11 +2539,6 @@ static void do_deferred_attach(struct device *dev)
 		intel_iommu_attach_device(domain, dev);
 }
 
-static struct dmar_domain *deferred_attach_domain(struct device *dev)
-{
-	return find_domain(dev);
-}
-
 static inline struct device_domain_info *
 dmar_search_domain_by_dev_info(int segment, int bus, int devfn)
 {
@@ -3643,7 +3638,7 @@ static dma_addr_t __intel_map_single(struct device *dev, phys_addr_t paddr,
 
 	BUG_ON(dir == DMA_NONE);
 
-	domain = deferred_attach_domain(dev);
+	domain = find_domain(dev);
 	if (!domain)
 		return DMA_MAPPING_ERROR;
 
@@ -3863,7 +3858,7 @@ static int intel_map_sg(struct device *dev, struct scatterlist *sglist, int nele
 	if (!iommu_need_mapping(dev))
 		return dma_direct_map_sg(dev, sglist, nelems, dir, attrs);
 
-	domain = deferred_attach_domain(dev);
+	domain = find_domain(dev);
 	if (!domain)
 		return 0;
 
@@ -3958,7 +3953,7 @@ bounce_map_single(struct device *dev, phys_addr_t paddr, size_t size,
 	int prot = 0;
 	int ret;
 
-	domain = deferred_attach_domain(dev);
+	domain = find_domain(dev);
 	if (WARN_ON(dir == DMA_NONE || !domain))
 		return DMA_MAPPING_ERROR;
 
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
author maintainer
#8 lore raw

PATCH 3/5 iommu/vt-d: Do deferred attachment in iommu_need_mapping()

In reply to Joerg Roedel

From: Joerg Roedel <[email protected]>

The attachment of deferred devices needs to happen before the check whether the device is identity mapped or not. Otherwise the check will return wrong results, cause warnings boot failures in kdump kernels, like

	WARNING: CPU: 0 PID: 318 at ../drivers/iommu/intel-iommu.c:592 domain_get_iommu+0x61/0x70
	[...]

	 Call Trace:
	  __intel_map_single+0x55/0x190
	  intel_alloc_coherent+0xac/0x110
	  dmam_alloc_attrs+0x50/0xa0
	  ahci_port_start+0xfb/0x1f0 [libahci]
	  ata_host_start.part.39+0x104/0x1e0 [libata]

With the earlier check the kdump boot succeeds and a crashdump is written.

---
 drivers/iommu/intel-iommu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/intel-iommu.c +3 -3
index 42cdcce1602e..32f43695a22b 100644
@@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev)
 
 static struct dmar_domain *deferred_attach_domain(struct device *dev)
 {
-	if (unlikely(attach_deferred(dev)))
-		do_deferred_attach(dev);
-
 	return find_domain(dev);
 }
 
@@ -3595,6 +3592,9 @@ static bool iommu_need_mapping(struct device *dev)
 	if (iommu_dummy(dev))
 		return false;
 
+	if (unlikely(attach_deferred(dev)))
+		do_deferred_attach(dev);
+
 	ret = identity_mapping(dev);
 	if (ret) {
 		u64 dma_mask = *dev->dma_mask;
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
author maintainer
#17 lore raw

PATCH 5/5 iommu/vt-d: Simplify check in identity_mapping()

In reply to Joerg Roedel

From: Joerg Roedel <[email protected]>

The function only has one call-site and there it is never called with dummy or deferred devices. Simplify the check in the function to account for that.

---
 drivers/iommu/intel-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +1 -1
index 16e47ca505eb..0b5a0fadbc0c 100644
@@ -2916,7 +2916,7 @@ static int identity_mapping(struct device *dev)
 	struct device_domain_info *info;
 
 	info = dev->archdata.iommu;
-	if (info && info != DUMMY_DEVICE_DOMAIN_INFO && info != DEFER_DEVICE_DOMAIN_INFO)
+	if (info)
 		return (info->domain == si_domain);
 
 	return 0;
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH 1/5 iommu/vt-d: Add attach_deferred() helper

In reply to Joerg Roedel

From: Joerg Roedel <[email protected]>

Implement a helper function to check whether a device's attach process is deferred.

---
 drivers/iommu/intel-iommu.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/iommu/intel-iommu.c +8 -4
index 9dc37672bf89..80f2332a5466 100644
@@ -762,6 +762,11 @@ static int iommu_dummy(struct device *dev)
 	return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
 }
 
+static bool attach_deferred(struct device *dev)
+{
+	return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
+}
+
 /**
  * is_downstream_to_pci_bridge - test if a device belongs to the PCI
  *				 sub-hierarchy of a candidate PCI-PCI bridge
@@ -2510,8 +2515,7 @@ struct dmar_domain *find_domain(struct device *dev)
 {
 	struct device_domain_info *info;
 
-	if (unlikely(dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO ||
-		     dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO))
+	if (unlikely(attach_deferred(dev) || iommu_dummy(dev)))
 		return NULL;
 
 	if (dev_is_pci(dev))
@@ -2527,7 +2531,7 @@ struct dmar_domain *find_domain(struct device *dev)
 
 static struct dmar_domain *deferred_attach_domain(struct device *dev)
 {
-	if (unlikely(dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO)) {
+	if (unlikely(attach_deferred(dev))) {
 		struct iommu_domain *domain;
 
 		dev->archdata.iommu = NULL;
@@ -6133,7 +6137,7 @@ intel_iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev)
 static bool intel_iommu_is_attach_deferred(struct iommu_domain *domain,
 					   struct device *dev)
 {
-	return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
+	return attach_deferred(dev);
 }
 
 static int
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] iommu/vt-d: Add attach_deferred() helper

Quoted 6 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

Implement a helper function to check whether a device's attach process is deferred.

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reviewed-by on v1 3/5
#9 lore raw

Re: [PATCH 3/5] iommu/vt-d: Do deferred attachment in iommu_need_mapping()

In reply to Joerg Roedel
Quoted 17 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

The attachment of deferred devices needs to happen before the check whether the device is identity mapped or not. Otherwise the check will return wrong results, cause warnings boot failures in kdump kernels, like

	WARNING: CPU: 0 PID: 318 at ../drivers/iommu/intel-iommu.c:592 domain_get_iommu+0x61/0x70
	[...]

	 Call Trace:
	  __intel_map_single+0x55/0x190
	  intel_alloc_coherent+0xac/0x110
	  dmam_alloc_attrs+0x50/0xa0
	  ahci_port_start+0xfb/0x1f0 [libahci]
	  ata_host_start.part.39+0x104/0x1e0 [libata]
Quoted 3 lines

With the earlier check the kdump boot succeeds and a crashdump is written.

#10 lore raw

Re: [PATCH 3/5] iommu/vt-d: Do deferred attachment in iommu_need_mapping()

In reply to Joerg Roedel

Hi Joerg,

Thanks for doing this.

Quoted 29 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

The attachment of deferred devices needs to happen before the check whether the device is identity mapped or not. Otherwise the check will return wrong results, cause warnings boot failures in kdump kernels, like

	WARNING: CPU: 0 PID: 318 at ../drivers/iommu/intel-iommu.c:592 domain_get_iommu+0x61/0x70
	[...]

	 Call Trace:
	  __intel_map_single+0x55/0x190
	  intel_alloc_coherent+0xac/0x110
	  dmam_alloc_attrs+0x50/0xa0
	  ahci_port_start+0xfb/0x1f0 [libahci]
	  ata_host_start.part.39+0x104/0x1e0 [libata]

With the earlier check the kdump boot succeeds and a crashdump is written.

---
  drivers/iommu/intel-iommu.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/intel-iommu.c +0 -0
index 42cdcce1602e..32f43695a22b 100644

drivers/iommu/intel-iommu.c static void do_deferred_attach(struct device *dev) · line 2546

Quoted 6 lines
drivers/iommu/intel-iommu.c +0 -3
@@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev)
 
  static struct dmar_domain *deferred_attach_domain(struct device *dev)
  {
-	if (unlikely(attach_deferred(dev)))
-		do_deferred_attach(dev);
-

This should also be moved to the call place of deferred_attach_domain() in bounce_map_single().

bounce_map_single() assumes that devices always use DMA domain, so it doesn't call iommu_need_mapping(). We could do_deferred_attach() there manually.

Best regards,
baolu

Quoted 5 lines
drivers/iommu/intel-iommu.c +0 -0
  	return find_domain(dev);
  }
 

drivers/iommu/intel-iommu.c static bool iommu_need_mapping(struct device *dev) · line 3600

Quoted 9 lines
drivers/iommu/intel-iommu.c +3 -0
@@ -3595,6 +3592,9 @@ static bool iommu_need_mapping(struct device *dev)
  	if (iommu_dummy(dev))
  		return false;
 
+	if (unlikely(attach_deferred(dev)))
+		do_deferred_attach(dev);
+
  	ret = identity_mapping(dev);
  	if (ret) {
  		u64 dma_mask = *dev->dma_mask;

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#11 lore raw

PATCH v2 3/5 iommu/vt-d: Do deferred attachment in iommu_need_mapping()

Hi Baolu,

Quoted 14 lines · Lu Baolu

drivers/iommu/intel-iommu.c static void do_deferred_attach(struct device *dev) · line 2545

Quoted 10 lines
drivers/iommu/intel-iommu.c +0 -3
index 42cdcce1602e..32f43695a22b 100644
@@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev)
  static struct dmar_domain *deferred_attach_domain(struct device *dev)
  {
-	if (unlikely(attach_deferred(dev)))
-		do_deferred_attach(dev);
-

This should also be moved to the call place of deferred_attach_domain() in bounce_map_single().

Quoted 3 lines

bounce_map_single() assumes that devices always use DMA domain, so it doesn't call iommu_need_mapping(). We could do_deferred_attach() there manually.

Good point, thanks for your review. Updated patch below.

From 3a5b8a66d288d86ac1fd45092e7d96f842d0cccf Mon Sep 17 00:00:00 2001
From: Joerg Roedel <[email protected]>
Date: Mon, 17 Feb 2020 17:20:59 +0100
Subject: [PATCH 3/5] iommu/vt-d: Do deferred attachment in
iommu_need_mapping()

The attachment of deferred devices needs to happen before the check whether the device is identity mapped or not. Otherwise the check will return wrong results, cause warnings boot failures in kdump kernels, like

	WARNING: CPU: 0 PID: 318 at ../drivers/iommu/intel-iommu.c:592 domain_get_iommu+0x61/0x70
	[...]

	 Call Trace:
	  __intel_map_single+0x55/0x190
	  intel_alloc_coherent+0xac/0x110
	  dmam_alloc_attrs+0x50/0xa0
	  ahci_port_start+0xfb/0x1f0 [libahci]
	  ata_host_start.part.39+0x104/0x1e0 [libata]

With the earlier check the kdump boot succeeds and a crashdump is written.

---
 drivers/iommu/intel-iommu.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/iommu/intel-iommu.c +7 -3
index 42cdcce1602e..723f615c6e84 100644
@@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev)
 
 static struct dmar_domain *deferred_attach_domain(struct device *dev)
 {
-	if (unlikely(attach_deferred(dev)))
-		do_deferred_attach(dev);
-
 	return find_domain(dev);
 }
 
@@ -3595,6 +3592,9 @@ static bool iommu_need_mapping(struct device *dev)
 	if (iommu_dummy(dev))
 		return false;
 
+	if (unlikely(attach_deferred(dev)))
+		do_deferred_attach(dev);
+
 	ret = identity_mapping(dev);
 	if (ret) {
 		u64 dma_mask = *dev->dma_mask;
@@ -3958,7 +3958,11 @@ bounce_map_single(struct device *dev, phys_addr_t paddr, size_t size,
 	int prot = 0;
 	int ret;
 
+	if (unlikely(attach_deferred(dev)))
+		do_deferred_attach(dev);
+
 	domain = deferred_attach_domain(dev);
+
 	if (WARN_ON(dir == DMA_NONE || !domain))
 		return DMA_MAPPING_ERROR;
 
Signature · 1 line
2.25.0
Acked-by on v2 3/5
#12 lore raw

Re: [PATCH 3/5 v2] iommu/vt-d: Do deferred attachment in iommu_need_mapping()

Hi Joerg,

Quoted 17 lines · Joerg Roedel

Hi Baolu,

Quoted 14 lines · Lu Baolu

drivers/iommu/intel-iommu.c static void do_deferred_attach(struct device *dev) · line 2545

Quoted 10 lines
drivers/iommu/intel-iommu.c +0 -3
index 42cdcce1602e..32f43695a22b 100644
@@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev)
   static struct dmar_domain *deferred_attach_domain(struct device *dev)
   {
-	if (unlikely(attach_deferred(dev)))
-		do_deferred_attach(dev);
-

This should also be moved to the call place of deferred_attach_domain() in bounce_map_single().

Quoted 6 lines
Quoted 3 lines

bounce_map_single() assumes that devices always use DMA domain, so it doesn't call iommu_need_mapping(). We could do_deferred_attach() there manually.

Good point, thanks for your review. Updated patch below.

Looks good to me now. For all patches in this series,

Best regards,
baolu

Quoted 65 lines

From 3a5b8a66d288d86ac1fd45092e7d96f842d0cccf Mon Sep 17 00:00:00 2001
From: Joerg Roedel <[email protected]>
Date: Mon, 17 Feb 2020 17:20:59 +0100
Subject: [PATCH 3/5] iommu/vt-d: Do deferred attachment in
iommu_need_mapping()

The attachment of deferred devices needs to happen before the check whether the device is identity mapped or not. Otherwise the check will return wrong results, cause warnings boot failures in kdump kernels, like

	WARNING: CPU: 0 PID: 318 at ../drivers/iommu/intel-iommu.c:592 domain_get_iommu+0x61/0x70
	[...]

	 Call Trace:
	  __intel_map_single+0x55/0x190
	  intel_alloc_coherent+0xac/0x110
	  dmam_alloc_attrs+0x50/0xa0
	  ahci_port_start+0xfb/0x1f0 [libahci]
	  ata_host_start.part.39+0x104/0x1e0 [libata]

With the earlier check the kdump boot succeeds and a crashdump is written.

---
  drivers/iommu/intel-iommu.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/iommu/intel-iommu.c +7 -3
index 42cdcce1602e..723f615c6e84 100644
@@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev)
 
  static struct dmar_domain *deferred_attach_domain(struct device *dev)
  {
-	if (unlikely(attach_deferred(dev)))
-		do_deferred_attach(dev);
-
  	return find_domain(dev);
  }
 
@@ -3595,6 +3592,9 @@ static bool iommu_need_mapping(struct device *dev)
  	if (iommu_dummy(dev))
  		return false;
 
+	if (unlikely(attach_deferred(dev)))
+		do_deferred_attach(dev);
+
  	ret = identity_mapping(dev);
  	if (ret) {
  		u64 dma_mask = *dev->dma_mask;
@@ -3958,7 +3958,11 @@ bounce_map_single(struct device *dev, phys_addr_t paddr, size_t size,
  	int prot = 0;
  	int ret;
 
+	if (unlikely(attach_deferred(dev)))
+		do_deferred_attach(dev);
+
  	domain = deferred_attach_domain(dev);
+
  	if (WARN_ON(dir == DMA_NONE || !domain))
  		return DMA_MAPPING_ERROR;
 
Reviewed-by on v2 3/5
#14 lore raw

Re: [PATCH 3/5 v2] iommu/vt-d: Do deferred attachment in iommu_need_mapping()

In reply to Joerg Roedel
Quoted 44 lines · Joerg Roedel

Hi Baolu,

Quoted 14 lines · Lu Baolu

drivers/iommu/intel-iommu.c static void do_deferred_attach(struct device *dev) · line 2545

Quoted 10 lines
drivers/iommu/intel-iommu.c +0 -3
index 42cdcce1602e..32f43695a22b 100644
@@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev)
  static struct dmar_domain *deferred_attach_domain(struct device *dev)
  {
-	if (unlikely(attach_deferred(dev)))
-		do_deferred_attach(dev);
-

This should also be moved to the call place of deferred_attach_domain() in bounce_map_single().

Quoted 3 lines

bounce_map_single() assumes that devices always use DMA domain, so it doesn't call iommu_need_mapping(). We could do_deferred_attach() there manually.

Good point, thanks for your review. Updated patch below.

From 3a5b8a66d288d86ac1fd45092e7d96f842d0cccf Mon Sep 17 00:00:00 2001
From: Joerg Roedel <[email protected]>
Date: Mon, 17 Feb 2020 17:20:59 +0100
Subject: [PATCH 3/5] iommu/vt-d: Do deferred attachment in iommu_need_mapping()

The attachment of deferred devices needs to happen before the check whether the device is identity mapped or not. Otherwise the check will return wrong results, cause warnings boot failures in kdump kernels, like

	WARNING: CPU: 0 PID: 318 at ../drivers/iommu/intel-iommu.c:592 domain_get_iommu+0x61/0x70
	[...]

	 Call Trace:
	  __intel_map_single+0x55/0x190
	  intel_alloc_coherent+0xac/0x110
	  dmam_alloc_attrs+0x50/0xa0
	  ahci_port_start+0xfb/0x1f0 [libahci]
	  ata_host_start.part.39+0x104/0x1e0 [libata]
Quoted 3 lines

With the earlier check the kdump boot succeeds and a crashdump is written.

#3 lore raw

Re: [PATCH 1/5] iommu/vt-d: Add attach_deferred() helper

In reply to Joerg Roedel

drivers/iommu/intel-iommu.c static int iommu_dummy(struct device *dev) · line 768

Quoted 4 lines
drivers/iommu/intel-iommu.c +4 -0
+static bool attach_deferred(struct device *dev)
+{
+	return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
+}

This is not a very useful helper.

drivers/iommu/intel-iommu.c struct dmar_domain *find_domain(struct device *dev) · line 2519

Quoted 12 lines
drivers/iommu/intel-iommu.c +2 -2
+
 /**
  * is_downstream_to_pci_bridge - test if a device belongs to the PCI
  *				 sub-hierarchy of a candidate PCI-PCI bridge
@@ -2510,8 +2515,7 @@ struct dmar_domain *find_domain(struct device *dev)
 {
 	struct device_domain_info *info;
 
-	if (unlikely(dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO ||
-		     dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO))
+	if (unlikely(attach_deferred(dev) || iommu_dummy(dev)))
 		return NULL;

I'd rather kill the iommu_dummy helper as well. And IIRC I have an outstanding series somewhere that does just that..
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#7 lore raw

Re: [PATCH 2/5] iommu/vt-d: Move deferred device attachment into helper function

In reply to Joerg Roedel
Quoted 7 lines
drivers/iommu/intel-iommu.c +5 -0
+static void do_deferred_attach(struct device *dev)
 {
+	struct iommu_domain *domain;
 
+	dev->archdata.iommu = NULL;
+	domain = iommu_get_domain_for_dev(dev);
+	if (domain)

drivers/iommu/intel-iommu.c struct dmar_domain *find_domain(struct device *dev) · line 2548

Quoted 10 lines
drivers/iommu/intel-iommu.c +7 -0
+		intel_iommu_attach_device(domain, dev);
+}
+
+static struct dmar_domain *deferred_attach_domain(struct device *dev)
+{
+	if (unlikely(attach_deferred(dev)))
+		do_deferred_attach(dev);
 
 	return find_domain(dev);
 }

Can we start using proper sybmbol prefixes and avoid do_* names where possible?

#4 lore raw

Re: [PATCH 1/5] iommu/vt-d: Add attach_deferred() helper

In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig

drivers/iommu/intel-iommu.c static int iommu_dummy(struct device *dev) · line 768

Quoted 4 lines
drivers/iommu/intel-iommu.c +4 -0
+static bool attach_deferred(struct device *dev)
+{
+	return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
+}

This is not a very useful helper.

Depends on what one considers useful. I think such helpers make the code better readable, which is pretty useful to me.

Regards,

Joerg