[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] passthrough: re-attempt ACS and ATS enabling when devices get reported by Dom0



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1320238385 -3600
# Node ID 119bccb1cc5eee1364bbbd3bd1a30f22e9db703a
# Parent  6da8953b7a902f9ea186bffdc169b9e0e97c277d
passthrough: re-attempt ACS and ATS enabling when devices get reported by Dom0

Since extended config space accesses may not be possible when
scan_pci_devices() runs (due to MMCFG resources not being reserved in
the E820 table, which the specification allows to be the case),
functionality enabling of which requires such must be re-attempted
when it is known whether MMCFG is safe to use.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: "Kay, Allen M" <allen.m.kay@xxxxxxxxx>
---


diff -r 6da8953b7a90 -r 119bccb1cc5e xen/drivers/passthrough/iommu.c
--- a/xen/drivers/passthrough/iommu.c   Wed Nov 02 13:51:28 2011 +0100
+++ b/xen/drivers/passthrough/iommu.c   Wed Nov 02 13:53:05 2011 +0100
@@ -150,6 +150,23 @@
     return hd->platform_ops->add_device(pdev);
 }
 
+int iommu_enable_device(struct pci_dev *pdev)
+{
+    struct hvm_iommu *hd;
+
+    if ( !pdev->domain )
+        return -EINVAL;
+
+    ASSERT(spin_is_locked(&pcidevs_lock));
+
+    hd = domain_hvm_iommu(pdev->domain);
+    if ( !iommu_enabled || !hd->platform_ops ||
+         !hd->platform_ops->enable_device )
+        return 0;
+
+    return hd->platform_ops->enable_device(pdev);
+}
+
 int iommu_remove_device(struct pci_dev *pdev)
 {
     struct hvm_iommu *hd;
diff -r 6da8953b7a90 -r 119bccb1cc5e xen/drivers/passthrough/pci.c
--- a/xen/drivers/passthrough/pci.c     Wed Nov 02 13:51:28 2011 +0100
+++ b/xen/drivers/passthrough/pci.c     Wed Nov 02 13:53:05 2011 +0100
@@ -258,7 +258,7 @@
  * pci_enable_acs - enable ACS if hardware support it
  * @dev: the PCI device
  */
-void pci_enable_acs(struct pci_dev *pdev)
+static void pci_enable_acs(struct pci_dev *pdev)
 {
     int pos;
     u16 cap, ctrl, seg = pdev->seg;
@@ -409,8 +409,11 @@
         }
 
         list_add(&pdev->domain_list, &dom0->arch.pdev_list);
-        pci_enable_acs(pdev);
     }
+    else
+        iommu_enable_device(pdev);
+
+    pci_enable_acs(pdev);
 
 out:
     spin_unlock(&pcidevs_lock);
diff -r 6da8953b7a90 -r 119bccb1cc5e xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Wed Nov 02 13:51:28 2011 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c       Wed Nov 02 13:53:05 2011 +0100
@@ -1900,6 +1900,19 @@
     return ret;
 }
 
+static int intel_iommu_enable_device(struct pci_dev *pdev)
+{
+    struct acpi_drhd_unit *drhd = acpi_find_matched_drhd_unit(pdev);
+    int ret = drhd ? ats_device(pdev, drhd) : -ENODEV;
+
+    if ( ret <= 0 )
+        return ret;
+
+    ret = enable_ats_device(pdev->seg, pdev->bus, pdev->devfn);
+
+    return ret >= 0 ? 0 : ret;
+}
+
 static int intel_iommu_remove_device(struct pci_dev *pdev)
 {
     struct acpi_rmrr_unit *rmrr;
@@ -1930,7 +1943,6 @@
 static void __init setup_dom0_device(struct pci_dev *pdev)
 {
     domain_context_mapping(pdev->domain, pdev->seg, pdev->bus, pdev->devfn);
-    pci_enable_acs(pdev);
     pci_vtd_quirk(pdev);
 }
 
@@ -2301,6 +2313,7 @@
     .init = intel_iommu_domain_init,
     .dom0_init = intel_iommu_dom0_init,
     .add_device = intel_iommu_add_device,
+    .enable_device = intel_iommu_enable_device,
     .remove_device = intel_iommu_remove_device,
     .assign_device  = intel_iommu_assign_device,
     .teardown = iommu_domain_teardown,
diff -r 6da8953b7a90 -r 119bccb1cc5e xen/include/xen/iommu.h
--- a/xen/include/xen/iommu.h   Wed Nov 02 13:51:28 2011 +0100
+++ b/xen/include/xen/iommu.h   Wed Nov 02 13:53:05 2011 +0100
@@ -70,6 +70,7 @@
 void iommu_disable_x2apic_IR(void);
 
 int iommu_add_device(struct pci_dev *pdev);
+int iommu_enable_device(struct pci_dev *pdev);
 int iommu_remove_device(struct pci_dev *pdev);
 int iommu_domain_init(struct domain *d);
 void iommu_dom0_init(struct domain *d);
@@ -120,6 +121,7 @@
     int (*init)(struct domain *d);
     void (*dom0_init)(struct domain *d);
     int (*add_device)(struct pci_dev *pdev);
+    int (*enable_device)(struct pci_dev *pdev);
     int (*remove_device)(struct pci_dev *pdev);
     int (*assign_device)(struct domain *d, u16 seg, u8 bus, u8 devfn);
     void (*teardown)(struct domain *d);
diff -r 6da8953b7a90 -r 119bccb1cc5e xen/include/xen/pci.h
--- a/xen/include/xen/pci.h     Wed Nov 02 13:51:28 2011 +0100
+++ b/xen/include/xen/pci.h     Wed Nov 02 13:53:05 2011 +0100
@@ -134,6 +134,5 @@
 int msixtbl_pt_register(struct domain *, struct pirq *, uint64_t gtable);
 void msixtbl_pt_unregister(struct domain *, struct pirq *);
 void msixtbl_pt_cleanup(struct domain *d);
-void pci_enable_acs(struct pci_dev *pdev);
 
 #endif /* __XEN_PCI_H__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.