Skip to content

Commit 07557cc

Browse files
committed
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
1 parent e0b4779 commit 07557cc

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎include/linux/irqdesc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct irq_desc {
9393
#endif
9494
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
9595
struct dentry *debugfs_file;
96+
const char *dev_name;
9697
#endif
9798
#ifdef CONFIG_SPARSE_IRQ
9899
struct rcu_head rcu;

‎kernel/irq/debugfs.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ static int irq_debug_show(struct seq_file *m, void *p)
149149
raw_spin_lock_irq(&desc->lock);
150150
data = irq_desc_get_irq_data(desc);
151151
seq_printf(m, "handler: %pf\n", desc->handle_irq);
152+
seq_printf(m, "device: %s\n", desc->dev_name);
152153
seq_printf(m, "status: 0x%08x\n", desc->status_use_accessors);
153154
irq_debug_show_bits(m, 0, desc->status_use_accessors, irqdesc_states,
154155
ARRAY_SIZE(irqdesc_states));
@@ -226,6 +227,15 @@ static const struct file_operations dfs_irq_ops = {
226227
.release = single_release,
227228
};
228229

230+
void 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+
229239
void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc)
230240
{
231241
char name [10];

‎kernel/irq/internals.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,9 @@ void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc);
443443
static inline void irq_remove_debugfs_entry(struct irq_desc *desc)
444444
{
445445
debugfs_remove(desc->debugfs_file);
446+
kfree(desc->dev_name);
446447
}
448+
void irq_debugfs_copy_devname(int irq, struct device *dev);
447449
# ifdef CONFIG_IRQ_DOMAIN
448450
void irq_domain_debugfs_init(struct dentry *root);
449451
# else
@@ -458,4 +460,7 @@ static inline void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *d)
458460
static inline void irq_remove_debugfs_entry(struct irq_desc *d)
459461
{
460462
}
463+
static inline void irq_debugfs_copy_devname(int irq, struct device *dev)
464+
{
465+
}
461466
#endif /* CONFIG_GENERIC_IRQ_DEBUGFS */

‎kernel/irq/msi.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <linux/msi.h>
1717
#include <linux/slab.h>
1818

19+
#include "internals.h"
20+
1921
/**
2022
* alloc_msi_entry - Allocate an initialize msi_entry
2123
* @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,
373375
return ret;
374376
}
375377

376-
for (i = 0; i < desc->nvec_used; i++)
378+
for (i = 0; i < desc->nvec_used; i++) {
377379
irq_set_msi_desc_off(virq, i, desc);
380+
irq_debugfs_copy_devname(virq + i, dev);
381+
}
378382
}
379383

380384
if (ops->msi_finish)

0 commit comments

Comments
 (0)