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

[Xen-devel] [PATCH 3/3] xen/iommu: disable IOMMU engine completely before enter S5



S5 menas we also shut down IOMMU engine as well, so we should
disable IOMMU engine completely before enter S5, otherwise we
still probably receive some interrupts in this period. But
currently VT-D path depends on force_iommu and iommu_intremap
to determine if we should disable translation and queued
invalidation. So this unexpected behaviour can be fixed by
clearing force_iommu and iommu_intremap. Additionally, some
cleanups to code comments.

Signed-off-by: Tiejun Chen <tiejun.chen@xxxxxxxxx>
---
 xen/arch/x86/acpi/power.c           |  2 ++
 xen/arch/x86/crash.c                | 12 ++++++++----
 xen/drivers/passthrough/vtd/iommu.c |  5 +++--
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c
index f41f0de..345470d 100644
--- a/xen/arch/x86/acpi/power.c
+++ b/xen/arch/x86/acpi/power.c
@@ -183,6 +183,8 @@ static int enter_state(u32 state)
         break;
     case ACPI_STATE_S5:
         acpi_enter_sleep_state(ACPI_STATE_S5);
+        /* Make sure we really disable VT-d engine completely. */
+        force_iommu = iommu_intremap = 0;
         break;
     default:
         error = -EINVAL;
diff --git a/xen/arch/x86/crash.c b/xen/arch/x86/crash.c
index eb7be9c..123fb12 100644
--- a/xen/arch/x86/crash.c
+++ b/xen/arch/x86/crash.c
@@ -171,15 +171,19 @@ static void nmi_shootdown_cpus(void)
         printk("Failed to shoot down CPUs {%s}\n", keyhandler_scratch);
     }
 
-    /* Crash shutdown any IOMMU functionality as the crashdump kernel is not
-     * happy when booting if interrupt/dma remapping is still enabled */
+    /*
+     * Crash shutdown any IOMMU functionality as the crashdump kernel is not
+     * happy when booting if interrupt/dma remapping is still enabled.
+     */
     iommu_crash_shutdown();
 
     __stop_this_cpu();
 
-    /* This is a bit of a hack due to the problems with the x2apic_enabled
+    /*
+     * This is a bit of a hack due to the problems with the x2apic_enabled
      * variable, but we can't do any better without a significant refactoring
-     * of the APIC code */
+     * of the APIC code.
+     */
     x2apic_enabled = (current_local_apic_mode() == APIC_MODE_X2APIC);
 
     disable_IO_APIC();
diff --git a/xen/drivers/passthrough/vtd/iommu.c 
b/xen/drivers/passthrough/vtd/iommu.c
index 72cd854..28244ec 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -2367,9 +2367,10 @@ static void vtd_suspend(void)
 
         iommu_disable_translation(iommu);
 
-        /* If interrupt remapping is enabled, queued invalidation
+        /*
+         * If interrupt remapping is enabled, queued invalidation
          * will be disabled following interupt remapping disabling
-         * in local apic suspend
+         * in local apic suspend.
          */
         if ( !iommu_intremap && iommu_qinval )
             disable_qinval(iommu);
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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