]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
genirq/msi: Capture device name for debugfs
authorThomas Gleixner <tglx@linutronix.de>
Wed, 13 Sep 2017 21:29:05 +0000 (23:29 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 25 Sep 2017 18:38:22 +0000 (20:38 +0200)
For debugging the allocation of unused or potentially leaked interrupt
descriptor it's helpful to have some information about the site which
allocated them. In case of MSI this is simple because the caller hands the
device struct pointer into the domain allocation function.

Duplicate the device name and show it in the debugfs entry of the interrupt
descriptor.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Juergen Gross <jgross@suse.com>
Tested-by: Yu Chen <yu.c.chen@intel.com>
Acked-by: Juergen Gross <jgross@suse.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Alok Kataria <akataria@vmware.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Rui Zhang <rui.zhang@intel.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Len Brown <lenb@kernel.org>
Link: https://lkml.kernel.org/r/20170913213152.433038426@linutronix.de
include/linux/irqdesc.h
kernel/irq/debugfs.c
kernel/irq/internals.h
kernel/irq/msi.c

index 3e90a094798d2955054db8f8bee381cb07dcfde9..b55b113c049b1885b6c71c7191464a6a2d9aef0f 100644 (file)
@@ -93,6 +93,7 @@ struct irq_desc {
 #endif
 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
        struct dentry           *debugfs_file;
+       const char              *dev_name;
 #endif
 #ifdef CONFIG_SPARSE_IRQ
        struct rcu_head         rcu;
index c3fdb36dec304956650082efc63bed95f37ff56c..b7d1023b9b2209a4a1419edd555775f657605cb1 100644 (file)
@@ -149,6 +149,7 @@ static int irq_debug_show(struct seq_file *m, void *p)
        raw_spin_lock_irq(&desc->lock);
        data = irq_desc_get_irq_data(desc);
        seq_printf(m, "handler:  %pf\n", desc->handle_irq);
+       seq_printf(m, "device:   %s\n", desc->dev_name);
        seq_printf(m, "status:   0x%08x\n", desc->status_use_accessors);
        irq_debug_show_bits(m, 0, desc->status_use_accessors, irqdesc_states,
                            ARRAY_SIZE(irqdesc_states));
@@ -226,6 +227,15 @@ static const struct file_operations dfs_irq_ops = {
        .release        = single_release,
 };
 
+void irq_debugfs_copy_devname(int irq, struct device *dev)
+{
+       struct irq_desc *desc = irq_to_desc(irq);
+       const char *name = dev_name(dev);
+
+       if (name)
+               desc->dev_name = kstrdup(name, GFP_KERNEL);
+}
+
 void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc)
 {
        char name [10];
index a4aa39009f0d50d5be26e32b768bc2a2ff9c1f27..cfaec2669093a71231a752400c9e84dd26b97a75 100644 (file)
@@ -443,7 +443,9 @@ void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc);
 static inline void irq_remove_debugfs_entry(struct irq_desc *desc)
 {
        debugfs_remove(desc->debugfs_file);
+       kfree(desc->dev_name);
 }
+void irq_debugfs_copy_devname(int irq, struct device *dev);
 # ifdef CONFIG_IRQ_DOMAIN
 void irq_domain_debugfs_init(struct dentry *root);
 # else
@@ -458,4 +460,7 @@ static inline void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *d)
 static inline void irq_remove_debugfs_entry(struct irq_desc *d)
 {
 }
+static inline void irq_debugfs_copy_devname(int irq, struct device *dev)
+{
+}
 #endif /* CONFIG_GENERIC_IRQ_DEBUGFS */
index 3fa4bd59f569865703bb9ab189d24401e99bbf38..94ecc029384475971d8a44838bb51af0bb27798d 100644 (file)
@@ -16,6 +16,8 @@
 #include <linux/msi.h>
 #include <linux/slab.h>
 
+#include "internals.h"
+
 /**
  * alloc_msi_entry - Allocate an initialize msi_entry
  * @dev:       Pointer to the device for which this is allocated
@@ -373,8 +375,10 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
                        return ret;
                }
 
-               for (i = 0; i < desc->nvec_used; i++)
+               for (i = 0; i < desc->nvec_used; i++) {
                        irq_set_msi_desc_off(virq, i, desc);
+                       irq_debugfs_copy_devname(virq + i, dev);
+               }
        }
 
        if (ops->msi_finish)