[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220625125204.2199437-5-baolu.lu@linux.intel.com>
Date: Sat, 25 Jun 2022 20:52:02 +0800
From: Lu Baolu <baolu.lu@...ux.intel.com>
To: Joerg Roedel <joro@...tes.org>, Steve Wahl <steve.wahl@....com>,
Kevin Tian <kevin.tian@...el.com>
Cc: David Woodhouse <dwmw2@...radead.org>,
Jerry Snitselaar <jsnitsel@...hat.com>,
Mike Travis <mike.travis@....com>,
Dimitri Sivanich <sivanich@....com>,
Russ Anderson <russ.anderson@....com>, iommu@...ts.linux.dev,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org,
Lu Baolu <baolu.lu@...ux.intel.com>
Subject: [PATCH v1 4/6] iommu/vt-d: Add VTD_FLAG_IOMMU_PROBED flag
In the IOMMU hot-add path, there's a need to check whether an IOMMU
has been probed. Instead of checking the IOMMU pointer in the global
list, it's better to allocate a flag bit in iommu->flags for this
purpose.
Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com>
---
drivers/iommu/intel/iommu.h | 1 +
drivers/iommu/intel/iommu.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
index 56c3d1a9e155..105a1e7c60d9 100644
--- a/drivers/iommu/intel/iommu.h
+++ b/drivers/iommu/intel/iommu.h
@@ -479,6 +479,7 @@ enum {
#define VTD_FLAG_TRANS_PRE_ENABLED (1 << 0)
#define VTD_FLAG_IRQ_REMAP_PRE_ENABLED (1 << 1)
#define VTD_FLAG_SVM_CAPABLE (1 << 2)
+#define VTD_FLAG_IOMMU_PROBED (1 << 3)
extern int intel_iommu_sm;
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 78b26fef685e..f6d7055cffd7 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -1695,6 +1695,7 @@ static void free_dmar_iommu(struct intel_iommu *iommu)
}
g_iommus[iommu->seq_id] = NULL;
+ iommu->flags &= ~VTD_FLAG_IOMMU_PROBED;
/* free context mapping */
free_context_table(iommu);
@@ -2951,6 +2952,7 @@ static int __init init_dmars(void)
}
g_iommus[iommu->seq_id] = iommu;
+ iommu->flags |= VTD_FLAG_IOMMU_PROBED;
intel_iommu_init_qi(iommu);
@@ -3460,7 +3462,7 @@ static int intel_iommu_add(struct dmar_drhd_unit *dmaru)
int sp, ret;
struct intel_iommu *iommu = dmaru->iommu;
- if (g_iommus[iommu->seq_id])
+ if (iommu->flags & VTD_FLAG_IOMMU_PROBED)
return 0;
ret = intel_cap_audit(CAP_AUDIT_HOTPLUG_DMAR, iommu);
@@ -3487,6 +3489,7 @@ static int intel_iommu_add(struct dmar_drhd_unit *dmaru)
iommu_disable_translation(iommu);
g_iommus[iommu->seq_id] = iommu;
+ iommu->flags |= VTD_FLAG_IOMMU_PROBED;
ret = iommu_init_domains(iommu);
if (ret == 0)
ret = iommu_alloc_root_entry(iommu);
--
2.25.1
Powered by blists - more mailing lists