From: Lu Baolu <baolu.lu@linux.intel.com>
To: Joerg Roedel <joro@8bytes.org>,
David Woodhouse <dwmw2@infradead.org>,
Alex Williamson <alex.williamson@redhat.com>,
Kirti Wankhede <kwankhede@nvidia.com>
Cc: ashok.raj@intel.com, sanjay.k.kumar@intel.com,
jacob.jun.pan@intel.com, kevin.tian@intel.com,
Jean-Philippe Brucker <jean-philippe.brucker@arm.com>,
yi.l.liu@intel.com, yi.y.sun@intel.com, peterx@redhat.com,
tiwei.bie@intel.com, Zeng Xin <xin.zeng@intel.com>,
iommu@lists.linux-foundation.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, Lu Baolu <baolu.lu@linux.intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>
Subject: [RFC PATCH 4/5] iommu/vt-d: Allocate and free a pasid
Date: Mon, 12 Nov 2018 14:45:00 +0800 [thread overview]
Message-ID: <20181112064501.2290-5-baolu.lu@linux.intel.com> (raw)
In-Reply-To: <20181112064501.2290-1-baolu.lu@linux.intel.com>
This adds the Intel vt-d specific ops to allocate and free a
pasid value.
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/iommu/intel-iommu.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 769b7059d52f..8dbd0c601dab 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -5626,6 +5626,37 @@ static int intel_iommu_pasid_init(struct iommu_pasid *pasid)
return 0;
}
+static int intel_iommu_pasid_alloc(struct iommu_pasid *pasid, ioasid_t start,
+ ioasid_t end, ioasid_t *ioasid)
+{
+ struct intel_iommu *iommu;
+
+ iommu = pasid->priv;
+ if (!iommu)
+ return -EINVAL;
+
+ /*
+ * In caching mode, PASID ID should be allocated and freed
+ * through the virtual command registers. Otherwise, rely
+ * on the iommu global idr.
+ */
+ if (!cap_caching_mode(iommu->cap))
+ return -EAGAIN;
+
+ return vcmd_alloc_pasid(iommu, ioasid);
+}
+
+static void intel_iommu_pasid_free(struct iommu_pasid *pasid, ioasid_t ioasid)
+{
+ struct intel_iommu *iommu;
+
+ iommu = pasid->priv;
+ if (!iommu || !cap_caching_mode(iommu->cap))
+ return;
+
+ vcmd_free_pasid(iommu, ioasid);
+}
+
const struct iommu_ops intel_iommu_ops = {
.capable = intel_iommu_capable,
.domain_alloc = intel_iommu_domain_alloc,
@@ -5646,6 +5677,8 @@ const struct iommu_ops intel_iommu_ops = {
.get_dev_attr = intel_iommu_get_dev_attr,
.set_dev_attr = intel_iommu_set_dev_attr,
.pasid_init = intel_iommu_pasid_init,
+ .pasid_alloc = intel_iommu_pasid_alloc,
+ .pasid_free = intel_iommu_pasid_free,
.pgsize_bitmap = INTEL_IOMMU_PGSIZES,
};
--
2.17.1
next prev parent reply other threads:[~2018-11-12 6:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-12 6:44 [RFC PATCH 0/5] iommu: APIs for paravirtual PASID allocation Lu Baolu
2018-11-12 6:44 ` [RFC PATCH 1/5] iommu: Add APIs for IOMMU PASID management Lu Baolu
[not found] ` <20181112064501.2290-2-baolu.lu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-12-15 22:38 ` Liu, Yi L
2018-12-15 22:38 ` Liu, Yi L
[not found] ` <A2975661238FB949B60364EF0F2C257439D8E060-0J0gbvR4kTg/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2018-12-16 1:20 ` Lu Baolu
2018-12-16 1:20 ` Lu Baolu
2019-01-30 19:05 ` Jacob Pan
2019-02-15 17:33 ` Jean-Philippe Brucker
[not found] ` <65452190-afac-bc71-de29-ce24b508955a-5wv7dgnIgG8@public.gmane.org>
2019-02-19 18:37 ` Jacob Pan
2018-11-12 6:45 ` Lu Baolu [this message]
2018-11-12 6:45 ` [RFC PATCH 5/5] iommu/vt-d: Use global pasid allocator Lu Baolu
[not found] ` <20181112064501.2290-1-baolu.lu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-11-12 6:44 ` [RFC PATCH 2/5] iommu/vt-d: Initialize a PASID consumer Lu Baolu
2018-11-12 6:44 ` Lu Baolu
2018-11-12 6:44 ` [RFC PATCH 3/5] iommu/vt-d: Enlightened PASID allocation Lu Baolu
2018-11-12 6:44 ` Lu Baolu
2018-11-19 16:36 ` [RFC PATCH 0/5] iommu: APIs for paravirtual " Konrad Rzeszutek Wilk
2018-11-19 16:36 ` Konrad Rzeszutek Wilk
2018-11-20 2:29 ` Yi Sun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181112064501.2290-5-baolu.lu@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=alex.williamson@redhat.com \
--cc=ashok.raj@intel.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@intel.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe.brucker@arm.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterx@redhat.com \
--cc=sanjay.k.kumar@intel.com \
--cc=tiwei.bie@intel.com \
--cc=xin.zeng@intel.com \
--cc=yi.l.liu@intel.com \
--cc=yi.y.sun@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.