]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/IOMMU: initialize iommu_ops in vendor-independent code
authorJan Beulich <jbeulich@suse.com>
Mon, 8 Apr 2019 11:08:05 +0000 (13:08 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 8 Apr 2019 11:08:05 +0000 (13:08 +0200)
Move this into iommu_hardware_setup() and make that function non-
inline. Move its declaration into common code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Brian Woods <brian.woods@amd.com>
xen/drivers/passthrough/amd/pci_amd_iommu.c
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/passthrough/x86/iommu.c
xen/include/asm-arm/iommu.h
xen/include/asm-x86/iommu.h
xen/include/xen/iommu.h

index 243a37663b0cdbf9940e41963f7e883ea0007f20..dbc71ca7d5892d35bc858c014d4a4cf764a97d23 100644 (file)
@@ -31,7 +31,6 @@
 static bool_t __read_mostly init_done;
 
 static const struct iommu_init_ops _iommu_init_ops;
-static const struct iommu_ops amd_iommu_ops;
 
 struct amd_iommu *find_iommu_for_device(int seg, int bdf)
 {
@@ -173,8 +172,6 @@ static int __init iov_detect(void)
     if ( !iommu_enable && !iommu_intremap )
         return 0;
 
-    iommu_ops = amd_iommu_ops;
-
     if ( amd_iommu_init() != 0 )
     {
         printk("AMD-Vi: Error initialization\n");
@@ -545,7 +542,7 @@ static void amd_dump_p2m_table(struct domain *d)
     amd_dump_p2m_table_level(hd->arch.root_table, hd->arch.paging_mode, 0, 0);
 }
 
-static const struct iommu_ops __initconstrel amd_iommu_ops = {
+static const struct iommu_ops __initconstrel _iommu_ops = {
     .init = amd_iommu_domain_init,
     .hwdom_init = amd_iommu_hwdom_init,
     .add_device = amd_iommu_add_device,
@@ -572,5 +569,6 @@ static const struct iommu_ops __initconstrel amd_iommu_ops = {
 };
 
 static const struct iommu_init_ops __initconstrel _iommu_init_ops = {
+    .ops = &_iommu_ops,
     .setup = iov_detect,
 };
index 74133101c4aa790c654487123f0e9f7aefafe671..69995c4a9f6ea7296d93e6e755ed401ca4b7cbb7 100644 (file)
@@ -2305,8 +2305,6 @@ static int __init 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
index 1c8e1ddb5f792a90827c20970670d6f9bc539489..034ac903dd8013d7f12245c96e770ac4f3ae883e 100644 (file)
 const struct iommu_init_ops *__initdata iommu_init_ops;
 struct iommu_ops __read_mostly iommu_ops;
 
+int __init iommu_hardware_setup(void)
+{
+    if ( !iommu_init_ops )
+        return -ENODEV;
+
+    if ( !iommu_ops.init )
+        iommu_ops = *iommu_init_ops->ops;
+    else
+        /* x2apic setup may have previously initialised the struct. */
+        ASSERT(iommu_ops.init == iommu_init_ops->ops->init);
+
+    return iommu_init_ops->setup();
+}
+
 int iommu_enable_x2apic(void)
 {
     if ( system_state < SYS_STATE_active )
index 90cd011d3537c1718cf954f82188ac46353110c0..904c9aec11e2c21840bec64e2bfb430e7b1c269c 100644 (file)
@@ -26,8 +26,6 @@ struct arch_iommu
 const struct iommu_ops *iommu_get_ops(void);
 void iommu_set_ops(const struct iommu_ops *ops);
 
-int iommu_hardware_setup(void);
-
 #endif /* __ARCH_ARM_IOMMU_H__ */
 
 /*
index 19c82e924a29ef129f06b06b7a46f8c4cfe40244..fd24d8fb7b71d03a134a76114390973b41fe4454 100644 (file)
@@ -73,11 +73,6 @@ struct iommu_init_ops {
 
 extern const struct iommu_init_ops *iommu_init_ops;
 
-static inline int iommu_hardware_setup(void)
-{
-    return iommu_init_ops ? iommu_init_ops->setup() : -ENODEV;
-}
-
 /* Are we using the domain P2M table as its IOMMU pagetable? */
 #define iommu_use_hap_pt(d) \
     (hap_enabled(d) && has_iommu_pt(d) && iommu_hap_pt_share)
index 8b0750981f656b49217cfb41055a7c6b1946fa46..b4afafd972fb06ad5b70c2918c691564837db0ac 100644 (file)
@@ -65,6 +65,7 @@ extern int8_t iommu_hwdom_reserved;
 extern unsigned int iommu_dev_iotlb_timeout;
 
 int iommu_setup(void);
+int iommu_hardware_setup(void);
 
 int iommu_domain_init(struct domain *d);
 void iommu_hwdom_init(struct domain *d);