WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] x86: add keyhandler to dump MSI state

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] x86: add keyhandler to dump MSI state
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Thu, 21 Jan 2010 14:41:13 +0000
Delivery-date: Thu, 21 Jan 2010 06:41:33 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Equivalent to dumping IO-APIC state; the question is whether this ought
to live on its own key (as done here), or whether it should be chanined
to from the 'i' handler.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- 2010-01-06.orig/xen/arch/x86/msi.c  2010-01-21 15:19:09.000000000 +0100
+++ 2010-01-06/xen/arch/x86/msi.c       2010-01-21 15:19:28.000000000 +0100
@@ -370,6 +370,21 @@ static void msi_set_mask_bit(unsigned in
     entry->msi_attrib.masked = !!flag;
 }
 
+static int msi_get_mask_bit(const struct msi_desc *entry)
+{
+    switch (entry->msi_attrib.type) {
+    case PCI_CAP_ID_MSI:
+        if (!entry->dev || !entry->msi_attrib.maskbit)
+            break;
+        return pci_conf_read32(entry->dev->bus, PCI_SLOT(entry->dev->devfn),
+                               PCI_FUNC(entry->dev->devfn),
+                               (unsigned long)entry->mask_base) & 1;
+    case PCI_CAP_ID_MSIX:
+        return readl(entry->mask_base + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET) & 1;
+    }
+    return -1;
+}
+
 void mask_msi_irq(unsigned int irq)
 {
     msi_set_mask_bit(irq, 1);
@@ -811,3 +826,65 @@ unsigned int pci_msix_get_table_len(stru
 
     return len;
 }
+
+static void dump_msi(unsigned char key)
+{
+    unsigned int irq;
+
+    printk("PCI-MSI interrupt information:\n");
+
+    for ( irq = 0; irq < nr_irqs; irq++ )
+    {
+        struct irq_desc *desc = irq_to_desc(irq);
+        const struct msi_desc *entry;
+        u32 addr, data;
+        unsigned long flags;
+        char type;
+
+        spin_lock_irqsave(&desc->lock, flags);
+
+        entry = desc->msi_desc;
+        type = desc->handler == &pci_msi_type && entry;
+
+        spin_unlock_irqrestore(&desc->lock, flags);
+
+        if ( !type )
+            continue;
+
+        switch ( entry->msi_attrib.type )
+        {
+        case PCI_CAP_ID_MSI: type = ' '; break;
+        case PCI_CAP_ID_MSIX: type = 'X'; break;
+        default: type = '?'; break;
+        }
+
+        data = entry->msg.data;
+        addr = entry->msg.address_lo;
+
+        printk(" MSI%c %4u vec=%02x%7s%6s%3sassert%5s%7s"
+               " dest=%08x mask=%d/%d/%d\n",
+               type, irq,
+               (data & MSI_DATA_VECTOR_MASK) >> MSI_DATA_VECTOR_SHIFT,
+               data & MSI_DATA_DELIVERY_LOWPRI ? "lowest" : "fixed",
+               data & MSI_DATA_TRIGGER_LEVEL ? "level" : "edge",
+               data & MSI_DATA_LEVEL_ASSERT ? "" : "de",
+               addr & MSI_ADDR_DESTMODE_LOGIC ? "log" : "phys",
+               addr & MSI_ADDR_REDIRECTION_LOWPRI ? "lowest" : "cpu",
+               entry->msg.dest32,
+               entry->msi_attrib.maskbit, entry->msi_attrib.masked,
+               msi_get_mask_bit(entry));
+    }
+}
+
+static struct keyhandler dump_msi_keyhandler = {
+    .diagnostic = 1,
+    .u.fn = dump_msi,
+    .desc = "dump MSI state"
+};
+
+static int __init msi_setup_keyhandler(void)
+{
+    register_keyhandler('M', &dump_msi_keyhandler);
+    return 0;
+}
+__initcall(msi_setup_keyhandler);



Attachment: x86-msi-key-handler.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] x86: add keyhandler to dump MSI state, Jan Beulich <=