From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lu Baolu Subject: [RFC PATCH 2/5] iommu/vt-d: Initialize a PASID consumer Date: Mon, 12 Nov 2018 14:44:58 +0800 Message-ID: <20181112064501.2290-3-baolu.lu@linux.intel.com> References: <20181112064501.2290-1-baolu.lu@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20181112064501.2290-1-baolu.lu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Joerg Roedel , David Woodhouse , Alex Williamson , Kirti Wankhede Cc: kevin.tian-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, ashok.raj-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, tiwei.bie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, Jean-Philippe Brucker , sanjay.k.kumar-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, yi.y.sun-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, jacob.jun.pan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: iommu@lists.linux-foundation.org This adds the Intel vt-d specific ops to initialize a PASID consumer. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Signed-off-by: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 49a278a699b0..769b7059d52f 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5597,6 +5597,35 @@ static int intel_iommu_domain_get_attr(struct iommu_domain *domain, return ret; } +static int intel_iommu_pasid_init(struct iommu_pasid *pasid) +{ + struct dmar_drhd_unit *drhd; + struct intel_iommu *iommu = NULL, *temp; + + /* + * Iterate the iommu units and get a scalable mode capable one + * for virtual command usages. Return failure if scalable mode + * doesn't support by any unit. + */ + rcu_read_lock(); + for_each_active_iommu(temp, drhd) { + if (sm_supported(temp)) { + iommu = temp; + break; + } + } + rcu_read_unlock(); + + if (!iommu) + return -ENODEV; + + pasid->max = intel_pasid_max_id; + pasid->min = PASID_MIN; + pasid->priv = iommu; + + return 0; +} + const struct iommu_ops intel_iommu_ops = { .capable = intel_iommu_capable, .domain_alloc = intel_iommu_domain_alloc, @@ -5616,6 +5645,7 @@ const struct iommu_ops intel_iommu_ops = { .domain_get_attr = intel_iommu_domain_get_attr, .get_dev_attr = intel_iommu_get_dev_attr, .set_dev_attr = intel_iommu_set_dev_attr, + .pasid_init = intel_iommu_pasid_init, .pgsize_bitmap = INTEL_IOMMU_PGSIZES, }; -- 2.17.1