diff -r 42e9682e4b61 xen/arch/x86/acpi/boot.c --- a/xen/arch/x86/acpi/boot.c Mon Oct 26 13:33:38 2009 +0000 +++ b/xen/arch/x86/acpi/boot.c Wed Oct 28 11:58:31 2009 +0100 @@ -936,6 +936,8 @@ int __init acpi_boot_init(void) acpi_dmar_init(); + acpi_ivrs_init(); + acpi_mmcfg_init(); return 0; diff -r 42e9682e4b61 xen/drivers/passthrough/amd/iommu_acpi.c --- a/xen/drivers/passthrough/amd/iommu_acpi.c Mon Oct 26 13:33:38 2009 +0000 +++ b/xen/drivers/passthrough/amd/iommu_acpi.c Wed Oct 28 11:58:31 2009 +0100 @@ -863,6 +863,7 @@ static int __init detect_iommu_acpi(stru return -ENODEV; } + INIT_LIST_HEAD(&amd_iommu_head); while ( table->length > (length + sizeof(*ivrs_block)) ) { ivrs_block = (struct acpi_ivrs_block_header *) ((u8 *)table + length); @@ -972,9 +973,23 @@ static int __init get_last_bdf_acpi(stru return 0; } -int __init amd_iommu_detect_acpi(void) -{ - return acpi_table_parse(AMD_IOMMU_ACPI_IVRS_SIG, detect_iommu_acpi); +int __init acpi_ivrs_init(void) +{ + int rt; + + /* to make sure this flag has not been cleared after vtd detection */ + iommu_enabled = 1; + + rt = acpi_table_parse(AMD_IOMMU_ACPI_IVRS_SIG, detect_iommu_acpi); + + if ( (rt != 0) || (iommu_found() == 0) ) + { + printk("AMD-Vi: IOMMU not found!\n"); + iommu_enabled = 0; + return -ENODEV; + } + + return 0; } int __init amd_iommu_get_ivrs_dev_entries(void) diff -r 42e9682e4b61 xen/drivers/passthrough/amd/iommu_init.c --- a/xen/drivers/passthrough/amd/iommu_init.c Mon Oct 26 13:33:38 2009 +0000 +++ b/xen/drivers/passthrough/amd/iommu_init.c Wed Oct 28 11:58:31 2009 +0100 @@ -628,7 +628,7 @@ error_out: return -ENODEV; } -static void __init amd_iommu_init_cleanup(void) +void __init amd_iommu_init_cleanup(void) { struct amd_iommu *iommu, *next; int bdf; @@ -718,7 +718,7 @@ static int __init amd_iommu_setup_device int sys_mgt, dev_ex, lint1_pass, lint0_pass, nmi_pass, ext_int_pass, init_pass; - BUG_ON( (ivrs_bdf_entries == 0) || (iommu_enabled) ); + BUG_ON( (ivrs_bdf_entries == 0) ); /* allocate 'device table' on a 4K boundary */ device_table.alloc_size = PAGE_SIZE << @@ -805,6 +805,7 @@ int __init amd_iommu_init(void) error_out: amd_iommu_init_cleanup(); + printk("AMD-Vi: Error initialization!\n"); return -ENODEV; } diff -r 42e9682e4b61 xen/drivers/passthrough/amd/pci_amd_iommu.c --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Mon Oct 26 13:33:38 2009 +0000 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Oct 28 11:58:31 2009 +0100 @@ -158,24 +158,6 @@ static void amd_iommu_setup_dom0_devices spin_unlock(&pcidevs_lock); } -int amd_iov_detect(void) -{ - INIT_LIST_HEAD(&amd_iommu_head); - - if ( (amd_iommu_detect_acpi() !=0) || (iommu_found() == 0) ) - { - printk("AMD-Vi: IOMMU not found!\n"); - return -ENODEV; - } - - if ( amd_iommu_init() != 0 ) - { - printk("Error initialization\n"); - return -ENODEV; - } - return 0; -} - static int allocate_domain_resources(struct hvm_iommu *hd) { /* allocate root table */ diff -r 42e9682e4b61 xen/include/asm-x86/acpi.h --- a/xen/include/asm-x86/acpi.h Mon Oct 26 13:33:38 2009 +0000 +++ b/xen/include/asm-x86/acpi.h Wed Oct 28 11:58:31 2009 +0100 @@ -154,6 +154,7 @@ extern u8 x86_acpiid_to_apicid[]; #define MAX_LOCAL_APIC 256 int acpi_dmar_init(void); +int acpi_ivrs_init(void); void acpi_mmcfg_init(void); /* Incremented whenever we transition through S3. Value is 1 during boot. */ diff -r 42e9682e4b61 xen/include/asm-x86/hvm/iommu.h --- a/xen/include/asm-x86/hvm/iommu.h Mon Oct 26 13:33:38 2009 +0000 +++ b/xen/include/asm-x86/hvm/iommu.h Wed Oct 28 11:58:31 2009 +0100 @@ -5,7 +5,7 @@ extern struct iommu_ops intel_iommu_ops; extern struct iommu_ops intel_iommu_ops; extern struct iommu_ops amd_iommu_ops; extern int intel_vtd_setup(void); -extern int amd_iov_detect(void); +extern int amd_iommu_init(void); static inline struct iommu_ops *iommu_get_ops(void) { @@ -29,7 +29,7 @@ static inline int iommu_hardware_setup(v case X86_VENDOR_INTEL: return intel_vtd_setup(); case X86_VENDOR_AMD: - return amd_iov_detect(); + return amd_iommu_init(); default: BUG(); }