xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH 5 of 6] IOMMU: add crash_shutdown iommu_op
Date: Wed, 25 May 2011 15:32:07 +0100	[thread overview]
Message-ID: <d3026545e9a0aae90d1d.1306333927@andrewcoop> (raw)
In-Reply-To: <patchbomb.1306333922@andrewcoop>

The kdump kernel has problems booting with interrupt/dma
remapping enabled, so we need a new iommu_ops called
crash_shutdown which is basically suspend but doesn't
need to bother saving state.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

diff -r 80f7a773887d -r d3026545e9a0 xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c	Wed May 25 15:12:23 2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_init.c	Wed May 25 15:12:37 2011 +0100
@@ -921,6 +921,14 @@ void amd_iommu_suspend(void)
         disable_iommu(iommu);
 }
 
+void amd_iommu_crash_shutdown(void)
+{
+    struct amd_iommu *iommu;
+
+    for_each_amd_iommu ( iommu )
+        disable_iommu(iommu);
+}
+
 void amd_iommu_resume(void)
 {
     struct amd_iommu *iommu;
diff -r 80f7a773887d -r d3026545e9a0 xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c	Wed May 25 15:12:23 2011 +0100
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c	Wed May 25 15:12:37 2011 +0100
@@ -459,4 +459,5 @@ const struct iommu_ops amd_iommu_ops = {
     .suspend = amd_iommu_suspend,
     .resume = amd_iommu_resume,
     .share_p2m = amd_iommu_share_p2m,
+    .crash_shutdown = amd_iommu_crash_shutdown,
 };
diff -r 80f7a773887d -r d3026545e9a0 xen/drivers/passthrough/iommu.c
--- a/xen/drivers/passthrough/iommu.c	Wed May 25 15:12:23 2011 +0100
+++ b/xen/drivers/passthrough/iommu.c	Wed May 25 15:12:37 2011 +0100
@@ -421,6 +421,13 @@ void iommu_suspend(void)
         ops->suspend();
 }
 
+void iommu_crash_shutdown(void)
+{
+    const struct iommu_ops *ops = iommu_get_ops();
+    if ( ops && ops->crash_shutdown )
+        ops->crash_shutdown();
+}
+
 void iommu_share_p2m_table(struct domain* d)
 {
     const struct iommu_ops *ops = iommu_get_ops();
diff -r 80f7a773887d -r d3026545e9a0 xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c	Wed May 25 15:12:23 2011 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c	Wed May 25 15:12:37 2011 +0100
@@ -2238,6 +2238,25 @@ static void vtd_suspend(void)
     }
 }
 
+static void vtd_crash_shutdown(void)
+{
+    struct acpi_drhd_unit *drhd;
+    struct iommu *iommu;
+
+    if ( !iommu_enabled )
+        return;
+
+    iommu_flush_all();
+
+    for_each_drhd_unit ( drhd )
+    {
+        iommu = drhd->iommu;
+        iommu_disable_translation(iommu);
+    }
+
+    iommu_disable_x2apic_IR();
+}
+
 static void vtd_resume(void)
 {
     struct acpi_drhd_unit *drhd;
@@ -2289,6 +2308,7 @@ const struct iommu_ops intel_iommu_ops =
     .suspend = vtd_suspend,
     .resume = vtd_resume,
     .share_p2m = iommu_set_pgd,
+    .crash_shutdown = vtd_crash_shutdown,
 };
 
 /*
diff -r 80f7a773887d -r d3026545e9a0 xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
--- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Wed May 25 15:12:23 2011 +0100
+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Wed May 25 15:12:37 2011 +0100
@@ -98,6 +98,7 @@ unsigned int amd_iommu_read_ioapic_from_
 /* power management support */
 void amd_iommu_resume(void);
 void amd_iommu_suspend(void);
+void amd_iommu_crash_shutdown(void);
 
 static inline u32 get_field_from_reg_u32(u32 reg_value, u32 mask, u32 shift)
 {
diff -r 80f7a773887d -r d3026545e9a0 xen/include/xen/iommu.h
--- a/xen/include/xen/iommu.h	Wed May 25 15:12:23 2011 +0100
+++ b/xen/include/xen/iommu.h	Wed May 25 15:12:37 2011 +0100
@@ -133,6 +133,7 @@ struct iommu_ops {
     void (*suspend)(void);
     void (*resume)(void);
     void (*share_p2m)(struct domain *d);
+    void (*crash_shutdown)(void);
 };
 
 void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);
@@ -142,6 +143,7 @@ unsigned int iommu_read_apic_from_ire(un
 
 void iommu_suspend(void);
 void iommu_resume(void);
+void iommu_crash_shutdown(void);
 
 void iommu_set_dom0_mapping(struct domain *d);
 void iommu_share_p2m_table(struct domain *d);

  parent reply	other threads:[~2011-05-25 14:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-25 14:32 [PATCH 0 of 6] Fix kexec in Xen (take 3) Andrew Cooper
2011-05-25 14:32 ` [PATCH 1 of 6] APIC: record local APIC state on boot Andrew Cooper
2011-05-25 14:32 ` [PATCH 2 of 6] APIC: remove 'enabled_via_apicbase' variable Andrew Cooper
2011-05-25 14:32 ` [PATCH 3 of 6] APIC: add crash_disable_local_APIC Andrew Cooper
2011-05-25 14:32 ` [PATCH 4 of 6] IOMMU: Sanitise some of our pointer work Andrew Cooper
2011-05-25 17:28   ` Konrad Rzeszutek Wilk
2011-05-25 14:32 ` Andrew Cooper [this message]
2011-05-25 14:32 ` [PATCH 6 of 6] KEXEC: disable iommu jumping into the kdump kernel Andrew Cooper
2011-05-25 15:01 ` [PATCH 0 of 6] Fix kexec in Xen (take 3) Wei Wang2
2011-05-25 16:14 ` Jan Beulich
2011-05-25 16:30   ` Andrew Cooper
2011-05-25 21:35     ` Keir Fraser
2011-05-26  9:12       ` Andrew Cooper
2011-05-26  9:19         ` Keir Fraser

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=d3026545e9a0aae90d1d.1306333927@andrewcoop \
    --to=andrew.cooper3@citrix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).