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