aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2017-09-13 17:29:05 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-09-25 14:38:22 -0400
commit07557ccb8c83f315e409ddee181e9ffbf87c6ad1 (patch)
tree59d738d6d53f618b74763d0f5691310795d0ad21
parente0b477941d130576d9daf31160dab6e34335b10a (diff)
genirq/msi: Capture device name for debugfs
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
-rw-r--r--include/linux/irqdesc.h1
-rw-r--r--kernel/irq/debugfs.c10
-rw-r--r--kernel/irq/internals.h5
-rw-r--r--kernel/irq/msi.c6
4 files changed, 21 insertions, 1 deletions
diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
index 3e90a094798d..b55b113c049b 100644
--- a/include/linux/irqdesc.h
+++ b/include/linux/irqdesc.h
@@ -93,6 +93,7 @@ struct irq_desc {
93#endif 93#endif
94#ifdef CONFIG_GENERIC_IRQ_DEBUGFS 94#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
95 struct dentry *debugfs_file; 95 struct dentry *debugfs_file;
96 const char *dev_name;
96#endif 97#endif
97#ifdef CONFIG_SPARSE_IRQ 98#ifdef CONFIG_SPARSE_IRQ
98 struct rcu_head rcu; 99 struct rcu_head rcu;
diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
index c3fdb36dec30..b7d1023b9b22 100644
--- a/kernel/irq/debugfs.c
+++ b/kernel/irq/debugfs.c
@@ -149,6 +149,7 @@ static int irq_debug_show(struct seq_file *m, void *p)
149 raw_spin_lock_irq(&desc->lock); 149 raw_spin_lock_irq(&desc->lock);
150 data = irq_desc_get_irq_data(desc); 150 data = irq_desc_get_irq_data(desc);
151 seq_printf(m, "handler: %pf\n", desc->handle_irq); 151 seq_printf(m, "handler: %pf\n", desc->handle_irq);
152 seq_printf(m, "device: %s\n", desc->dev_name);
152 seq_printf(m, "status: 0x%08x\n", desc->status_use_accessors); 153 seq_printf(m, "status: 0x%08x\n", desc->status_use_accessors);
153 irq_debug_show_bits(m, 0, desc->status_use_accessors, irqdesc_states, 154 irq_debug_show_bits(m, 0, desc->status_use_accessors, irqdesc_states,
154 ARRAY_SIZE(irqdesc_states)); 155 ARRAY_SIZE(irqdesc_states));
@@ -226,6 +227,15 @@ static const struct file_operations dfs_irq_ops = {
226 .release = single_release, 227 .release = single_release,
227}; 228};
228 229
230void irq_debugfs_copy_devname(int irq, struct device *dev)
231{
232 struct irq_desc *desc = irq_to_desc(irq);
233 const char *name = dev_name(dev);
234
235 if (name)
236 desc->dev_name = kstrdup(name, GFP_KERNEL);
237}
238
229void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc) 239void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc)
230{ 240{
231 char name [10]; 241 char name [10];
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index a4aa39009f0d..cfaec2669093 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -443,7 +443,9 @@ void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc);
443static inline void irq_remove_debugfs_entry(struct irq_desc *desc) 443static inline void irq_remove_debugfs_entry(struct irq_desc *desc)
444{ 444{
445 debugfs_remove(desc->debugfs_file); 445 debugfs_remove(desc->debugfs_file);
446 kfree(desc->dev_name);
446} 447}
448void irq_debugfs_copy_devname(int irq, struct device *dev);
447# ifdef CONFIG_IRQ_DOMAIN 449# ifdef CONFIG_IRQ_DOMAIN
448void irq_domain_debugfs_init(struct dentry *root); 450void irq_domain_debugfs_init(struct dentry *root);
449# else 451# else
@@ -458,4 +460,7 @@ static inline void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *d)
458static inline void irq_remove_debugfs_entry(struct irq_desc *d) 460static inline void irq_remove_debugfs_entry(struct irq_desc *d)
459{ 461{
460} 462}
463static inline void irq_debugfs_copy_devname(int irq, struct device *dev)
464{
465}
461#endif /* CONFIG_GENERIC_IRQ_DEBUGFS */ 466#endif /* CONFIG_GENERIC_IRQ_DEBUGFS */
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 3fa4bd59f569..94ecc0293844 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -16,6 +16,8 @@
16#include <linux/msi.h> 16#include <linux/msi.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18 18
19#include "internals.h"
20
19/** 21/**
20 * alloc_msi_entry - Allocate an initialize msi_entry 22 * alloc_msi_entry - Allocate an initialize msi_entry
21 * @dev: Pointer to the device for which this is allocated 23 * @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,
373 return ret; 375 return ret;
374 } 376 }
375 377
376 for (i = 0; i < desc->nvec_used; i++) 378 for (i = 0; i < desc->nvec_used; i++) {
377 irq_set_msi_desc_off(virq, i, desc); 379 irq_set_msi_desc_off(virq, i, desc);
380 irq_debugfs_copy_devname(virq + i, dev);
381 }
378 } 382 }
379 383
380 if (ops->msi_finish) 384 if (ops->msi_finish)