From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lu Baolu Subject: [RFC PATCH 03/10] iommu/vt-d: Allocate groups for mediated devices Date: Sun, 22 Jul 2018 14:09:26 +0800 Message-ID: <1532239773-15325-4-git-send-email-baolu.lu@linux.intel.com> References: <1532239773-15325-1-git-send-email-baolu.lu@linux.intel.com> Return-path: In-Reply-To: <1532239773-15325-1-git-send-email-baolu.lu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org To: Joerg Roedel , David Woodhouse , Alex Williamson , Kirti Wankhede Cc: ashok.raj@intel.com, sanjay.k.kumar@intel.com, jacob.jun.pan@intel.com, kevin.tian@intel.com, yi.l.liu@intel.com, yi.y.sun@intel.com, peterx@redhat.com, iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu , Jacob Pan List-Id: iommu@lists.linux-foundation.org With the Intel IOMMU supporting PASID granularity isolation and protection, a mediated device could be isolated and protected by an IOMMU unit. We need to allocate a new group instead of a PCI group. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Sanjay Kumar Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 3ede34a..57ccfc4 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5276,6 +5276,17 @@ static void intel_iommu_put_resv_regions(struct device *dev, } } +static struct iommu_group *intel_iommu_device_group(struct device *dev) +{ + if (dev_is_pci(dev)) + return pci_device_group(dev); + + if (dev_is_mdev(dev)) + return iommu_group_alloc(); + + return ERR_PTR(-EINVAL); +} + #ifdef CONFIG_INTEL_IOMMU_SVM int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev) { @@ -5370,7 +5381,7 @@ const struct iommu_ops intel_iommu_ops = { .remove_device = intel_iommu_remove_device, .get_resv_regions = intel_iommu_get_resv_regions, .put_resv_regions = intel_iommu_put_resv_regions, - .device_group = pci_device_group, + .device_group = intel_iommu_device_group, .pgsize_bitmap = INTEL_IOMMU_PGSIZES, }; -- 2.7.4