Skip to content

Commit a6d268c

Browse files
sohilmehjoergroedel
authored andcommitted
iommu/vt-d: Add debugfs support for Interrupt remapping
Debugfs extension for Intel IOMMU to dump Interrupt remapping table entries for Interrupt remapping and Interrupt posting. The file /sys/kernel/debug/iommu/intel/ir_translation_struct provides detailed information, such as Index, Source Id, Destination Id, Vector and the IRTE values for entries with the present bit set, in the format shown. Remapped Interrupt supported on IOMMU: dmar1 IR table address:85e500000 Entry SrcID DstID Vct IRTE_high IRTE_low 24 01:00.0 00000001 24 0000000000040100 000000010024000d 25 01:00.0 00000004 22 0000000000040100 000000040022000d Posted Interrupt supported on IOMMU: dmar5 IR table address:85ec00000 Entry SrcID PDA_high PDA_low Vct IRTE_high IRTE_low 4 43:00.0 0000000f ff765980 41 0000000f00044300 ff76598000418001 5 43:00.0 0000000f ff765980 51 0000000f00044300 ff76598000518001 Cc: Lu Baolu <baolu.lu@linux.intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Ashok Raj <ashok.raj@intel.com> Co-Developed-by: Gayatri Kammela <gayatri.kammela@intel.com> Signed-off-by: Gayatri Kammela <gayatri.kammela@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sohil Mehta <sohil.mehta@intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 6825d3e commit a6d268c

1 file changed

Lines changed: 108 additions & 0 deletions

File tree

‎drivers/iommu/intel-iommu-debugfs.c‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,119 @@ static int iommu_regset_show(struct seq_file *m, void *unused)
131131
}
132132
DEFINE_SHOW_ATTRIBUTE(iommu_regset);
133133

134+
#ifdef CONFIG_IRQ_REMAP
135+
static void ir_tbl_remap_entry_show(struct seq_file *m,
136+
struct intel_iommu *iommu)
137+
{
138+
struct irte *ri_entry;
139+
unsigned long flags;
140+
int idx;
141+
142+
seq_puts(m, " Entry SrcID DstID Vct IRTE_high\t\tIRTE_low\n");
143+
144+
raw_spin_lock_irqsave(&irq_2_ir_lock, flags);
145+
for (idx = 0; idx < INTR_REMAP_TABLE_ENTRIES; idx++) {
146+
ri_entry = &iommu->ir_table->base[idx];
147+
if (!ri_entry->present || ri_entry->p_pst)
148+
continue;
149+
150+
seq_printf(m, " %-5d %02x:%02x.%01x %08x %02x %016llx\t%016llx\n",
151+
idx, PCI_BUS_NUM(ri_entry->sid),
152+
PCI_SLOT(ri_entry->sid), PCI_FUNC(ri_entry->sid),
153+
ri_entry->dest_id, ri_entry->vector,
154+
ri_entry->high, ri_entry->low);
155+
}
156+
raw_spin_unlock_irqrestore(&irq_2_ir_lock, flags);
157+
}
158+
159+
static void ir_tbl_posted_entry_show(struct seq_file *m,
160+
struct intel_iommu *iommu)
161+
{
162+
struct irte *pi_entry;
163+
unsigned long flags;
164+
int idx;
165+
166+
seq_puts(m, " Entry SrcID PDA_high PDA_low Vct IRTE_high\t\tIRTE_low\n");
167+
168+
raw_spin_lock_irqsave(&irq_2_ir_lock, flags);
169+
for (idx = 0; idx < INTR_REMAP_TABLE_ENTRIES; idx++) {
170+
pi_entry = &iommu->ir_table->base[idx];
171+
if (!pi_entry->present || !pi_entry->p_pst)
172+
continue;
173+
174+
seq_printf(m, " %-5d %02x:%02x.%01x %08x %08x %02x %016llx\t%016llx\n",
175+
idx, PCI_BUS_NUM(pi_entry->sid),
176+
PCI_SLOT(pi_entry->sid), PCI_FUNC(pi_entry->sid),
177+
pi_entry->pda_h, pi_entry->pda_l << 6,
178+
pi_entry->vector, pi_entry->high,
179+
pi_entry->low);
180+
}
181+
raw_spin_unlock_irqrestore(&irq_2_ir_lock, flags);
182+
}
183+
184+
/*
185+
* For active IOMMUs go through the Interrupt remapping
186+
* table and print valid entries in a table format for
187+
* Remapped and Posted Interrupts.
188+
*/
189+
static int ir_translation_struct_show(struct seq_file *m, void *unused)
190+
{
191+
struct dmar_drhd_unit *drhd;
192+
struct intel_iommu *iommu;
193+
u64 irta;
194+
195+
rcu_read_lock();
196+
for_each_active_iommu(iommu, drhd) {
197+
if (!ecap_ir_support(iommu->ecap))
198+
continue;
199+
200+
seq_printf(m, "Remapped Interrupt supported on IOMMU: %s\n",
201+
iommu->name);
202+
203+
if (iommu->ir_table) {
204+
irta = virt_to_phys(iommu->ir_table->base);
205+
seq_printf(m, " IR table address:%llx\n", irta);
206+
ir_tbl_remap_entry_show(m, iommu);
207+
} else {
208+
seq_puts(m, "Interrupt Remapping is not enabled\n");
209+
}
210+
seq_putc(m, '\n');
211+
}
212+
213+
seq_puts(m, "****\n\n");
214+
215+
for_each_active_iommu(iommu, drhd) {
216+
if (!cap_pi_support(iommu->cap))
217+
continue;
218+
219+
seq_printf(m, "Posted Interrupt supported on IOMMU: %s\n",
220+
iommu->name);
221+
222+
if (iommu->ir_table) {
223+
irta = virt_to_phys(iommu->ir_table->base);
224+
seq_printf(m, " IR table address:%llx\n", irta);
225+
ir_tbl_posted_entry_show(m, iommu);
226+
} else {
227+
seq_puts(m, "Interrupt Remapping is not enabled\n");
228+
}
229+
seq_putc(m, '\n');
230+
}
231+
rcu_read_unlock();
232+
233+
return 0;
234+
}
235+
DEFINE_SHOW_ATTRIBUTE(ir_translation_struct);
236+
#endif
237+
134238
void __init intel_iommu_debugfs_init(void)
135239
{
136240
struct dentry *intel_iommu_debug = debugfs_create_dir("intel",
137241
iommu_debugfs_dir);
138242

139243
debugfs_create_file("iommu_regset", 0444, intel_iommu_debug, NULL,
140244
&iommu_regset_fops);
245+
#ifdef CONFIG_IRQ_REMAP
246+
debugfs_create_file("ir_translation_struct", 0444, intel_iommu_debug,
247+
NULL, &ir_translation_struct_fops);
248+
#endif
141249
}

0 commit comments

Comments
 (0)