From: "Jan Beulich" Subject: Re: [xen-unstable] Commit 2ca9fbd739b8a72b16dd790d0fff7b75f5488fb8 AMD IOMMU: allocate IRTE entries instead of using a static mapping, makes dom0 boot process stall several times. Date: Mon, 26 Aug 2013 07:59:24 +0100 Message-ID: <521B18EC02000078000EE410@nat28.tlf.novell.com> References: <1831656044.20130722225004@eikelenboom.it> <51FF74E502000078000E9267@nat28.tlf.novell.com> <52011A78.2040701@amd.com> <757500547.20130815164341@eikelenboom.it> <520D0CBF02000078000EC4FF@nat28.tlf.novell.com> <1182640844.20130816012228@eikelenboom.it> <33876223.20130816014116@eikelenboom.it> <520DEEFD02000078000EC76F@nat28.tlf.novell.com> <208201973.20130816094246@eikelenboom.it> <520DF8F302000078000EC7AD@nat28.tlf.novell.com> <1157392160.20130816104005@eikelenboom.it> <520E0AA002000078000EC82B@nat28.tlf.novell.com> <451541998.20130816124429@eikelenboom.it> <520E422602000078000EC94D@nat28.tlf.novell.com> <1834274604.20130823005128@eikelenboom.it> <52178DBB02000078000EE0BC@nat28.tlf.novell.com> <1636534211.20130823170508@eikelenboom.it> <521797B002000078000EE0F0@nat28.tlf.novell.com> <1864096999.20130823172907@eikelenboom.it> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1864096999.20130823172907@eikelenboom.it> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Sander Eikelenboom Cc: Andrew Cooper , Suravee Suthikulanit , xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 23.08.13 at 17:29, Sander Eikelenboom wrote: > (XEN) [2013-08-23 15:22:50] 0000:00:14:0: > (XEN) [2013-08-23 15:22:50] IRTE[000] 00a80445 > (XEN) [2013-08-23 15:22:50] IRTE[001] 00f00145 > (XEN) [2013-08-23 15:22:50] IRTE[002] 00380145 > (XEN) [2013-08-23 15:22:50] IRTE[003] 00f10145 > (XEN) [2013-08-23 15:22:50] IRTE[004] 00400145 > (XEN) [2013-08-23 15:22:50] IRTE[005] 00480145 > (XEN) [2013-08-23 15:22:50] IRTE[006] 00500145 > (XEN) [2013-08-23 15:22:50] IRTE[007] 00580145 > (XEN) [2013-08-23 15:22:50] IRTE[008] 00680145 > (XEN) [2013-08-23 15:22:50] IRTE[009] 00700145 > (XEN) [2013-08-23 15:22:50] IRTE[00a] 00780145 > (XEN) [2013-08-23 15:22:50] IRTE[00b] 00883f45 > (XEN) [2013-08-23 15:22:50] IRTE[00c] 00900145 > (XEN) [2013-08-23 15:22:50] IRTE[00d] 00980145 > (XEN) [2013-08-23 15:22:50] IRTE[00e] 00600141 > (XEN) [2013-08-23 15:22:50] IRTE[00f] 00210141 > (XEN) [2013-08-23 15:22:50] IRTE[010] 00d80141 The use on only entry 0 here made clear that this was a really trivial oversight of the original patch. Please try the additional change below. It also alters a bogus comparison in the original code (note the extra ! in (!msi_desc->hpet_id != hpet_sbdf.id)) - I can't see why it would have been coded that way, but double checking the output with "iommu=debug" for the absence of the respective message would be very helpful. Jan --- a/xen/drivers/passthrough/amd/iommu_intr.c +++ b/xen/drivers/passthrough/amd/iommu_intr.c @@ -595,14 +595,31 @@ void* __init amd_iommu_alloc_intremap_ta int __init amd_setup_hpet_msi(struct msi_desc *msi_desc) { - if ( (!msi_desc->hpet_id != hpet_sbdf.id) || - (hpet_sbdf.iommu == NULL) ) + spinlock_t *lock; + unsigned long flags; + int rc = 0; + + if ( msi_desc->hpet_id != hpet_sbdf.id || !hpet_sbdf.iommu ) { - AMD_IOMMU_DEBUG("Fail to setup HPET MSI remapping\n"); - return 1; + AMD_IOMMU_DEBUG("Failed to setup HPET MSI remapping: %s\n", + hpet_sbdf.iommu ? "Wrong HPET" : "No IOMMU"); + return -ENODEV; } - return 0; + lock = get_intremap_lock(hpet_sbdf.seg, hpet_sbdf.bdf); + spin_lock_irqsave(lock, flags); + + msi_desc->remap_index = alloc_intremap_entry(hpet_sbdf.seg, + hpet_sbdf.bdf, 1); + if ( msi_desc->remap_index >= INTREMAP_ENTRIES ) + { + msi_desc->remap_index = -1; + rc = -ENXIO; + } + + spin_unlock_irqrestore(lock, flags); + + return rc; } static void dump_intremap_table(const u32 *table)