From: Jean-Philippe Brucker <jean-philippe@linaro.org>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
Tony Luck <tony.luck@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Raj Ashok <ashok.raj@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Kumar, Sanjay K" <sanjay.k.kumar@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@infradead.org>,
iommu@lists.linux-foundation.org,
Jacob Pan <jacob.jun.pan@intel.com>,
Jason Gunthorpe <jgg@nvidia.com>, Barry Song <21cnbao@gmail.com>,
Dan Williams <dan.j.williams@intel.com>,
Jean-Philippe Brucker <jean-philippe@linaro.com>,
"Zanussi, Tom" <tom.zanussi@intel.com>
Subject: Re: [PATCH 1/4] ioasid: Reserve a global PASID for in-kernel DMA
Date: Thu, 9 Dec 2021 11:03:23 +0000 [thread overview]
Message-ID: <YbHie/Z4bIXwTInx@myrica> (raw)
In-Reply-To: <1638884834-83028-2-git-send-email-jacob.jun.pan@linux.intel.com>
Hi Jacob,
On Tue, Dec 07, 2021 at 05:47:11AM -0800, Jacob Pan wrote:
> In-kernel DMA is managed by DMA mapping APIs, which supports per device
> addressing mode for legacy DMA requests. With the introduction of
> Process Address Space ID (PASID), device DMA can now target at a finer
> granularity per PASID + Requester ID (RID).
>
> However, for in-kernel DMA there is no need to differentiate between
> legacy DMA and DMA with PASID in terms of mapping. DMA address mapping
> for RID+PASID can be made identical to the RID. The benefit for the
> drivers is the continuation of DMA mapping APIs without change.
>
> This patch reserves a special IOASID for devices that perform in-kernel
> DMA requests with PASID. This global IOASID is excluded from the
> IOASID allocator. The analogous case is PASID #0, a special PASID
> reserved for DMA requests without PASID (legacy). We could have different
> kernel PASIDs for individual devices, but for simplicity reasons, a
> globally reserved one will fit the bill.
>
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 2 +-
> drivers/iommu/intel/iommu.c | 4 ++--
> drivers/iommu/intel/pasid.h | 3 +--
> drivers/iommu/intel/svm.c | 2 +-
> drivers/iommu/ioasid.c | 2 ++
> include/linux/ioasid.h | 4 ++++
> 6 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
> index ee66d1f4cb81..ac79a37ffe06 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
> @@ -329,7 +329,7 @@ __arm_smmu_sva_bind(struct device *dev, struct mm_struct *mm)
> return ERR_PTR(-ENOMEM);
>
> /* Allocate a PASID for this mm if necessary */
> - ret = iommu_sva_alloc_pasid(mm, 1, (1U << master->ssid_bits) - 1);
> + ret = iommu_sva_alloc_pasid(mm, IOASID_ALLOC_BASE, (1U << master->ssid_bits) - 1);
I'd rather keep hardware limits as parameters here. PASID#0 is reserved by
the SMMUv3 hardware so we have to pass at least 1 here, but VT-d could
change RID_PASID and pass 0. On the other hand IOASID_DMA_PASID depends on
device drivers needs and is not needed on all systems, so I think could
stay within the ioasid allocator. Could VT-d do an ioasid_alloc()/ioasid_get()
to reserve this global PASID, storing it under the device_domain_lock?
This looks like we're just one step away from device drivers needing
multiple PASIDs for kernel DMA so I'm trying to figure out how to evolve
the API towards that. It's probably as simple as keeping a kernel IOASID
set at first, but then we'll probably want to optimize by having multiple
overlapping sets for each device driver (all separate from the SVA set).
Thanks,
Jean
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2021-12-09 11:03 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 13:47 [PATCH 0/4] Enable PASID for DMA API users Jacob Pan
2021-12-07 13:47 ` [PATCH 1/4] ioasid: Reserve a global PASID for in-kernel DMA Jacob Pan
2021-12-09 11:03 ` Jean-Philippe Brucker [this message]
2021-12-09 18:14 ` Jacob Pan
2021-12-10 9:06 ` Jean-Philippe Brucker
2021-12-10 12:31 ` Jason Gunthorpe via iommu
2021-12-10 18:05 ` Jacob Pan
2021-12-11 8:39 ` Tian, Kevin
2021-12-12 23:34 ` Jason Gunthorpe via iommu
2021-12-07 13:47 ` [PATCH 2/4] iommu: Add PASID support for DMA mapping API users Jacob Pan
2021-12-08 2:31 ` Lu Baolu
2021-12-08 18:49 ` Jacob Pan
2021-12-09 1:56 ` Tian, Kevin
2021-12-09 2:21 ` Lu Baolu
2021-12-09 16:32 ` Jacob Pan
2021-12-09 16:57 ` Raj, Ashok
2021-12-09 17:34 ` Jacob Pan
2021-12-07 13:47 ` [PATCH 3/4] iommu/vt-d: Support PASID DMA for in-kernel usage Jacob Pan
2021-12-08 13:22 ` Jason Gunthorpe via iommu
2021-12-08 19:16 ` Jacob Pan
2021-12-09 2:32 ` Lu Baolu
2021-12-09 23:21 ` Jacob Pan
2021-12-09 23:41 ` Jason Gunthorpe via iommu
2021-12-10 6:46 ` Lu Baolu
2021-12-10 17:50 ` Jacob Pan
2021-12-10 17:48 ` Jason Gunthorpe via iommu
2021-12-10 18:18 ` Jacob Pan
2021-12-10 18:53 ` Jason Gunthorpe via iommu
2021-12-07 13:47 ` [PATCH 4/4] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID Jacob Pan
2021-12-07 23:27 ` Dave Jiang
2021-12-08 4:56 ` Vinod Koul
2021-12-08 17:36 ` Jacob Pan
2021-12-08 13:13 ` Jason Gunthorpe via iommu
2021-12-08 15:35 ` Dave Jiang
2021-12-08 17:51 ` Jason Gunthorpe via iommu
2021-12-09 1:48 ` Tian, Kevin
2021-12-09 19:18 ` Jacob Pan
2021-12-08 19:55 ` Jacob Pan
2021-12-08 20:30 ` Jason Gunthorpe via iommu
2021-12-08 21:59 ` Jacob Pan
2021-12-08 23:39 ` Jason Gunthorpe via iommu
2021-12-09 0:12 ` Dave Jiang
2021-12-09 2:06 ` Tian, Kevin
2021-12-08 18:37 ` kernel test robot
2021-12-08 13:10 ` [PATCH 0/4] Enable PASID for DMA API users Jason Gunthorpe via iommu
2021-12-08 18:15 ` 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=YbHie/Z4bIXwTInx@myrica \
--to=jean-philippe@linaro.org \
--cc=21cnbao@gmail.com \
--cc=ashok.raj@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@intel.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.com \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sanjay.k.kumar@intel.com \
--cc=tom.zanussi@intel.com \
--cc=tony.luck@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