Skip to content

Commit

Permalink
iommu/vt-d: Populate debugfs if IOMMUs are detected
Browse files Browse the repository at this point in the history
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: ee2636b ("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>
  • Loading branch information
Megha Dey authored and Joerg Roedel committed Mar 14, 2020
1 parent 730ad0e commit 1da8347
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion drivers/iommu/intel-iommu-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,16 @@ static int dmar_translation_struct_show(struct seq_file *m, void *unused)
{
struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu;
u32 sts;

rcu_read_lock();
for_each_active_iommu(iommu, drhd) {
sts = dmar_readl(iommu->reg + DMAR_GSTS_REG);
if (!(sts & DMA_GSTS_TES)) {
seq_printf(m, "DMA Remapping is not enabled on %s\n",
iommu->name);
continue;
}
root_tbl_walk(m, iommu);
seq_putc(m, '\n');
}
Expand Down Expand Up @@ -425,6 +432,7 @@ static int ir_translation_struct_show(struct seq_file *m, void *unused)
struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu;
u64 irta;
u32 sts;

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

if (iommu->ir_table) {
sts = dmar_readl(iommu->reg + DMAR_GSTS_REG);
if (iommu->ir_table && (sts & DMA_GSTS_IRES)) {
irta = virt_to_phys(iommu->ir_table->base);
seq_printf(m, " IR table address:%llx\n", irta);
ir_tbl_remap_entry_show(m, iommu);
Expand Down
4 changes: 3 additions & 1 deletion drivers/iommu/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5133,6 +5133,9 @@ int __init intel_iommu_init(void)

down_write(&dmar_global_lock);

if (!no_iommu)
intel_iommu_debugfs_init();

if (no_iommu || dmar_disabled) {
/*
* We exit the function here to ensure IOMMU's remapping and
Expand Down Expand Up @@ -5228,7 +5231,6 @@ int __init intel_iommu_init(void)
pr_info("Intel(R) Virtualization Technology for Directed I/O\n");

intel_iommu_enabled = 1;
intel_iommu_debugfs_init();

return 0;

Expand Down

0 comments on commit 1da8347

Please sign in to comment.