Skip to contentSkip to conversation

intel-iommu: PCIe hot plug for Intel iommu - IOMMU API

PATCH NAK Fenghua Yu 2 participants 2 messages Oct 2, 2009 – Oct 5, 2009 3 messages not in the archive PCI

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): A6AD88C3F2289247BE726C37303E1EB8BC06E356@orsmsx505.amr.corp.intel.com

A message that is not in the archive (sent off-list or not yet received): 715D42877B251141A38726ABF5CABF2C05505A7433@pdsmsx503.ccr.corp.intel.com

A message that is not in the archive (sent off-list or not yet received): C2866F9FC4CB034EB51A633DF168598605E2D2EE@ssbarcelone

Fenghua Yu

author
#3 lore raw

PATCH 1/2 intel-iommu: PCIe hot plug for Intel iommu - IOMMU API

We expand existing IOMMU API iommu_detach_device for PCIe hot remove. We don't need IOMMU API for hot add.

---

 drivers/pci/intel-iommu.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletion(-)
drivers/pci/intel-iommu.c +12 -1
index 855dd7c..5c12283 100644
@@ -3559,9 +3559,20 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
 static void intel_iommu_detach_device(struct iommu_domain *domain,
 				      struct device *dev)
 {
-	struct dmar_domain *dmar_domain = domain->priv;
+	struct dmar_domain *dmar_domain;
 	struct pci_dev *pdev = to_pci_dev(dev);
 
+	/* If domain=NULL, we'll find a valid domain for the device.*/
+	if (!domain) {
+		dmar_domain = find_domain(pdev);
+		if (!dmar_domain) {
+			printk(KERN_ERR "Can not find IOMMU domain for %s\n",
+			       pci_name(pdev));
+			return;
+		}
+	} else
+		dmar_domain = domain->priv;
+
 	domain_remove_one_dev_info(dmar_domain, pdev);
 }
 
#4 lore raw
Quoted 2 lines · Fenghua Yu

We expand existing IOMMU API iommu_detach_device for PCIe hot remove. We don't need IOMMU API for hot add.

I think this could do with more explanation. A hot remove will cause detach_device() to be called with a NULL domain parameter? Surely we shouldn't be printing an error with KERN_ERR just because such a device hasn't been used for DMA before it was removed?

Quoted 32 lines

---

 drivers/pci/intel-iommu.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletion(-)
drivers/pci/intel-iommu.c +12 -1
index 855dd7c..5c12283 100644
@@ -3559,9 +3559,20 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
 static void intel_iommu_detach_device(struct iommu_domain *domain,
 				      struct device *dev)
 {
-	struct dmar_domain *dmar_domain = domain->priv;
+	struct dmar_domain *dmar_domain;
 	struct pci_dev *pdev = to_pci_dev(dev);
 
+	/* If domain=NULL, we'll find a valid domain for the device.*/
+	if (!domain) {
+		dmar_domain = find_domain(pdev);
+		if (!dmar_domain) {
+			printk(KERN_ERR "Can not find IOMMU domain for %s\n",
+			       pci_name(pdev));
+			return;
+		}
+	} else
+		dmar_domain = domain->priv;
+
 	domain_remove_one_dev_info(dmar_domain, pdev);
 }
 
Signature · 1 line
dwmw2