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)
{
if ( !iommu_enable && !iommu_intremap )
return 0;
- iommu_ops = amd_iommu_ops;
-
if ( amd_iommu_init() != 0 )
{
printk("AMD-Vi: Error initialization\n");
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,
};
static const struct iommu_init_ops __initconstrel _iommu_init_ops = {
+ .ops = &_iommu_ops,
.setup = iov_detect,
};
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
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 )
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__ */
/*
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)
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);