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

Hi Jason,

On Tue, 15 Mar 2022 20:04:57 -0300, Jason Gunthorpe <jgg@nvidia.com> wrote:

> On Tue, Mar 15, 2022 at 03:36:20PM -0700, Jacob Pan wrote:
> > Hi Jason,
> > 
> > On Tue, 15 Mar 2022 11:33:22 -0300, Jason Gunthorpe <jgg@nvidia.com>
> > wrote: 
> > > On Mon, Mar 14, 2022 at 10:07:07PM -0700, Jacob Pan wrote:  
> > > > +	/*
> > > > +	 * Each domain could have multiple devices attached with
> > > > shared or per
> > > > +	 * device PASIDs. At the domain level, we keep track of
> > > > unique PASIDs and
> > > > +	 * device user count.
> > > > +	 * E.g. If a domain has two devices attached, device A has
> > > > PASID 0, 1;
> > > > +	 * device B has PASID 0, 2. Then the domain would have
> > > > PASID 0, 1, 2.
> > > > +	 */    
> > > 
> > > A 2d array of xarray's seems like a poor data structure for this task.
> > > 
> > > AFACIT this wants to store a list of (device, pasid) tuples, so a
> > > simple linked list, 1d xarray vector or a red black tree seems more
> > > appropriate..
> > >   
> > Agreed.
> > It might need some surgery for dmar_domain and device_domain_info, which
> > already has a simple device list. I am trying to leverage the existing
> > data struct, let me take a closer look.  
> 
> Maybe the core code should provide this data structure in the
> iommu_domain.
> 
> Figuring out what stuff is attached is something every driver has to
> do right?
yeah, seems we already have some duplicated device list in vendor domain
struct, e.g. VT-d's dmar_domain, AMD's protection_domain. Similarly for 
device_domain_info equivalent.

If core code provides domain-device-pasid tracking, we could do device-pasid
tracking in ioasid.c, when we support per device PASID allocation, each
phy device could be an IOASID set, thus its own namespace.

Perhaps, we could do the following: add a device list to struct
iommu_domain, this will replace vender's domain lists. The data would be
something like:
struct iommu_dev_pasid_data {
	struct list_head list;	  /* For iommu_domain->dev_list */
	struct ioasid_set *pasids;  /* For the PASIDs used by the device */
	struct device *dev;
};

I guess a list of (device, pasid) tuples as you suggested could work but it
will have duplicated device entries since each device could have multiple
PASIDs. right?

Have to code this up to see.

Thanks for the pointers,

Jacob

WARNING: multiple messages have this Message-ID (diff)
From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: Jason Gunthorpe <jgg@nvidia.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>,
	"Zanussi,  Tom" <tom.zanussi@intel.com>,
	"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>,
	Dan Williams <dan.j.williams@intel.com>,
	Jean-Philippe Brucker <jean-philippe@linaro.com>
Subject: Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops
Date: Wed, 16 Mar 2022 13:50:04 -0700	[thread overview]
Message-ID: <20220316135004.61ae1611@jacob-builder> (raw)
In-Reply-To: <20220315230457.GO11336@nvidia.com>

Hi Jason,

On Tue, 15 Mar 2022 20:04:57 -0300, Jason Gunthorpe <jgg@nvidia.com> wrote:

> On Tue, Mar 15, 2022 at 03:36:20PM -0700, Jacob Pan wrote:
> > Hi Jason,
> > 
> > On Tue, 15 Mar 2022 11:33:22 -0300, Jason Gunthorpe <jgg@nvidia.com>
> > wrote: 
> > > On Mon, Mar 14, 2022 at 10:07:07PM -0700, Jacob Pan wrote:  
> > > > +	/*
> > > > +	 * Each domain could have multiple devices attached with
> > > > shared or per
> > > > +	 * device PASIDs. At the domain level, we keep track of
> > > > unique PASIDs and
> > > > +	 * device user count.
> > > > +	 * E.g. If a domain has two devices attached, device A has
> > > > PASID 0, 1;
> > > > +	 * device B has PASID 0, 2. Then the domain would have
> > > > PASID 0, 1, 2.
> > > > +	 */    
> > > 
> > > A 2d array of xarray's seems like a poor data structure for this task.
> > > 
> > > AFACIT this wants to store a list of (device, pasid) tuples, so a
> > > simple linked list, 1d xarray vector or a red black tree seems more
> > > appropriate..
> > >   
> > Agreed.
> > It might need some surgery for dmar_domain and device_domain_info, which
> > already has a simple device list. I am trying to leverage the existing
> > data struct, let me take a closer look.  
> 
> Maybe the core code should provide this data structure in the
> iommu_domain.
> 
> Figuring out what stuff is attached is something every driver has to
> do right?
yeah, seems we already have some duplicated device list in vendor domain
struct, e.g. VT-d's dmar_domain, AMD's protection_domain. Similarly for 
device_domain_info equivalent.

If core code provides domain-device-pasid tracking, we could do device-pasid
tracking in ioasid.c, when we support per device PASID allocation, each
phy device could be an IOASID set, thus its own namespace.

Perhaps, we could do the following: add a device list to struct
iommu_domain, this will replace vender's domain lists. The data would be
something like:
struct iommu_dev_pasid_data {
	struct list_head list;	  /* For iommu_domain->dev_list */
	struct ioasid_set *pasids;  /* For the PASIDs used by the device */
	struct device *dev;
};

I guess a list of (device, pasid) tuples as you suggested could work but it
will have duplicated device entries since each device could have multiple
PASIDs. right?

Have to code this up to see.

Thanks for the pointers,

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

  reply	other threads:[~2022-03-16 20:47 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
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 [this message]
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=20220316135004.61ae1611@jacob-builder \
    --to=jacob.jun.pan@linux.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=jean-philippe@linaro.com \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --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 \
    --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.