From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 6 of 7] IOMMU: add crash_shutdown iommu_op [Reformatted] Date: Wed, 15 Jun 2011 16:00:31 +0100 Message-ID: <4DF8C90F.2070907@citrix.com> References: <3ad737eb0a8ded1b8306.1307984573@andrewcoop.uk.xensource.com> <987664A83D2D224EAE907B061CE93D5301E728131A@orsmsx505.amr.corp.intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040202020902000204020409" Return-path: In-Reply-To: <987664A83D2D224EAE907B061CE93D5301E728131A@orsmsx505.amr.corp.intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "Kay, Allen M" Cc: Jan, "xen-devel@lists.xensource.com" , Keir Fraser , Beulich List-Id: xen-devel@lists.xenproject.org --------------040202020902000204020409 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Reformatted patch which removes the crash_shutdown call to iommu_disable_x2apic_IR and merges disable_intremap and disable_qinval into the single for_each_dhrd_unit loop. -- Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer T: +44 (0)1223 225 900, http://www.citrix.com --------------040202020902000204020409 Content-Type: text/x-patch; name="crash_shutdown_iommu_ops.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="crash_shutdown_iommu_ops.patch" IOMMU: add crash_shutdown iommu_op 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. Make sure that crash_shutdown is called on the kexec path. Signed-off-by: Andrew Cooper diff -r 3b440fc31409 xen/arch/x86/crash.c --- a/xen/arch/x86/crash.c Wed Jun 15 15:45:58 2011 +0100 +++ b/xen/arch/x86/crash.c Wed Jun 15 15:55:20 2011 +0100 @@ -77,6 +77,10 @@ static void nmi_shootdown_cpus(void) msecs--; } + /* 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(); disable_IO_APIC(); } diff -r 3b440fc31409 xen/drivers/passthrough/amd/iommu_init.c --- a/xen/drivers/passthrough/amd/iommu_init.c Wed Jun 15 15:45:58 2011 +0100 +++ b/xen/drivers/passthrough/amd/iommu_init.c Wed Jun 15 15:55:20 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 3b440fc31409 xen/drivers/passthrough/amd/pci_amd_iommu.c --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Jun 15 15:45:58 2011 +0100 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Jun 15 15:55:20 2011 +0100 @@ -456,4 +456,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 3b440fc31409 xen/drivers/passthrough/iommu.c --- a/xen/drivers/passthrough/iommu.c Wed Jun 15 15:45:58 2011 +0100 +++ b/xen/drivers/passthrough/iommu.c Wed Jun 15 15:55:20 2011 +0100 @@ -432,6 +432,14 @@ void iommu_share_p2m_table(struct domain ops->share_p2m(d); } +void iommu_crash_shutdown(void) +{ + const struct iommu_ops *ops = iommu_get_ops(); + if ( ops && ops->crash_shutdown ) + ops->crash_shutdown(); + iommu_enabled = 0; +} + /* * Local variables: * mode: C diff -r 3b440fc31409 xen/drivers/passthrough/vtd/iommu.c --- a/xen/drivers/passthrough/vtd/iommu.c Wed Jun 15 15:45:58 2011 +0100 +++ b/xen/drivers/passthrough/vtd/iommu.c Wed Jun 15 15:55:20 2011 +0100 @@ -2235,6 +2235,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); + disable_intremap(drhd->iommu); + disable_qinval(drhd->iommu); + } +} + static void vtd_resume(void) { struct acpi_drhd_unit *drhd; @@ -2286,6 +2305,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 3b440fc31409 xen/include/asm-x86/hvm/svm/amd-iommu-proto.h --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Wed Jun 15 15:45:58 2011 +0100 +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Wed Jun 15 15:55:20 2011 +0100 @@ -102,6 +102,7 @@ extern void *shared_intremap_table; /* 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 3b440fc31409 xen/include/xen/iommu.h --- a/xen/include/xen/iommu.h Wed Jun 15 15:45:58 2011 +0100 +++ b/xen/include/xen/iommu.h Wed Jun 15 15:55:20 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); --------------040202020902000204020409 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------040202020902000204020409--