From: Wei Wang2 <wei.wang2@amd.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] AMD IOMMU: Parse IVRS table early to prevent iommu_enabled from being disabled
Date: Wed, 28 Oct 2009 17:31:48 +0100 [thread overview]
Message-ID: <200910281731.49136.wei.wang2@amd.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 537 bytes --]
This patch moves IVRS table parsing functions into an early position, which
prevent iommu_enabled from being disabled by failure dmar table detection.
Thanks,
Wei
Signed-off-by: Wei Wang <wei.wang2@amd.com>
--
AMD GmbH, Germany
Operating System Research Center
Legal Information:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34
85609 Dornach b. München
Geschäftsführer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis München
Registergericht München, HRB Nr. 43632
[-- Attachment #2: fix-ivrs.patch --]
[-- Type: text/x-diff, Size: 4352 bytes --]
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();
}
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2009-10-28 16:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-28 16:31 Wei Wang2 [this message]
2009-10-28 17:30 ` [PATCH] AMD IOMMU: Parse IVRS table early to prevent iommu_enabled from being disabled Keir Fraser
2009-10-28 17:46 ` Wei Wang2
2009-10-28 18:03 ` Keir Fraser
2009-10-29 13:51 ` Wei Wang2
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200910281731.49136.wei.wang2@amd.com \
--to=wei.wang2@amd.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.