>From e5ad3120b67dda98a77d0ae05773ceeb2be1c92f Mon Sep 17 00:00:00 2001 From: Suravee Suthikulpanit Date: Wed, 24 Apr 2013 16:40:09 -0500 Subject: [PATCH 2/2] Add debug-key for dumping IOMMU IRTE. Adding debug-key "j" to allow IOMMU IRTE dumping Example: xl debug-key j Signed-off-by: Suravee Suthikulpanit --- xen/drivers/passthrough/amd/iommu_intr.c | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/xen/drivers/passthrough/amd/iommu_intr.c b/xen/drivers/passthrough/amd/iommu_intr.c index ed9ae79..ab16a5c 100644 --- a/xen/drivers/passthrough/amd/iommu_intr.c +++ b/xen/drivers/passthrough/amd/iommu_intr.c @@ -23,6 +23,7 @@ #include #include #include +#include #define INTREMAP_TABLE_ORDER 1 #define INTREMAP_LENGTH 0xB @@ -34,6 +35,14 @@ void *shared_intremap_table; unsigned long *shared_intremap_inuse; static DEFINE_SPINLOCK(shared_intremap_lock); +static void _dump_amd_iommu_intremap_tables(unsigned char key); + +static struct keyhandler dump_iommu_intremap_table = { + .diagnostic = 0, + .u.fn = _dump_amd_iommu_intremap_tables, + .desc = "dump AMD iommu intremap tables" +}; + static spinlock_t* get_intremap_lock(int seg, int req_id) { return (amd_iommu_perdev_intremap ? @@ -241,6 +250,8 @@ int __init amd_iommu_setup_ioapic_remapping(void) } } + register_keyhandler('j', &dump_iommu_intremap_table); + return 0; } @@ -554,3 +565,49 @@ int __init amd_setup_hpet_msi(struct msi_desc *msi_desc) return 0; } + +static void _dump_intremap_table (u32 bdf, u32 *table) +{ + u32 count; + + if ( table == NULL ) { + return; + } + + for (count = 0; count < INTREMAP_ENTRIES; count++) { + if (*(table+count) == 0) + continue; + printk(" BDF:%3x, IRTE[%4u] : 0x%x\n", bdf, count, *(table+count)); + } +} + +static int __dump_iommu_intremap_mapping(u16 seg, struct ivrs_mappings *ivrs_mapping) +{ + unsigned long flags; + + if ( ivrs_mapping == NULL ) + return 0; + + spin_lock_irqsave(&(ivrs_mapping->intremap_lock), flags); + + _dump_intremap_table(ivrs_mapping->dte_requestor_id, ivrs_mapping->intremap_table); + + spin_unlock_irqrestore(&(ivrs_mapping->intremap_lock), flags); + + return 0; +} + +static void _dump_amd_iommu_intremap_tables(unsigned char key) +{ + unsigned long flags; + + printk("--- Dumping Per-dev IOMMU Interrupt Remapping Table ---\n"); + + iterate_ivrs_entries(__dump_iommu_intremap_mapping); + + printk("--- Dumping Shared IOMMU Interrupt Remapping Table ---\n"); + + spin_lock_irqsave(&shared_intremap_lock, flags); + _dump_intremap_table(-1, shared_intremap_table); + spin_unlock_irqrestore(&shared_intremap_lock, flags); +} -- 1.7.10.4