Skip to content

Commit 1da8347

Browse files
Megha Deyjoergroedel
authored andcommitted
iommu/vt-d: Populate debugfs if IOMMUs are detected
Currently, the intel iommu debugfs directory(/sys/kernel/debug/iommu/intel) gets populated only when DMA remapping is enabled (dmar_disabled = 0) irrespective of whether interrupt remapping is enabled or not. Instead, populate the intel iommu debugfs directory if any IOMMUs are detected. Cc: Dan Carpenter <[email protected]> Fixes: ee2636b ("iommu/vt-d: Enable base Intel IOMMU debugfs support") Signed-off-by: Megha Dey <[email protected]> Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 730ad0e commit 1da8347

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

drivers/iommu/intel-iommu-debugfs.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,16 @@ static int dmar_translation_struct_show(struct seq_file *m, void *unused)
282282
{
283283
struct dmar_drhd_unit *drhd;
284284
struct intel_iommu *iommu;
285+
u32 sts;
285286

286287
rcu_read_lock();
287288
for_each_active_iommu(iommu, drhd) {
289+
sts = dmar_readl(iommu->reg + DMAR_GSTS_REG);
290+
if (!(sts & DMA_GSTS_TES)) {
291+
seq_printf(m, "DMA Remapping is not enabled on %s\n",
292+
iommu->name);
293+
continue;
294+
}
288295
root_tbl_walk(m, iommu);
289296
seq_putc(m, '\n');
290297
}
@@ -425,6 +432,7 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused)
425432
struct dmar_drhd_unit *drhd;
426433
struct intel_iommu *iommu;
427434
u64 irta;
435+
u32 sts;
428436

429437
rcu_read_lock();
430438
for_each_active_iommu(iommu, drhd) {
@@ -434,7 +442,8 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused)
434442
seq_printf(m, "Remapped Interrupt supported on IOMMU: %s\n",
435443
iommu->name);
436444

437-
if (iommu->ir_table) {
445+
sts = dmar_readl(iommu->reg + DMAR_GSTS_REG);
446+
if (iommu->ir_table && (sts & DMA_GSTS_IRES)) {
438447
irta = virt_to_phys(iommu->ir_table->base);
439448
seq_printf(m, " IR table address:%llx\n", irta);
440449
ir_tbl_remap_entry_show(m, iommu);

drivers/iommu/intel-iommu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5133,6 +5133,9 @@ int __init intel_iommu_init(void)
51335133

51345134
down_write(&dmar_global_lock);
51355135

5136+
if (!no_iommu)
5137+
intel_iommu_debugfs_init();
5138+
51365139
if (no_iommu || dmar_disabled) {
51375140
/*
51385141
* We exit the function here to ensure IOMMU's remapping and
@@ -5228,7 +5231,6 @@ int __init intel_iommu_init(void)
52285231
pr_info("Intel(R) Virtualization Technology for Directed I/O\n");
52295232

52305233
intel_iommu_enabled = 1;
5231-
intel_iommu_debugfs_init();
52325234

52335235
return 0;
52345236

0 commit comments

Comments
 (0)