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

[Xen-devel] [PATCH v4 11/12] IOMMU: remove indirection from certain IOMMU hook accesses



In !IOMMU_MIXED mode there's no need to go through an extra level of
indirection. In order to limit code churn, call sites using struct
domain_iommu's platform_ops don't get touched here, however.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v4: New.

--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -29,6 +29,8 @@
 
 static bool_t __read_mostly init_done;
 
+static const struct iommu_ops amd_iommu_ops;
+
 struct amd_iommu *find_iommu_for_device(int seg, int bdf)
 {
     struct ivrs_mappings *ivrs_mappings = get_ivrs_mappings(seg);
@@ -182,6 +184,8 @@ int __init amd_iov_detect(void)
         return -ENODEV;
     }
 
+    iommu_ops = amd_iommu_ops;
+
     if ( amd_iommu_init() != 0 )
     {
         printk("AMD-Vi: Error initialization\n");
@@ -607,7 +611,7 @@ static void amd_dump_p2m_table(struct do
     amd_dump_p2m_table_level(hd->arch.root_table, hd->arch.paging_mode, 0, 0);
 }
 
-const struct iommu_ops amd_iommu_ops = {
+static const struct iommu_ops __initconstrel amd_iommu_ops = {
     .init = amd_iommu_domain_init,
     .hwdom_init = amd_iommu_hwdom_init,
     .add_device = amd_iommu_add_device,
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -78,6 +78,8 @@ bool_t __read_mostly amd_iommu_perdev_in
 DEFINE_PER_CPU(bool_t, iommu_dont_flush_iotlb);
 
 #ifndef CONFIG_IOMMU_MIXED
+struct iommu_ops iommu_ops;
+
 DEFINE_SPINLOCK(iommu_pt_cleanup_lock);
 PAGE_LIST_HEAD(iommu_pt_cleanup_list);
 static struct tasklet iommu_pt_cleanup_tasklet;
--- a/xen/drivers/passthrough/vtd/extern.h
+++ b/xen/drivers/passthrough/vtd/extern.h
@@ -27,6 +27,7 @@
 
 struct pci_ats_dev;
 extern bool_t rwbf_quirk;
+extern const struct iommu_ops intel_iommu_ops;
 
 void print_iommu_regs(struct acpi_drhd_unit *drhd);
 void print_vtd_entries(struct iommu *iommu, int bus, int devfn, u64 gmfn);
--- a/xen/drivers/passthrough/vtd/intremap.c
+++ b/xen/drivers/passthrough/vtd/intremap.c
@@ -897,6 +897,8 @@ int iommu_enable_x2apic_IR(void)
     else if ( !x2apic_enabled )
         return -EOPNOTSUPP;
 
+    iommu_ops = intel_iommu_ops;
+
     for_each_drhd_unit ( drhd )
     {
         iommu = drhd->iommu;
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -2251,6 +2251,8 @@ int __init intel_vtd_setup(void)
         goto error;
     }
 
+    iommu_ops = intel_iommu_ops;
+
     /* We enable the following features only if they are supported by all VT-d
      * engines: Snoop Control, DMA passthrough, Queued Invalidation, Interrupt
      * Remapping, and Posted Interrupt
@@ -2650,7 +2652,7 @@ static void vtd_dump_p2m_table(struct do
     vtd_dump_p2m_table_level(hd->arch.pgd_maddr, agaw_to_level(hd->arch.agaw), 
0, 0);
 }
 
-const struct iommu_ops intel_iommu_ops = {
+const struct iommu_ops __initconstrel intel_iommu_ops = {
     .init = intel_iommu_domain_init,
     .hwdom_init = intel_iommu_hwdom_init,
     .add_device = intel_iommu_add_device,
--- a/xen/include/asm-x86/iommu.h
+++ b/xen/include/asm-x86/iommu.h
@@ -44,26 +44,9 @@ struct arch_iommu
     struct guest_iommu *g_iommu;
 };
 
-extern const struct iommu_ops intel_iommu_ops;
-extern const struct iommu_ops amd_iommu_ops;
 int intel_vtd_setup(void);
 int amd_iov_detect(void);
 
-static inline const struct iommu_ops *iommu_get_ops(void)
-{
-    switch ( boot_cpu_data.x86_vendor )
-    {
-    case X86_VENDOR_INTEL:
-        return &intel_iommu_ops;
-    case X86_VENDOR_AMD:
-        return &amd_iommu_ops;
-    }
-
-    BUG();
-
-    return NULL;
-}
-
 static inline int iommu_hardware_setup(void)
 {
     switch ( boot_cpu_data.x86_vendor )
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -176,6 +176,16 @@ struct iommu_ops {
     void (*dump_p2m_table)(struct domain *d);
 };
 
+#ifndef CONFIG_IOMMU_MIXED
+extern struct iommu_ops iommu_ops;
+
+static inline const struct iommu_ops *iommu_get_ops(void)
+{
+    BUG_ON(!iommu_ops.init);
+    return &iommu_ops;
+}
+#endif
+
 int __must_check iommu_suspend(void);
 void iommu_resume(void);
 void iommu_crash_shutdown(void);




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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