From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>,
iommu@lists.linux-foundation.org,
LKML <linux-kernel@vger.kernel.org>,
dmaengine@vger.kernel.org, Joerg Roedel <joro@8bytes.org>,
David Woodhouse <dwmw2@infradead.org>,
Jean-Philippe Brucker <jean-philippe@linaro.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Christoph Hellwig <hch@infradead.org>,
vkoul@kernel.org, robin.murphy@arm.com, will@kernel.org
Cc: baolu.lu@linux.intel.com, Yi Liu <yi.l.liu@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
"Tian, Kevin" <kevin.tian@intel.com>,
Raj Ashok <ashok.raj@intel.com>,
Eric Auger <eric.auger@redhat.com>
Subject: Re: [PATCH v4 2/6] iommu: Add a helper to do PASID lookup from domain
Date: Thu, 19 May 2022 14:41:06 +0800 [thread overview]
Message-ID: <41c717e3-2965-67ac-9140-72f4b071cd9a@linux.intel.com> (raw)
In-Reply-To: <20220518182120.1136715-3-jacob.jun.pan@linux.intel.com>
On 2022/5/19 02:21, Jacob Pan wrote:
> IOMMU group maintains a PASID array which stores the associated IOMMU
> domains. This patch introduces a helper function to do domain to PASID
> look up. It will be used by TLB flush and device-PASID attach verification.
Do you really need this?
The IOMMU driver has maintained a device tracking list for each domain.
It has been used for cache invalidation when unmap() is called against
dma domain.
Best regards,
baolu
>
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> ---
> drivers/iommu/iommu.c | 22 ++++++++++++++++++++++
> include/linux/iommu.h | 6 +++++-
> 2 files changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 00d0262a1fe9..22f44833db64 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -3199,3 +3199,25 @@ struct iommu_domain *iommu_get_domain_for_iopf(struct device *dev,
>
> return domain;
> }
> +
> +ioasid_t iommu_get_pasid_from_domain(struct device *dev, struct iommu_domain *domain)
> +{
> + struct iommu_domain *tdomain;
> + struct iommu_group *group;
> + unsigned long index;
> + ioasid_t pasid = INVALID_IOASID;
> +
> + group = iommu_group_get(dev);
> + if (!group)
> + return pasid;
> +
> + xa_for_each(&group->pasid_array, index, tdomain) {
> + if (domain == tdomain) {
> + pasid = index;
> + break;
> + }
> + }
> + iommu_group_put(group);
> +
> + return pasid;
> +}
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index 36ad007084cc..c0440a4be699 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -694,7 +694,7 @@ void iommu_detach_device_pasid(struct iommu_domain *domain,
> struct device *dev, ioasid_t pasid);
> struct iommu_domain *
> iommu_get_domain_for_iopf(struct device *dev, ioasid_t pasid);
> -
> +ioasid_t iommu_get_pasid_from_domain(struct device *dev, struct iommu_domain *domain);
> #else /* CONFIG_IOMMU_API */
>
> struct iommu_ops {};
> @@ -1070,6 +1070,10 @@ iommu_get_domain_for_iopf(struct device *dev, ioasid_t pasid)
> {
> return NULL;
> }
> +static ioasid_t iommu_get_pasid_from_domain(struct device *dev, struct iommu_domain *domain)
> +{
> + return INVALID_IOASID;
> +}
> #endif /* CONFIG_IOMMU_API */
>
> #ifdef CONFIG_IOMMU_SVA
next prev parent reply other threads:[~2022-05-19 6:41 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-18 18:21 [PATCH v4 0/6] Enable PASID for DMA API users Jacob Pan
2022-05-18 18:21 ` [PATCH v4 1/6] iommu: Add a per domain PASID for DMA API Jacob Pan
2022-05-19 6:50 ` Baolu Lu
2022-05-24 13:50 ` Jason Gunthorpe
2022-05-24 15:17 ` Jacob Pan
2022-05-30 12:22 ` Jason Gunthorpe
2022-05-31 10:12 ` Tian, Kevin
2022-05-31 12:45 ` Baolu Lu
2022-05-31 16:03 ` Jason Gunthorpe
2022-05-31 17:29 ` Jacob Pan
2022-05-31 19:05 ` Jason Gunthorpe
2022-05-31 20:44 ` Jacob Pan
2022-06-01 1:50 ` Tian, Kevin
2022-06-01 1:43 ` Tian, Kevin
2022-06-01 9:37 ` Baolu Lu
2022-06-01 10:05 ` Tian, Kevin
2022-05-18 18:21 ` [PATCH v4 2/6] iommu: Add a helper to do PASID lookup from domain Jacob Pan
2022-05-19 6:41 ` Baolu Lu [this message]
2022-05-19 20:10 ` Jacob Pan
2022-05-19 6:48 ` Christoph Hellwig
2022-05-20 15:18 ` Jacob Pan
2022-05-23 7:55 ` Tian, Kevin
2022-05-23 9:14 ` Tian, Kevin
2022-05-23 18:01 ` Jacob Pan
2022-05-18 18:21 ` [PATCH v4 3/6] iommu/vt-d: Implement domain ops for attach_dev_pasid Jacob Pan
2022-05-24 13:51 ` Jason Gunthorpe
2022-05-24 16:12 ` Jacob Pan
2022-05-24 18:02 ` Jason Gunthorpe
2022-05-24 20:45 ` Jacob Pan
2022-05-24 21:10 ` Jason Gunthorpe
2022-05-18 18:21 ` [PATCH v4 4/6] iommu: Add PASID support for DMA mapping API users Jacob Pan
2022-05-23 8:25 ` Tian, Kevin
2022-05-23 15:23 ` Jacob Pan
2022-05-18 18:21 ` [PATCH v4 5/6] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID Jacob Pan
2022-05-18 18:21 ` [PATCH v4 6/6] iommu/vt-d: Delete unused SVM flag Jacob Pan
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=41c717e3-2965-67ac-9140-72f4b071cd9a@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=eric.auger@redhat.com \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=vkoul@kernel.org \
--cc=will@kernel.org \
--cc=yi.l.liu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome