From: "Jan Beulich" Subject: [PATCH] AMD IOMMU: also allocate IRTEs for HPET MSI Date: Mon, 26 Aug 2013 15:20:28 +0100 Message-ID: <521B804C02000078000EE70F@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part794A3D3C.2__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VDxek-0006oT-IR for xen-devel@lists.xenproject.org; Mon, 26 Aug 2013 14:20:34 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Sander Eikelenboom , Jacob Shin , suravee.suthikulpanit@amd.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part794A3D3C.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Omitting this was a blatant oversight of mine in commit 2ca9fbd7 ("AMD IOMMU: allocate IRTE entries instead of using a static mapping"). This also changes a bogus inequality check into a sensible one, even though it is already known that this will make HPET MSI unusable on certain systems (having respective broken firmware). This, however, seems better than failing on systems with consistent ACPI tables. Reported-by: Sander Eikelenboom Signed-off-by: Jan Beulich --- 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 =20 int __init amd_setup_hpet_msi(struct msi_desc *msi_desc) { - if ( (!msi_desc->hpet_id !=3D hpet_sbdf.id) || - (hpet_sbdf.iommu =3D=3D NULL) ) + spinlock_t *lock; + unsigned long flags; + int rc =3D 0; + + if ( msi_desc->hpet_id !=3D 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; } =20 - return 0; + lock =3D get_intremap_lock(hpet_sbdf.seg, hpet_sbdf.bdf); + spin_lock_irqsave(lock, flags); + + msi_desc->remap_index =3D alloc_intremap_entry(hpet_sbdf.seg, + hpet_sbdf.bdf, 1); + if ( msi_desc->remap_index >=3D INTREMAP_ENTRIES ) + { + msi_desc->remap_index =3D -1; + rc =3D -ENXIO; + } + + spin_unlock_irqrestore(lock, flags); + + return rc; } =20 static void dump_intremap_table(const u32 *table) --=__Part794A3D3C.2__= Content-Type: text/plain; name="AMD-IOMMU-HPET-alloc-IRTE.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="AMD-IOMMU-HPET-alloc-IRTE.patch" AMD IOMMU: also allocate IRTEs for HPET MSI=0A=0AOmitting this was a = blatant oversight of mine in commit 2ca9fbd7 ("AMD=0AIOMMU: allocate IRTE = entries instead of using a static mapping").=0A=0AThis also changes a = bogus inequality check into a sensible one, even=0Athough it is already = known that this will make HPET MSI unusable on=0Acertain systems (having = respective broken firmware). This, however,=0Aseems better than failing on = systems with consistent ACPI tables.=0A=0AReported-by: Sander Eikelenboom = =0ASigned-off-by: Jan Beulich =0A= =0A--- a/xen/drivers/passthrough/amd/iommu_intr.c=0A+++ b/xen/drivers/passt= hrough/amd/iommu_intr.c=0A@@ -595,14 +595,31 @@ void* __init amd_iommu_allo= c_intremap_ta=0A =0A int __init amd_setup_hpet_msi(struct msi_desc = *msi_desc)=0A {=0A- if ( (!msi_desc->hpet_id !=3D hpet_sbdf.id) ||=0A- = (hpet_sbdf.iommu =3D=3D NULL) )=0A+ spinlock_t *lock;=0A+ = unsigned long flags;=0A+ int rc =3D 0;=0A+=0A+ if ( msi_desc->hpet_id= !=3D hpet_sbdf.id || !hpet_sbdf.iommu )=0A {=0A- AMD_IOMMU_DEBU= G("Fail to setup HPET MSI remapping\n");=0A- return 1;=0A+ = AMD_IOMMU_DEBUG("Failed to setup HPET MSI remapping: %s\n",=0A+ = hpet_sbdf.iommu ? "Wrong HPET" : "No IOMMU");=0A+ = return -ENODEV;=0A }=0A =0A- return 0;=0A+ lock =3D get_intremap_= lock(hpet_sbdf.seg, hpet_sbdf.bdf);=0A+ spin_lock_irqsave(lock, = flags);=0A+=0A+ msi_desc->remap_index =3D alloc_intremap_entry(hpet_sbdf= .seg,=0A+ hpet_sbdf.bdf, = 1);=0A+ if ( msi_desc->remap_index >=3D INTREMAP_ENTRIES )=0A+ {=0A+ = msi_desc->remap_index =3D -1;=0A+ rc =3D -ENXIO;=0A+ = }=0A+=0A+ spin_unlock_irqrestore(lock, flags);=0A+=0A+ return rc;=0A = }=0A =0A static void dump_intremap_table(const u32 *table)=0A --=__Part794A3D3C.2__= 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.xen.org http://lists.xen.org/xen-devel --=__Part794A3D3C.2__=--