All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Joerg Roedel <joro@8bytes.org>,
	"Jason Gunthorpe" <jgg@nvidia.com>,
	Christoph Hellwig <hch@infradead.org>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Jean-Philippe Brucker <jean-philippe@linaro.com>
Cc: "Pan, Jacob jun" <jacob.jun.pan@intel.com>,
	"Raj, Ashok" <ashok.raj@intel.com>,
	"Kumar, Sanjay K" <sanjay.k.kumar@intel.com>,
	"Jiang, Dave" <dave.jiang@intel.com>,
	"Luck, Tony" <tony.luck@intel.com>,
	"Zanussi, Tom" <tom.zanussi@intel.com>,
	"Williams, Dan J" <dan.j.williams@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>
Subject: RE: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops
Date: Tue, 15 Mar 2022 10:33:08 +0000	[thread overview]
Message-ID: <BN9PR11MB52768A46ED515D2E02FFEF5D8C109@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220315050713.2000518-4-jacob.jun.pan@linux.intel.com>

> From: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Sent: Tuesday, March 15, 2022 1:07 PM
> 
> On VT-d platforms with scalable mode enabled, devices issue DMA requests
> with PASID need to attach to the correct IOMMU domains.
> The attach operation involves the following:
> - programming the PASID into device's PASID table
> - tracking device domain and the PASID relationship
> - managing IOTLB and device TLB invalidations
> 
> This patch extends DMAR domain and device domain info with xarrays to
> track per domain and per device PASIDs.  It provides the flexibility to
> be used beyond DMA API PASID support.
> 
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> ---
>  drivers/iommu/intel/iommu.c | 194
> +++++++++++++++++++++++++++++++++++-
>  include/linux/intel-iommu.h |  12 ++-
>  2 files changed, 202 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 881f8361eca2..9267194eaed3 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -1622,20 +1622,48 @@ static void __iommu_flush_dev_iotlb(struct
> device_domain_info *info,
>  			   qdep, addr, mask);
>  }
> 
> +static void __iommu_flush_dev_piotlb(struct device_domain_info *info,

piotlb is confusing, better be:

	__iommu_flush_dev_iotlb_pasid()

> +					u64 address,
> +				     ioasid_t pasid, unsigned int mask)
> +{
> +	u16 sid, qdep;
> +
> +	if (!info || !info->ats_enabled)
> +		return;
> +
> +	sid = info->bus << 8 | info->devfn;
> +	qdep = info->ats_qdep;
> +	qi_flush_dev_iotlb_pasid(info->iommu, sid, info->pfsid,
> +				 pasid, qdep, address, mask);
> +}
> +
>  static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
>  				  u64 addr, unsigned mask)
>  {
>  	unsigned long flags;
>  	struct device_domain_info *info;
>  	struct subdev_domain_info *sinfo;
> +	unsigned long pasid;
> +	struct pasid_info *pinfo;
> 
>  	if (!domain->has_iotlb_device)
>  		return;
> 
>  	spin_lock_irqsave(&device_domain_lock, flags);
> -	list_for_each_entry(info, &domain->devices, link)
> -		__iommu_flush_dev_iotlb(info, addr, mask);
> -
> +	list_for_each_entry(info, &domain->devices, link) {
> +		/*
> +		 * We cannot use PASID based devTLB invalidation on
> RID2PASID
> +		 * Device does not understand RID2PASID/0. This is different

Lack of a conjunction word between 'RID2PASID' and 'Device'.

and what is RID2PASID/0? It would be clearer to point out that RID2PASID
is visible only within the iommu to mark out requests without PASID, 
thus this PASID value should never be sent to the device side.

> +		 * than IOTLB invalidation where RID2PASID is also used for
> +		 * tagging.

Then it would be obvious because IOTLB is iommu internal agent thus takes 
use of RID2PASID for tagging.

> +		 */
> +		xa_for_each(&info->pasids, pasid, pinfo) {
> +			if (!pasid)

this should be compared to PASID_RID2PASID (though it's zero today).

> +				__iommu_flush_dev_iotlb(info, addr, mask);
> +			else
> +				__iommu_flush_dev_piotlb(info, addr, pasid,
> mask);
> +		}
> +	}
>  	list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
>  		info = get_domain_info(sinfo->pdev);
>  		__iommu_flush_dev_iotlb(info, addr, mask);

Thanks
Kevin

WARNING: multiple messages have this Message-ID (diff)
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Joerg Roedel <joro@8bytes.org>,
	"Jason Gunthorpe" <jgg@nvidia.com>,
	Christoph Hellwig <hch@infradead.org>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Jean-Philippe Brucker <jean-philippe@linaro.com>
Cc: "Luck, Tony" <tony.luck@intel.com>,
	"Jiang, Dave" <dave.jiang@intel.com>,
	"Raj, Ashok" <ashok.raj@intel.com>,
	"Zanussi, Tom" <tom.zanussi@intel.com>,
	"Kumar, Sanjay K" <sanjay.k.kumar@intel.com>,
	"Pan, Jacob jun" <jacob.jun.pan@intel.com>,
	"Williams, Dan J" <dan.j.williams@intel.com>
Subject: RE: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops
Date: Tue, 15 Mar 2022 10:33:08 +0000	[thread overview]
Message-ID: <BN9PR11MB52768A46ED515D2E02FFEF5D8C109@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220315050713.2000518-4-jacob.jun.pan@linux.intel.com>

> From: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Sent: Tuesday, March 15, 2022 1:07 PM
> 
> On VT-d platforms with scalable mode enabled, devices issue DMA requests
> with PASID need to attach to the correct IOMMU domains.
> The attach operation involves the following:
> - programming the PASID into device's PASID table
> - tracking device domain and the PASID relationship
> - managing IOTLB and device TLB invalidations
> 
> This patch extends DMAR domain and device domain info with xarrays to
> track per domain and per device PASIDs.  It provides the flexibility to
> be used beyond DMA API PASID support.
> 
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> ---
>  drivers/iommu/intel/iommu.c | 194
> +++++++++++++++++++++++++++++++++++-
>  include/linux/intel-iommu.h |  12 ++-
>  2 files changed, 202 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 881f8361eca2..9267194eaed3 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -1622,20 +1622,48 @@ static void __iommu_flush_dev_iotlb(struct
> device_domain_info *info,
>  			   qdep, addr, mask);
>  }
> 
> +static void __iommu_flush_dev_piotlb(struct device_domain_info *info,

piotlb is confusing, better be:

	__iommu_flush_dev_iotlb_pasid()

> +					u64 address,
> +				     ioasid_t pasid, unsigned int mask)
> +{
> +	u16 sid, qdep;
> +
> +	if (!info || !info->ats_enabled)
> +		return;
> +
> +	sid = info->bus << 8 | info->devfn;
> +	qdep = info->ats_qdep;
> +	qi_flush_dev_iotlb_pasid(info->iommu, sid, info->pfsid,
> +				 pasid, qdep, address, mask);
> +}
> +
>  static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
>  				  u64 addr, unsigned mask)
>  {
>  	unsigned long flags;
>  	struct device_domain_info *info;
>  	struct subdev_domain_info *sinfo;
> +	unsigned long pasid;
> +	struct pasid_info *pinfo;
> 
>  	if (!domain->has_iotlb_device)
>  		return;
> 
>  	spin_lock_irqsave(&device_domain_lock, flags);
> -	list_for_each_entry(info, &domain->devices, link)
> -		__iommu_flush_dev_iotlb(info, addr, mask);
> -
> +	list_for_each_entry(info, &domain->devices, link) {
> +		/*
> +		 * We cannot use PASID based devTLB invalidation on
> RID2PASID
> +		 * Device does not understand RID2PASID/0. This is different

Lack of a conjunction word between 'RID2PASID' and 'Device'.

and what is RID2PASID/0? It would be clearer to point out that RID2PASID
is visible only within the iommu to mark out requests without PASID, 
thus this PASID value should never be sent to the device side.

> +		 * than IOTLB invalidation where RID2PASID is also used for
> +		 * tagging.

Then it would be obvious because IOTLB is iommu internal agent thus takes 
use of RID2PASID for tagging.

> +		 */
> +		xa_for_each(&info->pasids, pasid, pinfo) {
> +			if (!pasid)

this should be compared to PASID_RID2PASID (though it's zero today).

> +				__iommu_flush_dev_iotlb(info, addr, mask);
> +			else
> +				__iommu_flush_dev_piotlb(info, addr, pasid,
> mask);
> +		}
> +	}
>  	list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
>  		info = get_domain_info(sinfo->pdev);
>  		__iommu_flush_dev_iotlb(info, addr, mask);

Thanks
Kevin
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2022-03-15 10:33 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15  5:07 [PATCH v2 0/8] Enable PASID for DMA API users Jacob Pan
2022-03-15  5:07 ` Jacob Pan
2022-03-15  5:07 ` [PATCH v2 1/8] iommu: Assign per device max PASID Jacob Pan
2022-03-15  5:07   ` Jacob Pan
2022-03-15  5:07 ` [PATCH v2 2/8] iommu: Add attach/detach_dev_pasid domain ops Jacob Pan
2022-03-15  5:07   ` Jacob Pan
2022-03-15 10:24   ` Tian, Kevin
2022-03-15 10:24     ` Tian, Kevin
2022-03-15 11:26   ` Jean-Philippe Brucker
2022-03-15 11:26     ` Jean-Philippe Brucker
2022-03-15 11:49     ` Tian, Kevin
2022-03-15 11:49       ` Tian, Kevin
2022-03-15 16:11       ` Jacob Pan
2022-03-15 16:11         ` Jacob Pan
2022-03-18 12:01       ` Lu Baolu
2022-03-18 12:01         ` Lu Baolu
2022-03-18 13:50         ` Jason Gunthorpe
2022-03-18 13:50           ` Jason Gunthorpe via iommu
2022-03-18 11:52   ` Lu Baolu
2022-03-18 11:52     ` Lu Baolu
2022-03-18 13:48     ` Jason Gunthorpe
2022-03-18 13:48       ` Jason Gunthorpe via iommu
2022-03-15  5:07 ` [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops Jacob Pan
2022-03-15  5:07   ` Jacob Pan
2022-03-15 10:33   ` Tian, Kevin [this message]
2022-03-15 10:33     ` Tian, Kevin
2022-03-15 22:23     ` Jacob Pan
2022-03-15 22:23       ` Jacob Pan
2022-03-15 14:33   ` Jason Gunthorpe
2022-03-15 14:33     ` Jason Gunthorpe via iommu
2022-03-15 22:36     ` Jacob Pan
2022-03-15 22:36       ` Jacob Pan
2022-03-15 23:04       ` Jason Gunthorpe
2022-03-15 23:04         ` Jason Gunthorpe via iommu
2022-03-16 20:50         ` Jacob Pan
2022-03-16 20:50           ` Jacob Pan
2022-03-16 22:15           ` Jason Gunthorpe
2022-03-16 22:15             ` Jason Gunthorpe via iommu
2022-03-16 22:23             ` Luck, Tony
2022-03-16 22:23               ` Luck, Tony
2022-03-17  0:04               ` Jason Gunthorpe
2022-03-17  0:04                 ` Jason Gunthorpe via iommu
2022-03-18  5:47                 ` Tian, Kevin
2022-03-18  5:47                   ` Tian, Kevin
2022-03-18 13:47                   ` Jason Gunthorpe
2022-03-18 13:47                     ` Jason Gunthorpe via iommu
2022-03-17  0:49             ` Jacob Pan
2022-03-17  0:49               ` Jacob Pan
2022-03-17 13:23               ` Jason Gunthorpe
2022-03-17 13:23                 ` Jason Gunthorpe via iommu
2022-03-17 18:23                 ` Jacob Pan
2022-03-17 18:23                   ` Jacob Pan
2022-03-16  7:41     ` Tian, Kevin
2022-03-16  7:41       ` Tian, Kevin
2022-03-16 21:01       ` Jacob Pan
2022-03-16 21:01         ` Jacob Pan
2022-03-18  5:33         ` Tian, Kevin
2022-03-18  5:33           ` Tian, Kevin
2022-03-28 21:41           ` Jacob Pan
2022-03-28 21:41             ` Jacob Pan
2022-03-16  7:39   ` Tian, Kevin
2022-03-16  7:39     ` Tian, Kevin
2022-03-16 20:51     ` Jacob Pan
2022-03-16 20:51       ` Jacob Pan
2022-03-15  5:07 ` [PATCH v2 4/8] iommu/vt-d: Use device_pasid attach op for RID2PASID Jacob Pan
2022-03-15  5:07   ` Jacob Pan
2022-03-16  7:54   ` Tian, Kevin
2022-03-16  7:54     ` Tian, Kevin
2022-03-17 20:45     ` Jacob Pan
2022-03-17 20:45       ` Jacob Pan
2022-03-15  5:07 ` [PATCH v2 5/8] iommu: Add PASID support for DMA mapping API users Jacob Pan
2022-03-15  5:07   ` Jacob Pan
2022-03-15 11:16   ` Robin Murphy
2022-03-15 11:16     ` Robin Murphy
2022-03-15 14:22     ` Jason Gunthorpe
2022-03-15 14:22       ` Jason Gunthorpe via iommu
2022-03-15 16:31       ` Jacob Pan
2022-03-15 16:31         ` Jacob Pan
2022-03-15 17:05         ` Jason Gunthorpe
2022-03-15 17:05           ` Jason Gunthorpe via iommu
2022-03-15 21:24           ` Jacob Pan
2022-03-15 21:24             ` Jacob Pan
2022-03-16 10:32             ` Tian, Kevin
2022-03-16 10:32               ` Tian, Kevin
2022-03-16  8:41       ` Tian, Kevin
2022-03-16  8:41         ` Tian, Kevin
2022-03-16 14:07         ` Jason Gunthorpe
2022-03-16 14:07           ` Jason Gunthorpe via iommu
2022-03-15 14:35   ` Jason Gunthorpe
2022-03-15 14:35     ` Jason Gunthorpe via iommu
2022-03-15 16:38     ` Jacob Pan
2022-03-15 16:38       ` Jacob Pan
2022-03-15 23:05       ` Jason Gunthorpe
2022-03-15 23:05         ` Jason Gunthorpe via iommu
2022-03-18 12:43   ` Lu Baolu
2022-03-18 12:43     ` Lu Baolu
2022-03-28 21:44     ` Jacob Pan
2022-03-28 21:44       ` Jacob Pan
2022-03-15  5:07 ` [PATCH v2 6/8] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID Jacob Pan
2022-03-15  5:07   ` Jacob Pan
2022-03-18  6:10   ` Tian, Kevin
2022-03-18  6:10     ` Tian, Kevin
2022-03-29 17:39     ` Jacob Pan
2022-03-29 17:39       ` Jacob Pan
2022-03-15  5:07 ` [PATCH v2 7/8] iommu/vt-d: Delete supervisor/kernel SVA Jacob Pan
2022-03-15  5:07   ` Jacob Pan
2022-03-18  6:16   ` Tian, Kevin
2022-03-18  6:16     ` Tian, Kevin
2022-03-29 17:42     ` Jacob Pan
2022-03-29 17:42       ` Jacob Pan
2022-03-15  5:07 ` [PATCH v2 8/8] iommu: Remove unused driver data in sva_bind_device Jacob Pan
2022-03-15  5:07   ` Jacob Pan
2022-03-15 11:37   ` Jean-Philippe Brucker
2022-03-15 11:37     ` Jean-Philippe Brucker
2022-03-15  5:07 ` [PATCH v2 9/9] dmaengine: idxd: separate user and kernel pasid enabling Jacob Pan
2022-03-15  5:07   ` Jacob Pan
2022-03-18  6:28   ` Tian, Kevin
2022-03-18  6:28     ` Tian, Kevin
2022-03-15  8:16 ` [PATCH v2 0/8] Enable PASID for DMA API users Tian, Kevin
2022-03-15  8:16   ` Tian, Kevin
2022-03-15 15:49   ` Jacob Pan
2022-03-15 15:49     ` 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=BN9PR11MB52768A46ED515D2E02FFEF5D8C109@BN9PR11MB5276.namprd11.prod.outlook.com \
    --to=kevin.tian@intel.com \
    --cc=ashok.raj@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --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=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sanjay.k.kumar@intel.com \
    --cc=tom.zanussi@intel.com \
    --cc=tony.luck@intel.com \
    --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 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.