When using the Xen debug console and printing the IOMMU intremap tables,
it prints everything in the IVRS range regardless if it has an intr
remap or not.  Add some logic to cause an entry to only be printed if
the intr remap table isn't empty.

Signed-off-by: Brian Woods <brian.wo...@amd.com>
---
CC: Paul Durrant <paul.durr...@citrix.com>
CC: Roger Pau Monne <roger....@citrix.com>

 xen/drivers/passthrough/amd/iommu_intr.c | 34 ++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_intr.c 
b/xen/drivers/passthrough/amd/iommu_intr.c
index dad2d1e5ab..e86300b57f 100644
--- a/xen/drivers/passthrough/amd/iommu_intr.c
+++ b/xen/drivers/passthrough/amd/iommu_intr.c
@@ -665,6 +665,24 @@ int __init amd_setup_hpet_msi(struct msi_desc *msi_desc)
     return rc;
 }
 
+
+static bool intremap_table_empty(const u32 *table)
+{
+    u32 count;
+
+    if ( !table )
+        return true;
+
+    for ( count = 0; count < INTREMAP_ENTRIES; count++ )
+    {
+        if ( table[count] )
+            return false;
+    }
+    return true;
+}
+
+
+
 static void dump_intremap_table(const u32 *table)
 {
     u32 count;
@@ -687,13 +705,17 @@ static int dump_intremap_mapping(u16 seg, struct 
ivrs_mappings *ivrs_mapping)
     if ( !ivrs_mapping )
         return 0;
 
-    printk("  %04x:%02x:%02x:%u:\n", seg,
-           PCI_BUS(ivrs_mapping->dte_requestor_id),
-           PCI_SLOT(ivrs_mapping->dte_requestor_id),
-           PCI_FUNC(ivrs_mapping->dte_requestor_id));
-
     spin_lock_irqsave(&(ivrs_mapping->intremap_lock), flags);
-    dump_intremap_table(ivrs_mapping->intremap_table);
+
+    if ( !intremap_table_empty(ivrs_mapping->intremap_table) ) {
+        printk("  %04x:%02x:%02x:%u:\n", seg,
+               PCI_BUS(ivrs_mapping->dte_requestor_id),
+               PCI_SLOT(ivrs_mapping->dte_requestor_id),
+               PCI_FUNC(ivrs_mapping->dte_requestor_id));
+
+        dump_intremap_table(ivrs_mapping->intremap_table);
+    }
+
     spin_unlock_irqrestore(&(ivrs_mapping->intremap_lock), flags);
 
     return 0;
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to