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

[Xen-devel] [PATCH V3] x86/AMD-Vi: Fix IVRS HPET special->handle override



From: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>

The current logic does not handle the case when HPET special->handle
is invalid in IVRS. On such system, the following message is shown:

(XEN) AMD-Vi: Failed to setup HPET MSI remapping: Wrong HPET

This patch will allow the ivrs_hpet[<handle>]=<sbdf> to override the
IVRS.  Also, it removes struct hpet_sbdf.iommu since it is not
used anywhere in the code.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
---
Changes from V2:
        - Introduce enum ivrs_hpet_init per Jan suggestion.
        - Remove hpet_sbdf.cmdline

 xen/drivers/passthrough/amd/iommu_acpi.c      | 28 +++++++++++++++++----------
 xen/drivers/passthrough/amd/iommu_intr.c      | 12 +++++++++---
 xen/include/asm-x86/hvm/svm/amd-iommu-proto.h |  9 +++++++--
 3 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c 
b/xen/drivers/passthrough/amd/iommu_acpi.c
index c3b9631..b4b2a84 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -674,7 +674,7 @@ static void __init parse_ivrs_hpet(char *str)
     hpet_sbdf.id = id;
     hpet_sbdf.bdf = PCI_BDF(bus, dev, func);
     hpet_sbdf.seg = seg;
-    hpet_sbdf.cmdline = 1;
+    hpet_sbdf.init = HPET_CMDL;
 }
 custom_param("ivrs_hpet[", parse_ivrs_hpet);
 
@@ -789,20 +789,28 @@ static u16 __init parse_ivhd_device_special(
         }
         break;
     case ACPI_IVHD_HPET:
-        /* set device id of hpet */
-        if ( hpet_sbdf.iommu ||
-             (hpet_sbdf.cmdline && hpet_sbdf.id != special->handle) )
+        switch (hpet_sbdf.init)
         {
-            printk(XENLOG_WARNING "Only one IVHD HPET entry is supported\n");
+        case HPET_IVHD:
+            printk(XENLOG_WARNING "Only one IVHD HPET entry is supported.\n");
             break;
-        }
-        hpet_sbdf.id = special->handle;
-        if ( !hpet_sbdf.cmdline )
-        {
+        case HPET_CMDL:
+            AMD_IOMMU_DEBUG("IVHD: Command line override present for HPET %#x "
+                            "(IVRS: %#x devID %04x:%02x:%02x.%u)\n",
+                            hpet_sbdf.id, special->handle, seg, PCI_BUS(bdf),
+                            PCI_SLOT(bdf), PCI_FUNC(bdf));
+            break;
+        case HPET_NONE:
+            /* set device id of hpet */
+            hpet_sbdf.id = special->handle;
             hpet_sbdf.bdf = bdf;
             hpet_sbdf.seg = seg;
+            hpet_sbdf.init = HPET_IVHD;
+            break;
+        default:
+            printk(XENLOG_WARNING "IVHD: Failed to initialize HPET.\n");
+            break;
         }
-        hpet_sbdf.iommu = iommu;
         break;
     default:
         printk(XENLOG_ERR "Unrecognized IVHD special variety %#x\n",
diff --git a/xen/drivers/passthrough/amd/iommu_intr.c 
b/xen/drivers/passthrough/amd/iommu_intr.c
index 213f4d7..47ffd49 100644
--- a/xen/drivers/passthrough/amd/iommu_intr.c
+++ b/xen/drivers/passthrough/amd/iommu_intr.c
@@ -598,10 +598,16 @@ int __init amd_setup_hpet_msi(struct msi_desc *msi_desc)
     unsigned long flags;
     int rc = 0;
 
-    if ( msi_desc->hpet_id != hpet_sbdf.id || !hpet_sbdf.iommu )
+    if ( hpet_sbdf.init == HPET_NONE )
     {
-        AMD_IOMMU_DEBUG("Failed to setup HPET MSI remapping: %s\n",
-                        hpet_sbdf.iommu ? "Wrong HPET" : "No IOMMU");
+        AMD_IOMMU_DEBUG("Failed to setup HPET MSI remapping."
+                        " Missing IVRS HPET info.\n");
+        return -ENODEV;
+    }
+    else if ( msi_desc->hpet_id != hpet_sbdf.id )
+    {
+        AMD_IOMMU_DEBUG("Failed to setup HPET MSI remapping."
+                        " Mismatch IVRS info.\n");
         return -ENODEV;
     }
 
diff --git a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h 
b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
index 3e6961d..8c0246f 100644
--- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
@@ -106,10 +106,15 @@ extern struct ioapic_sbdf {
     u16 *pin_2_idx;
 } ioapic_sbdf[MAX_IO_APICS];
 
+typedef enum {
+    HPET_NONE = 0,
+    HPET_CMDL,
+    HPET_IVHD,
+} ivhd_hpet_init;
+
 extern struct hpet_sbdf {
     u16 bdf, seg, id;
-    bool_t cmdline;
-    struct amd_iommu *iommu;
+    ivhd_hpet_init init;
 } hpet_sbdf;
 
 extern void *shared_intremap_table;
-- 
1.8.1.2



_______________________________________________
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®.