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 <dan.carpenter@oracle.com>
Fixes: ee2636b8670b1 ("iommu/vt-d: Enable base Intel IOMMU debugfs support")
Signed-off-by: Megha Dey <megha.dey@linux.intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by Megha Dey and committed by Joerg Roedel 1da8347d 730ad0ed

+13 -2
+10 -1
drivers/iommu/intel-iommu-debugfs.c
··· 282 { 283 struct dmar_drhd_unit *drhd; 284 struct intel_iommu *iommu; 285 286 rcu_read_lock(); 287 for_each_active_iommu(iommu, drhd) { 288 root_tbl_walk(m, iommu); 289 seq_putc(m, '\n'); 290 } ··· 432 struct dmar_drhd_unit *drhd; 433 struct intel_iommu *iommu; 434 u64 irta; 435 436 rcu_read_lock(); 437 for_each_active_iommu(iommu, drhd) { ··· 442 seq_printf(m, "Remapped Interrupt supported on IOMMU: %s\n", 443 iommu->name); 444 445 - if (iommu->ir_table) { 446 irta = virt_to_phys(iommu->ir_table->base); 447 seq_printf(m, " IR table address:%llx\n", irta); 448 ir_tbl_remap_entry_show(m, iommu);
··· 282 { 283 struct dmar_drhd_unit *drhd; 284 struct intel_iommu *iommu; 285 + u32 sts; 286 287 rcu_read_lock(); 288 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 + } 295 root_tbl_walk(m, iommu); 296 seq_putc(m, '\n'); 297 } ··· 425 struct dmar_drhd_unit *drhd; 426 struct intel_iommu *iommu; 427 u64 irta; 428 + u32 sts; 429 430 rcu_read_lock(); 431 for_each_active_iommu(iommu, drhd) { ··· 434 seq_printf(m, "Remapped Interrupt supported on IOMMU: %s\n", 435 iommu->name); 436 437 + sts = dmar_readl(iommu->reg + DMAR_GSTS_REG); 438 + if (iommu->ir_table && (sts & DMA_GSTS_IRES)) { 439 irta = virt_to_phys(iommu->ir_table->base); 440 seq_printf(m, " IR table address:%llx\n", irta); 441 ir_tbl_remap_entry_show(m, iommu);
+3 -1
drivers/iommu/intel-iommu.c
··· 5133 5134 down_write(&dmar_global_lock); 5135 5136 if (no_iommu || dmar_disabled) { 5137 /* 5138 * We exit the function here to ensure IOMMU's remapping and ··· 5231 pr_info("Intel(R) Virtualization Technology for Directed I/O\n"); 5232 5233 intel_iommu_enabled = 1; 5234 - intel_iommu_debugfs_init(); 5235 5236 return 0; 5237
··· 5133 5134 down_write(&dmar_global_lock); 5135 5136 + if (!no_iommu) 5137 + intel_iommu_debugfs_init(); 5138 + 5139 if (no_iommu || dmar_disabled) { 5140 /* 5141 * We exit the function here to ensure IOMMU's remapping and ··· 5228 pr_info("Intel(R) Virtualization Technology for Directed I/O\n"); 5229 5230 intel_iommu_enabled = 1; 5231 5232 return 0; 5233