Skip to content

Commit 01499ae

Browse files
Hans ZhangKAGA-KOKO
authored andcommitted
genirq/msi: Expose MSI message data in debugfs
When debugging MSI-related hardware issues (e.g. interrupt delivery failures), developers currently need to either: 1. Recompile the kernel with dynamic debug for tracing msi_desc. 2. Manually read device registers through low-level tools. Both approaches become challenging in production environments where dynamic debugging is often disabled. The interrupt core provides a debugfs interface for inspection of interrupt related data, which contains the per interrupt information in the view of the hierarchical interrupt domains. Though this interface does not expose the MSI address/data pair, which is important information to: - Verify whether the MSI configuration matches the hardware expectations - Diagnose interrupt routing errors (e.g., mismatched destination ID) - Validate remapping behavior in virtualized environments Implement the debug_show() callback for the generic MSI interrupt domains, and use it to expose the MSI address/data pair in the per interrupt diagnostics. Sample output: address_hi: 0x00000000 address_lo: 0xfe670040 msg_data: 0x00000001 [ tglx: Massaged change log. Use irq_data_get_msi_desc() to avoid pointless lookup. ] Signed-off-by: Hans Zhang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent d082ecb commit 01499ae

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

kernel/irq/msi.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/mutex.h>
1616
#include <linux/pci.h>
1717
#include <linux/slab.h>
18+
#include <linux/seq_file.h>
1819
#include <linux/sysfs.h>
1920
#include <linux/types.h>
2021
#include <linux/xarray.h>
@@ -756,12 +757,30 @@ static int msi_domain_translate(struct irq_domain *domain, struct irq_fwspec *fw
756757
return info->ops->msi_translate(domain, fwspec, hwirq, type);
757758
}
758759

760+
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
761+
static void msi_domain_debug_show(struct seq_file *m, struct irq_domain *d,
762+
struct irq_data *irqd, int ind)
763+
{
764+
struct msi_desc *desc = irq_data_get_msi_desc(irqd);
765+
766+
if (!desc)
767+
return;
768+
769+
seq_printf(m, "\n%*saddress_hi: 0x%08x", ind + 1, "", desc->msg.address_hi);
770+
seq_printf(m, "\n%*saddress_lo: 0x%08x", ind + 1, "", desc->msg.address_lo);
771+
seq_printf(m, "\n%*smsg_data: 0x%08x\n", ind + 1, "", desc->msg.data);
772+
}
773+
#endif
774+
759775
static const struct irq_domain_ops msi_domain_ops = {
760776
.alloc = msi_domain_alloc,
761777
.free = msi_domain_free,
762778
.activate = msi_domain_activate,
763779
.deactivate = msi_domain_deactivate,
764780
.translate = msi_domain_translate,
781+
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
782+
.debug_show = msi_domain_debug_show,
783+
#endif
765784
};
766785

767786
static irq_hw_number_t msi_domain_ops_get_hwirq(struct msi_domain_info *info,

0 commit comments

Comments
 (0)