Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()
@ 2022-05-13  0:32 Nicolin Chen via iommu
  2022-05-13  3:32 ` Baolu Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolin Chen via iommu @ 2022-05-13  0:32 UTC (permalink / raw)
  To: dwmw2, baolu.lu, joro, will; +Cc: iommu, linux-kernel, jgg

Local boot test and VFIO sanity test show that info->iommu can be
used in device_to_iommu() as a fast path. So this patch adds it.

Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/intel/iommu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 2990f80c5e08..412fca5ab9cd 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -777,6 +777,7 @@ static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev)
 struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
 {
 	struct dmar_drhd_unit *drhd = NULL;
+	struct device_domain_info *info;
 	struct pci_dev *pdev = NULL;
 	struct intel_iommu *iommu;
 	struct device *tmp;
@@ -786,6 +787,10 @@ struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
 	if (!dev)
 		return NULL;
 
+	info = dev_iommu_priv_get(dev);
+	if (info)
+		return info->iommu;
+
 	if (dev_is_pci(dev)) {
 		struct pci_dev *pf_pdev;
 
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-13 16:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-13  0:32 [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu() Nicolin Chen via iommu
2022-05-13  3:32 ` Baolu Lu
2022-05-13  3:59   ` Nicolin Chen via iommu
2022-05-13 11:50   ` Jason Gunthorpe via iommu
2022-05-13 16:48     ` Nicolin Chen via iommu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox