diff mbox

[3/4,v5] iommu/fsl: Add iommu domain attributes required by fsl PAMU driver.

Message ID 1353419697-31269-4-git-send-email-Varun.Sethi@freescale.com (mailing list archive)
State Superseded
Delegated to: Kumar Gala
Headers show

Commit Message

Varun Sethi Nov. 20, 2012, 1:54 p.m. UTC
Added the following domain attributes required by FSL PAMU driver:
1. Subwindows field added to the iommu domain geometry attribute.
2. Added new iommu stash attribute, which allows setting of the
   LIODN specific stash id parameter through IOMMU API.
3. Added an attribute for enabling/disabling DMA to a particular
   memory window.

Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
---
changes in v5:
- Updated description of the subwindows field.
changes in v4:
- Updated comment explaining subwindows(as mentioned by Scott).
change in v3:
-renamed the stash attribute targets
 include/linux/iommu.h |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

Comments

Sethi Varun-B16395 Nov. 26, 2012, 5:24 a.m. UTC | #1
Hi Joerg,
Any comments? Can we apply this patch?

Regards
Varun

> -----Original Message-----
> From: Sethi Varun-B16395
> Sent: Tuesday, November 20, 2012 7:25 PM
> To: joerg.roedel@amd.com; iommu@lists.linux-foundation.org; linuxppc-
> dev@lists.ozlabs.org; linux-kernel@vger.kernel.org; Wood Scott-B07421;
> Tabi Timur-B04825
> Cc: Sethi Varun-B16395
> Subject: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes required
> by fsl PAMU driver.
> 
> Added the following domain attributes required by FSL PAMU driver:
> 1. Subwindows field added to the iommu domain geometry attribute.
> 2. Added new iommu stash attribute, which allows setting of the
>    LIODN specific stash id parameter through IOMMU API.
> 3. Added an attribute for enabling/disabling DMA to a particular
>    memory window.
> 
> Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
> ---
> changes in v5:
> - Updated description of the subwindows field.
> changes in v4:
> - Updated comment explaining subwindows(as mentioned by Scott).
> change in v3:
> -renamed the stash attribute targets
>  include/linux/iommu.h |   43 +++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 43 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h index
> f3b99e1..7ca1cda 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -44,6 +44,41 @@ struct iommu_domain_geometry {
>  	dma_addr_t aperture_start; /* First address that can be mapped
> */
>  	dma_addr_t aperture_end;   /* Last address that can be mapped
> */
>  	bool force_aperture;       /* DMA only allowed in mappable range?
> */
> +
> +	/*
> +	 * A geometry mapping can be created in one of the following ways
> +	 * for an IOMMU:
> +	 * 1. A single contiguous window
> +	 * 2. Through arbritary paging throughout the aperture.
> +	 * 3. Using multiple subwindows
> +	 *
> +	 * In absence of arbritary paging, subwindows allow for supporting
> +	 * physically discontiguous mappings.
> +	 *
> +	 * This attribute indicates number of DMA subwindows supported by
> +	 * the geometry. If there is a single window that maps the entire
> +	 * geometry, attribute must be set to "1". A value of "0" implies
> +	 * that this mechanism is not used at all(normal paging is used).
> +	 * Value other than* "0" or "1" indicates the actual number of
> +	 * subwindows.
> +	 */
> +	u32 subwindows;
> +};
> +
> +/* cache stash targets */
> +#define IOMMU_ATTR_CACHE_L1 1
> +#define IOMMU_ATTR_CACHE_L2 2
> +#define IOMMU_ATTR_CACHE_L3 3
> +
> +/* This attribute corresponds to IOMMUs capable of generating
> + * a stash transaction. A stash transaction is typically a
> + * hardware initiated prefetch of data from memory to cache.
> + * This attribute allows configuring stashig specific parameters
> + * in the IOMMU hardware.
> + */
> +struct iommu_stash_attribute {
> +	u32 	cpu;	/* cpu number */
> +	u32 	cache;	/* cache to stash to: L1,L2,L3 */
>  };
> 
>  struct iommu_domain {
> @@ -60,6 +95,14 @@ struct iommu_domain {  enum iommu_attr {
>  	DOMAIN_ATTR_MAX,
>  	DOMAIN_ATTR_GEOMETRY,
> +	/* Set the IOMMU hardware stashing
> +	 * parameters.
> +	 */
> +	DOMAIN_ATTR_STASH,
> +	/* Explicity enable/disable DMA for a
> +         * particular memory window.
> +         */
> +	DOMAIN_ATTR_ENABLE,
>  };
> 
>  #ifdef CONFIG_IOMMU_API
> --
> 1.7.4.1
Sethi Varun-B16395 Dec. 2, 2012, 8:12 a.m. UTC | #2
Ping!!

> -----Original Message-----
> From: Sethi Varun-B16395
> Sent: Monday, November 26, 2012 10:55 AM
> To: joerg.roedel@amd.com
> Cc: Sethi Varun-B16395; iommu@lists.linux-foundation.org; linuxppc-
> dev@lists.ozlabs.org; linux-kernel@vger.kernel.org; Wood Scott-B07421;
> Tabi Timur-B04825
> Subject: RE: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> required by fsl PAMU driver.
> 
> Hi Joerg,
> Any comments? Can we apply this patch?
> 
> Regards
> Varun
> 
> > -----Original Message-----
> > From: Sethi Varun-B16395
> > Sent: Tuesday, November 20, 2012 7:25 PM
> > To: joerg.roedel@amd.com; iommu@lists.linux-foundation.org; linuxppc-
> > dev@lists.ozlabs.org; linux-kernel@vger.kernel.org; Wood Scott-B07421;
> > Tabi Timur-B04825
> > Cc: Sethi Varun-B16395
> > Subject: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> > required by fsl PAMU driver.
> >
> > Added the following domain attributes required by FSL PAMU driver:
> > 1. Subwindows field added to the iommu domain geometry attribute.
> > 2. Added new iommu stash attribute, which allows setting of the
> >    LIODN specific stash id parameter through IOMMU API.
> > 3. Added an attribute for enabling/disabling DMA to a particular
> >    memory window.
> >
> > Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
> > ---
> > changes in v5:
> > - Updated description of the subwindows field.
> > changes in v4:
> > - Updated comment explaining subwindows(as mentioned by Scott).
> > change in v3:
> > -renamed the stash attribute targets
> >  include/linux/iommu.h |   43
> +++++++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 43 insertions(+), 0 deletions(-)
> >
> > diff --git a/include/linux/iommu.h b/include/linux/iommu.h index
> > f3b99e1..7ca1cda 100644
> > --- a/include/linux/iommu.h
> > +++ b/include/linux/iommu.h
> > @@ -44,6 +44,41 @@ struct iommu_domain_geometry {
> >  	dma_addr_t aperture_start; /* First address that can be mapped */
> >  	dma_addr_t aperture_end;   /* Last address that can be mapped
> > */
> >  	bool force_aperture;       /* DMA only allowed in mappable range?
> > */
> > +
> > +	/*
> > +	 * A geometry mapping can be created in one of the following ways
> > +	 * for an IOMMU:
> > +	 * 1. A single contiguous window
> > +	 * 2. Through arbritary paging throughout the aperture.
> > +	 * 3. Using multiple subwindows
> > +	 *
> > +	 * In absence of arbritary paging, subwindows allow for supporting
> > +	 * physically discontiguous mappings.
> > +	 *
> > +	 * This attribute indicates number of DMA subwindows supported by
> > +	 * the geometry. If there is a single window that maps the entire
> > +	 * geometry, attribute must be set to "1". A value of "0" implies
> > +	 * that this mechanism is not used at all(normal paging is used).
> > +	 * Value other than* "0" or "1" indicates the actual number of
> > +	 * subwindows.
> > +	 */
> > +	u32 subwindows;
> > +};
> > +
> > +/* cache stash targets */
> > +#define IOMMU_ATTR_CACHE_L1 1
> > +#define IOMMU_ATTR_CACHE_L2 2
> > +#define IOMMU_ATTR_CACHE_L3 3
> > +
> > +/* This attribute corresponds to IOMMUs capable of generating
> > + * a stash transaction. A stash transaction is typically a
> > + * hardware initiated prefetch of data from memory to cache.
> > + * This attribute allows configuring stashig specific parameters
> > + * in the IOMMU hardware.
> > + */
> > +struct iommu_stash_attribute {
> > +	u32 	cpu;	/* cpu number */
> > +	u32 	cache;	/* cache to stash to: L1,L2,L3 */
> >  };
> >
> >  struct iommu_domain {
> > @@ -60,6 +95,14 @@ struct iommu_domain {  enum iommu_attr {
> >  	DOMAIN_ATTR_MAX,
> >  	DOMAIN_ATTR_GEOMETRY,
> > +	/* Set the IOMMU hardware stashing
> > +	 * parameters.
> > +	 */
> > +	DOMAIN_ATTR_STASH,
> > +	/* Explicity enable/disable DMA for a
> > +         * particular memory window.
> > +         */
> > +	DOMAIN_ATTR_ENABLE,
> >  };
> >
> >  #ifdef CONFIG_IOMMU_API
> > --
> > 1.7.4.1
Joerg Roedel Dec. 2, 2012, 2:03 p.m. UTC | #3
Hmm, we need to work out a good abstraction for this.

On Tue, Nov 20, 2012 at 07:24:56PM +0530, Varun Sethi wrote:
> Added the following domain attributes required by FSL PAMU driver:
> 1. Subwindows field added to the iommu domain geometry attribute.

Are the Subwindows mapped with full size or do you map only parts of the
subwindows?

> +	 * This attribute indicates number of DMA subwindows supported by
> +	 * the geometry. If there is a single window that maps the entire
> +	 * geometry, attribute must be set to "1". A value of "0" implies
> +	 * that this mechanism is not used at all(normal paging is used).
> +	 * Value other than* "0" or "1" indicates the actual number of
> +	 * subwindows.
> +	 */

This semantic is ugly, how about a feature detection mechanism?

> +struct iommu_stash_attribute {
> +	u32 	cpu;	/* cpu number */
> +	u32 	cache;	/* cache to stash to: L1,L2,L3 */
>  };
>  
>  struct iommu_domain {
> @@ -60,6 +95,14 @@ struct iommu_domain {
>  enum iommu_attr {
>  	DOMAIN_ATTR_MAX,
>  	DOMAIN_ATTR_GEOMETRY,
> +	/* Set the IOMMU hardware stashing
> +	 * parameters.
> +	 */
> +	DOMAIN_ATTR_STASH,
> +	/* Explicity enable/disable DMA for a
> +         * particular memory window.
> +         */
> +	DOMAIN_ATTR_ENABLE,
>  };

When you add implementation specific attributes please add some
indication to the names that it is only for PAMU. DOMAIN_ATTR_STASH
sounds too generic.


	Joerg
Tabi Timur-B04825 Dec. 2, 2012, 3:11 p.m. UTC | #4
Joerg Roedel wrote:
> When you add implementation specific attributes please add some
> indication to the names that it is only for PAMU. DOMAIN_ATTR_STASH
> sounds too generic.

We were thinking that maybe this attribute could be useful to other IOMMUs 
in the future.  Stashing is not a concept that would only work on 
Freescale processors.

But we'll change it if you insist.
Sethi Varun-B16395 Dec. 3, 2012, 4:57 p.m. UTC | #5
> -----Original Message-----
> From: iommu-bounces@lists.linux-foundation.org [mailto:iommu-
> bounces@lists.linux-foundation.org] On Behalf Of Joerg Roedel
> Sent: Sunday, December 02, 2012 7:33 PM
> To: Sethi Varun-B16395
> Cc: linux-kernel@vger.kernel.org; iommu@lists.linux-foundation.org; Wood
> Scott-B07421; linuxppc-dev@lists.ozlabs.org; Tabi Timur-B04825
> Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> required by fsl PAMU driver.
> 
> Hmm, we need to work out a good abstraction for this.
> 
> On Tue, Nov 20, 2012 at 07:24:56PM +0530, Varun Sethi wrote:
> > Added the following domain attributes required by FSL PAMU driver:
> > 1. Subwindows field added to the iommu domain geometry attribute.
> 
> Are the Subwindows mapped with full size or do you map only parts of the
> subwindows?
> 
[Sethi Varun-B16395] It's possible to map a part of the subwindow i.e. size of the mapping can be less than the sub window size.

> > +	 * This attribute indicates number of DMA subwindows supported by
> > +	 * the geometry. If there is a single window that maps the entire
> > +	 * geometry, attribute must be set to "1". A value of "0" implies
> > +	 * that this mechanism is not used at all(normal paging is used).
> > +	 * Value other than* "0" or "1" indicates the actual number of
> > +	 * subwindows.
> > +	 */
> 
> This semantic is ugly, how about a feature detection mechanism?
> 
[Sethi Varun-B16395] A feature mechanism to query the type of IOMMU?

-Varun
Scott Wood Dec. 3, 2012, 5:03 p.m. UTC | #6
On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
> 
> 
> > -----Original Message-----
> > From: iommu-bounces@lists.linux-foundation.org [mailto:iommu-
> > bounces@lists.linux-foundation.org] On Behalf Of Joerg Roedel
> > Sent: Sunday, December 02, 2012 7:33 PM
> > To: Sethi Varun-B16395
> > Cc: linux-kernel@vger.kernel.org; iommu@lists.linux-foundation.org;  
> Wood
> > Scott-B07421; linuxppc-dev@lists.ozlabs.org; Tabi Timur-B04825
> > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> > required by fsl PAMU driver.
> >
> > Hmm, we need to work out a good abstraction for this.
> >
> > On Tue, Nov 20, 2012 at 07:24:56PM +0530, Varun Sethi wrote:
> > > Added the following domain attributes required by FSL PAMU driver:
> > > 1. Subwindows field added to the iommu domain geometry attribute.
> >
> > Are the Subwindows mapped with full size or do you map only parts  
> of the
> > subwindows?
> >
> [Sethi Varun-B16395] It's possible to map a part of the subwindow  
> i.e. size of the mapping can be less than the sub window size.
> 
> > > +	 * This attribute indicates number of DMA subwindows supported  
> by
> > > +	 * the geometry. If there is a single window that maps the  
> entire
> > > +	 * geometry, attribute must be set to "1". A value of "0"  
> implies
> > > +	 * that this mechanism is not used at all(normal paging is  
> used).
> > > +	 * Value other than* "0" or "1" indicates the actual number of
> > > +	 * subwindows.
> > > +	 */
> >
> > This semantic is ugly, how about a feature detection mechanism?
> >
> [Sethi Varun-B16395] A feature mechanism to query the type of IOMMU?

A feature mechanism to determine whether this subwindow mechanism is  
available, and what the limits are.

-Scott
Joerg Roedel Dec. 3, 2012, 5:27 p.m. UTC | #7
On Mon, Dec 03, 2012 at 04:57:29PM +0000, Sethi Varun-B16395 wrote:
> 
> 
> > -----Original Message-----
> > From: iommu-bounces@lists.linux-foundation.org [mailto:iommu-
> > bounces@lists.linux-foundation.org] On Behalf Of Joerg Roedel
> > Sent: Sunday, December 02, 2012 7:33 PM
> > To: Sethi Varun-B16395
> > Cc: linux-kernel@vger.kernel.org; iommu@lists.linux-foundation.org; Wood
> > Scott-B07421; linuxppc-dev@lists.ozlabs.org; Tabi Timur-B04825
> > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> > required by fsl PAMU driver.
> > 
> > Hmm, we need to work out a good abstraction for this.
> > 
> > On Tue, Nov 20, 2012 at 07:24:56PM +0530, Varun Sethi wrote:
> > > Added the following domain attributes required by FSL PAMU driver:
> > > 1. Subwindows field added to the iommu domain geometry attribute.
> > 
> > Are the Subwindows mapped with full size or do you map only parts of the
> > subwindows?
> > 
> [Sethi Varun-B16395] It's possible to map a part of the subwindow i.e.
> size of the mapping can be less than the sub window size.

Yes, I know that this is possible. But do you plan to support that or is
it sufficient when the whole subwindow is mapped?


	Joerg
Scott Wood Dec. 3, 2012, 5:36 p.m. UTC | #8
On 12/03/2012 11:27:12 AM, Joerg Roedel wrote:
> On Mon, Dec 03, 2012 at 04:57:29PM +0000, Sethi Varun-B16395 wrote:
> >
> >
> > > -----Original Message-----
> > > From: iommu-bounces@lists.linux-foundation.org [mailto:iommu-
> > > bounces@lists.linux-foundation.org] On Behalf Of Joerg Roedel
> > > Sent: Sunday, December 02, 2012 7:33 PM
> > > To: Sethi Varun-B16395
> > > Cc: linux-kernel@vger.kernel.org;  
> iommu@lists.linux-foundation.org; Wood
> > > Scott-B07421; linuxppc-dev@lists.ozlabs.org; Tabi Timur-B04825
> > > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> > > required by fsl PAMU driver.
> > >
> > > Hmm, we need to work out a good abstraction for this.
> > >
> > > On Tue, Nov 20, 2012 at 07:24:56PM +0530, Varun Sethi wrote:
> > > > Added the following domain attributes required by FSL PAMU  
> driver:
> > > > 1. Subwindows field added to the iommu domain geometry  
> attribute.
> > >
> > > Are the Subwindows mapped with full size or do you map only parts  
> of the
> > > subwindows?
> > >
> > [Sethi Varun-B16395] It's possible to map a part of the subwindow  
> i.e.
> > size of the mapping can be less than the sub window size.
> 
> Yes, I know that this is possible. But do you plan to support that or  
> is
> it sufficient when the whole subwindow is mapped?

We do plan to support that.

-Scott
Sethi Varun-B16395 Dec. 4, 2012, 11:53 a.m. UTC | #9
> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Monday, December 03, 2012 10:34 PM
> To: Sethi Varun-B16395
> Cc: Joerg Roedel; linux-kernel@vger.kernel.org; iommu@lists.linux-
> foundation.org; Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org; Tabi
> Timur-B04825
> Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> required by fsl PAMU driver.
> 
> On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
> >
> >
> > > -----Original Message-----
> > > From: iommu-bounces@lists.linux-foundation.org [mailto:iommu-
> > > bounces@lists.linux-foundation.org] On Behalf Of Joerg Roedel
> > > Sent: Sunday, December 02, 2012 7:33 PM
> > > To: Sethi Varun-B16395
> > > Cc: linux-kernel@vger.kernel.org; iommu@lists.linux-foundation.org;
> > Wood
> > > Scott-B07421; linuxppc-dev@lists.ozlabs.org; Tabi Timur-B04825
> > > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> > > required by fsl PAMU driver.
> > >
> > > Hmm, we need to work out a good abstraction for this.
> > >
> > > On Tue, Nov 20, 2012 at 07:24:56PM +0530, Varun Sethi wrote:
> > > > Added the following domain attributes required by FSL PAMU driver:
> > > > 1. Subwindows field added to the iommu domain geometry attribute.
> > >
> > > Are the Subwindows mapped with full size or do you map only parts
> > of the
> > > subwindows?
> > >
> > [Sethi Varun-B16395] It's possible to map a part of the subwindow i.e.
> > size of the mapping can be less than the sub window size.
> >
> > > > +	 * This attribute indicates number of DMA subwindows
> supported
> > by
> > > > +	 * the geometry. If there is a single window that maps the
> > entire
> > > > +	 * geometry, attribute must be set to "1". A value of "0"
> > implies
> > > > +	 * that this mechanism is not used at all(normal paging is
> > used).
> > > > +	 * Value other than* "0" or "1" indicates the actual number
> of
> > > > +	 * subwindows.
> > > > +	 */
> > >
> > > This semantic is ugly, how about a feature detection mechanism?
> > >
> > [Sethi Varun-B16395] A feature mechanism to query the type of IOMMU?
> 
> A feature mechanism to determine whether this subwindow mechanism is
> available, and what the limits are.
> 
So, we use the IOMMU capability interface to find out if IOMMU supports sub windows or not, right? But still number of sub windows would be specified as a part of the geometry and the valid value for sub windows would  0,1 or actual number of sub windows.

-Varun
Sethi Varun-B16395 Dec. 10, 2012, 10:10 a.m. UTC | #10
> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Tuesday, December 04, 2012 11:53 PM
> To: Sethi Varun-B16395
> Cc: Wood Scott-B07421; Joerg Roedel; linux-kernel@vger.kernel.org;
> iommu@lists.linux-foundation.org; linuxppc-dev@lists.ozlabs.org; Tabi
> Timur-B04825
> Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> required by fsl PAMU driver.
> 
> On 12/04/2012 05:53:33 AM, Sethi Varun-B16395 wrote:
> >
> >
> > > -----Original Message-----
> > > From: Wood Scott-B07421
> > > Sent: Monday, December 03, 2012 10:34 PM
> > > To: Sethi Varun-B16395
> > > Cc: Joerg Roedel; linux-kernel@vger.kernel.org; iommu@lists.linux-
> > > foundation.org; Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org;
> > Tabi
> > > Timur-B04825
> > > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> > > required by fsl PAMU driver.
> > >
> > > On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: iommu-bounces@lists.linux-foundation.org [mailto:iommu-
> > > > > bounces@lists.linux-foundation.org] On Behalf Of Joerg Roedel
> > > > > Sent: Sunday, December 02, 2012 7:33 PM
> > > > > To: Sethi Varun-B16395
> > > > > Cc: linux-kernel@vger.kernel.org;
> > iommu@lists.linux-foundation.org;
> > > > Wood
> > > > > Scott-B07421; linuxppc-dev@lists.ozlabs.org; Tabi Timur-B04825
> > > > > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain
> > attributes
> > > > > required by fsl PAMU driver.
> > > > >
> > > > > Hmm, we need to work out a good abstraction for this.
> > > > >
> > > > > On Tue, Nov 20, 2012 at 07:24:56PM +0530, Varun Sethi wrote:
> > > > > > Added the following domain attributes required by FSL PAMU
> > driver:
> > > > > > 1. Subwindows field added to the iommu domain geometry
> > attribute.
> > > > >
> > > > > Are the Subwindows mapped with full size or do you map only
> > parts
> > > > of the
> > > > > subwindows?
> > > > >
> > > > [Sethi Varun-B16395] It's possible to map a part of the subwindow
> > i.e.
> > > > size of the mapping can be less than the sub window size.
> > > >
> > > > > > +	 * This attribute indicates number of DMA subwindows
> > > supported
> > > > by
> > > > > > +	 * the geometry. If there is a single window that maps
> > the
> > > > entire
> > > > > > +	 * geometry, attribute must be set to "1". A value of
> > "0"
> > > > implies
> > > > > > +	 * that this mechanism is not used at all(normal paging
> > is
> > > > used).
> > > > > > +	 * Value other than* "0" or "1" indicates the actual
> > number
> > > of
> > > > > > +	 * subwindows.
> > > > > > +	 */
> > > > >
> > > > > This semantic is ugly, how about a feature detection mechanism?
> > > > >
> > > > [Sethi Varun-B16395] A feature mechanism to query the type of
> > IOMMU?
> > >
> > > A feature mechanism to determine whether this subwindow mechanism is
> > > available, and what the limits are.
> > >
> > So, we use the IOMMU capability interface to find out if IOMMU
> > supports sub windows or not, right? But still number of sub windows
> > would be specified as a part of the geometry and the valid value for
> > sub windows would  0,1 or actual number of sub windows.
> 
> How does a user of the interface find out what values are possible for
> the "actual number of subwindows"?  How does a user of the interface find
> out whether there are any limitations on specifying a value of zero (in
> the case of PAMU, that would be a maximum 1 MiB naturally-aligned
> aperture to support arbitrary 4KiB mappings)?
How about if we say that the default value for subwindows is zero and this what you get when you read the geometry (iommu_get_attr) after initializing the domain? In that case the user would know that implication of setting subwindows to zero with respect to the aperture size. Also, should we introduce an additional API like "iommu_check_attr", which the user can use to validate the attribute value. For example in case of geometry, the user can fill up the structure and pass it to the iommu driver in order to verify the aperture and subwindows field.

-Varun
Scott Wood Dec. 11, 2012, 1 a.m. UTC | #11
On 12/10/2012 04:10:06 AM, Sethi Varun-B16395 wrote:
> 
> 
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Tuesday, December 04, 2012 11:53 PM
> > To: Sethi Varun-B16395
> > Cc: Wood Scott-B07421; Joerg Roedel; linux-kernel@vger.kernel.org;
> > iommu@lists.linux-foundation.org; linuxppc-dev@lists.ozlabs.org;  
> Tabi
> > Timur-B04825
> > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> > required by fsl PAMU driver.
> >
> > On 12/04/2012 05:53:33 AM, Sethi Varun-B16395 wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Wood Scott-B07421
> > > > Sent: Monday, December 03, 2012 10:34 PM
> > > > To: Sethi Varun-B16395
> > > > Cc: Joerg Roedel; linux-kernel@vger.kernel.org;  
> iommu@lists.linux-
> > > > foundation.org; Wood Scott-B07421;  
> linuxppc-dev@lists.ozlabs.org;
> > > Tabi
> > > > Timur-B04825
> > > > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain  
> attributes
> > > > required by fsl PAMU driver.
> > > >
> > > > On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: iommu-bounces@lists.linux-foundation.org  
> [mailto:iommu-
> > > > > > bounces@lists.linux-foundation.org] On Behalf Of Joerg  
> Roedel
> > > > > > Sent: Sunday, December 02, 2012 7:33 PM
> > > > > > To: Sethi Varun-B16395
> > > > > > Cc: linux-kernel@vger.kernel.org;
> > > iommu@lists.linux-foundation.org;
> > > > > Wood
> > > > > > Scott-B07421; linuxppc-dev@lists.ozlabs.org; Tabi  
> Timur-B04825
> > > > > > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain
> > > attributes
> > > > > > required by fsl PAMU driver.
> > > > > >
> > > > > > Hmm, we need to work out a good abstraction for this.
> > > > > >
> > > > > > On Tue, Nov 20, 2012 at 07:24:56PM +0530, Varun Sethi wrote:
> > > > > > > Added the following domain attributes required by FSL PAMU
> > > driver:
> > > > > > > 1. Subwindows field added to the iommu domain geometry
> > > attribute.
> > > > > >
> > > > > > Are the Subwindows mapped with full size or do you map only
> > > parts
> > > > > of the
> > > > > > subwindows?
> > > > > >
> > > > > [Sethi Varun-B16395] It's possible to map a part of the  
> subwindow
> > > i.e.
> > > > > size of the mapping can be less than the sub window size.
> > > > >
> > > > > > > +	 * This attribute indicates number of DMA subwindows
> > > > supported
> > > > > by
> > > > > > > +	 * the geometry. If there is a single window that maps
> > > the
> > > > > entire
> > > > > > > +	 * geometry, attribute must be set to "1". A value of
> > > "0"
> > > > > implies
> > > > > > > +	 * that this mechanism is not used at all(normal paging
> > > is
> > > > > used).
> > > > > > > +	 * Value other than* "0" or "1" indicates the actual
> > > number
> > > > of
> > > > > > > +	 * subwindows.
> > > > > > > +	 */
> > > > > >
> > > > > > This semantic is ugly, how about a feature detection  
> mechanism?
> > > > > >
> > > > > [Sethi Varun-B16395] A feature mechanism to query the type of
> > > IOMMU?
> > > >
> > > > A feature mechanism to determine whether this subwindow  
> mechanism is
> > > > available, and what the limits are.
> > > >
> > > So, we use the IOMMU capability interface to find out if IOMMU
> > > supports sub windows or not, right? But still number of sub  
> windows
> > > would be specified as a part of the geometry and the valid value  
> for
> > > sub windows would  0,1 or actual number of sub windows.
> >
> > How does a user of the interface find out what values are possible  
> for
> > the "actual number of subwindows"?  How does a user of the  
> interface find
> > out whether there are any limitations on specifying a value of zero  
> (in
> > the case of PAMU, that would be a maximum 1 MiB naturally-aligned
> > aperture to support arbitrary 4KiB mappings)?
> How about if we say that the default value for subwindows is zero and  
> this what you get when you read the geometry (iommu_get_attr) after  
> initializing the domain? In that case the user would know that  
> implication of setting subwindows to zero with respect to the  
> aperture size.

So it would default to the maximum aperture size possible with no  
subwindows?  That might be OK, though is there a way to reset the  
domain later on to get back to that informational state?

How about finding out the maximum number of subwindows?

> Also, should we introduce an additional API like "iommu_check_attr",  
> which the user can use to validate the attribute value. For example  
> in case of geometry, the user can fill up the structure and pass it  
> to the iommu driver in order to verify the aperture and subwindows  
> field.

Doesn't the current API raise an error if you do something  
unsupported?  In any case I don't think making a series of guesses and  
seeing which ones are accepted is a good substitute for being able to  
simply read out the relevant parameters.

-Scott
Sethi Varun-B16395 Dec. 11, 2012, 4:50 a.m. UTC | #12
> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Tuesday, December 11, 2012 6:31 AM
> To: Sethi Varun-B16395
> Cc: Wood Scott-B07421; Joerg Roedel; linux-kernel@vger.kernel.org;
> iommu@lists.linux-foundation.org; linuxppc-dev@lists.ozlabs.org; Tabi
> Timur-B04825
> Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> required by fsl PAMU driver.
> 
> On 12/10/2012 04:10:06 AM, Sethi Varun-B16395 wrote:
> >
> >
> > > -----Original Message-----
> > > From: Wood Scott-B07421
> > > Sent: Tuesday, December 04, 2012 11:53 PM
> > > To: Sethi Varun-B16395
> > > Cc: Wood Scott-B07421; Joerg Roedel; linux-kernel@vger.kernel.org;
> > > iommu@lists.linux-foundation.org; linuxppc-dev@lists.ozlabs.org;
> > Tabi
> > > Timur-B04825
> > > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
> > > required by fsl PAMU driver.
> > >
> > > On 12/04/2012 05:53:33 AM, Sethi Varun-B16395 wrote:
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Wood Scott-B07421
> > > > > Sent: Monday, December 03, 2012 10:34 PM
> > > > > To: Sethi Varun-B16395
> > > > > Cc: Joerg Roedel; linux-kernel@vger.kernel.org;
> > iommu@lists.linux-
> > > > > foundation.org; Wood Scott-B07421;
> > linuxppc-dev@lists.ozlabs.org;
> > > > Tabi
> > > > > Timur-B04825
> > > > > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain
> > attributes
> > > > > required by fsl PAMU driver.
> > > > >
> > > > > On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
> > > > > >
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: iommu-bounces@lists.linux-foundation.org
> > [mailto:iommu-
> > > > > > > bounces@lists.linux-foundation.org] On Behalf Of Joerg
> > Roedel
> > > > > > > Sent: Sunday, December 02, 2012 7:33 PM
> > > > > > > To: Sethi Varun-B16395
> > > > > > > Cc: linux-kernel@vger.kernel.org;
> > > > iommu@lists.linux-foundation.org;
> > > > > > Wood
> > > > > > > Scott-B07421; linuxppc-dev@lists.ozlabs.org; Tabi
> > Timur-B04825
> > > > > > > Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain
> > > > attributes
> > > > > > > required by fsl PAMU driver.
> > > > > > >
> > > > > > > Hmm, we need to work out a good abstraction for this.
> > > > > > >
> > > > > > > On Tue, Nov 20, 2012 at 07:24:56PM +0530, Varun Sethi wrote:
> > > > > > > > Added the following domain attributes required by FSL PAMU
> > > > driver:
> > > > > > > > 1. Subwindows field added to the iommu domain geometry
> > > > attribute.
> > > > > > >
> > > > > > > Are the Subwindows mapped with full size or do you map only
> > > > parts
> > > > > > of the
> > > > > > > subwindows?
> > > > > > >
> > > > > > [Sethi Varun-B16395] It's possible to map a part of the
> > subwindow
> > > > i.e.
> > > > > > size of the mapping can be less than the sub window size.
> > > > > >
> > > > > > > > +	 * This attribute indicates number of DMA subwindows
> > > > > supported
> > > > > > by
> > > > > > > > +	 * the geometry. If there is a single window that maps
> > > > the
> > > > > > entire
> > > > > > > > +	 * geometry, attribute must be set to "1". A value of
> > > > "0"
> > > > > > implies
> > > > > > > > +	 * that this mechanism is not used at all(normal paging
> > > > is
> > > > > > used).
> > > > > > > > +	 * Value other than* "0" or "1" indicates the actual
> > > > number
> > > > > of
> > > > > > > > +	 * subwindows.
> > > > > > > > +	 */
> > > > > > >
> > > > > > > This semantic is ugly, how about a feature detection
> > mechanism?
> > > > > > >
> > > > > > [Sethi Varun-B16395] A feature mechanism to query the type of
> > > > IOMMU?
> > > > >
> > > > > A feature mechanism to determine whether this subwindow
> > mechanism is
> > > > > available, and what the limits are.
> > > > >
> > > > So, we use the IOMMU capability interface to find out if IOMMU
> > > > supports sub windows or not, right? But still number of sub
> > windows
> > > > would be specified as a part of the geometry and the valid value
> > for
> > > > sub windows would  0,1 or actual number of sub windows.
> > >
> > > How does a user of the interface find out what values are possible
> > for
> > > the "actual number of subwindows"?  How does a user of the
> > interface find
> > > out whether there are any limitations on specifying a value of zero
> > (in
> > > the case of PAMU, that would be a maximum 1 MiB naturally-aligned
> > > aperture to support arbitrary 4KiB mappings)?
> > How about if we say that the default value for subwindows is zero and
> > this what you get when you read the geometry (iommu_get_attr) after
> > initializing the domain? In that case the user would know that
> > implication of setting subwindows to zero with respect to the aperture
> > size.
> 
> So it would default to the maximum aperture size possible with no
> subwindows?  That might be OK, though is there a way to reset the domain
> later on to get back to that informational state?
> 
[Sethi Varun-B16395] Yes, that can be done via iommu_set_attr API.

> How about finding out the maximum number of subwindows?
[Sethi Varun-B16395] We can introduce an API to determine the permissible range of values for an attribute, but it may be redundant for other IOMMU implementations. For the IOMMU implementations where geometry is just a read only attribute, iommu_get_attr returns the set of permissible values. I think it would be better if we can add a read only field (for the users) "max_subwindows" to the geometry.

-Varun
diff mbox

Patch

diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index f3b99e1..7ca1cda 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -44,6 +44,41 @@  struct iommu_domain_geometry {
 	dma_addr_t aperture_start; /* First address that can be mapped    */
 	dma_addr_t aperture_end;   /* Last address that can be mapped     */
 	bool force_aperture;       /* DMA only allowed in mappable range? */
+
+	/*
+	 * A geometry mapping can be created in one of the following ways
+	 * for an IOMMU:
+	 * 1. A single contiguous window
+	 * 2. Through arbritary paging throughout the aperture.
+	 * 3. Using multiple subwindows
+	 *
+	 * In absence of arbritary paging, subwindows allow for supporting
+	 * physically discontiguous mappings.
+	 *
+	 * This attribute indicates number of DMA subwindows supported by
+	 * the geometry. If there is a single window that maps the entire
+	 * geometry, attribute must be set to "1". A value of "0" implies
+	 * that this mechanism is not used at all(normal paging is used).
+	 * Value other than* "0" or "1" indicates the actual number of
+	 * subwindows.
+	 */
+	u32 subwindows;
+};
+
+/* cache stash targets */
+#define IOMMU_ATTR_CACHE_L1 1
+#define IOMMU_ATTR_CACHE_L2 2
+#define IOMMU_ATTR_CACHE_L3 3
+
+/* This attribute corresponds to IOMMUs capable of generating
+ * a stash transaction. A stash transaction is typically a
+ * hardware initiated prefetch of data from memory to cache.
+ * This attribute allows configuring stashig specific parameters
+ * in the IOMMU hardware.
+ */
+struct iommu_stash_attribute {
+	u32 	cpu;	/* cpu number */
+	u32 	cache;	/* cache to stash to: L1,L2,L3 */
 };
 
 struct iommu_domain {
@@ -60,6 +95,14 @@  struct iommu_domain {
 enum iommu_attr {
 	DOMAIN_ATTR_MAX,
 	DOMAIN_ATTR_GEOMETRY,
+	/* Set the IOMMU hardware stashing
+	 * parameters.
+	 */
+	DOMAIN_ATTR_STASH,
+	/* Explicity enable/disable DMA for a
+         * particular memory window.
+         */
+	DOMAIN_ATTR_ENABLE,
 };
 
 #ifdef CONFIG_IOMMU_API