@@ -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;
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@intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Kevin Tian <kevin.tian@intel.com> Cc: Liu Yi L <yi.l.liu@intel.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> --- drivers/iommu/intel-pasid.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)