[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1532239773-15325-5-git-send-email-baolu.lu@linux.intel.com>
Date: Sun, 22 Jul 2018 14:09:27 +0800
From: Lu Baolu <baolu.lu@...ux.intel.com>
To: Joerg Roedel <joro@...tes.org>,
David Woodhouse <dwmw2@...radead.org>,
Alex Williamson <alex.williamson@...hat.com>,
Kirti Wankhede <kwankhede@...dia.com>
Cc: ashok.raj@...el.com, sanjay.k.kumar@...el.com,
jacob.jun.pan@...el.com, kevin.tian@...el.com, yi.l.liu@...el.com,
yi.y.sun@...el.com, peterx@...hat.com,
iommu@...ts.linux-foundation.org, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Lu Baolu <baolu.lu@...ux.intel.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>
Subject: [RFC PATCH 04/10] iommu/vt-d: Get pasid table for a mediated device
This patch adds the support to get the pasid table for a mediated
device. The assumption is that each mediated device is a minimal
assignable set of a physical PCI device. Hence, we should use the
pasid table of the parent PCI device to manage the translation.
Cc: Ashok Raj <ashok.raj@...el.com>
Cc: Jacob Pan <jacob.jun.pan@...ux.intel.com>
Cc: Kevin Tian <kevin.tian@...el.com>
Cc: Liu Yi L <yi.l.liu@...el.com>
Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com>
---
drivers/iommu/intel-pasid.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/intel-pasid.c b/drivers/iommu/intel-pasid.c
index 1195c2a..9b4d462 100644
--- a/drivers/iommu/intel-pasid.c
+++ b/drivers/iommu/intel-pasid.c
@@ -129,7 +129,19 @@ int intel_pasid_alloc_table(struct device *dev)
int ret, order;
info = dev->archdata.iommu;
- if (WARN_ON(!info || !dev_is_pci(dev) || info->pasid_table))
+ if (WARN_ON(!info || info->pasid_table))
+ return -EINVAL;
+
+ /* Use parent PCI device pasid table for mdev: */
+ if (dev_is_mdev(dev)) {
+ pasid_table = intel_pasid_get_table(dev_mdev_parent(dev));
+ if (pasid_table)
+ goto attach_out;
+ else
+ return -ENOMEM;
+ }
+
+ if (WARN_ON(!dev_is_pci(dev)))
return -EINVAL;
/* DMA alias device already has a pasid table, use it: */
@@ -190,7 +202,7 @@ void intel_pasid_free_table(struct device *dev)
int i, max_pde;
info = dev->archdata.iommu;
- if (!info || !dev_is_pci(dev) || !info->pasid_table)
+ if (!info || !info->pasid_table)
return;
pasid_table = info->pasid_table;
--
2.7.4
Powered by blists - more mailing lists