Skip to contentSkip to conversation

iommu/fsl: Freescale PAMU driver and IOMMU API implementation.

PATCH Applied Varun Sethi 7 participants 22 messages Nov 20, 2012 – Dec 11, 2012

Subsystems (2)

v1 of 6 Applied Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover iommu/fsl: Freescale PAMU driver and IOMMU API implementation.

This patchset provides the Freescale PAMU (Peripheral Access Management Unit) driver and the corresponding IOMMU API implementation. PAMU is the IOMMU present on Freescale QorIQ platforms. PAMU can authorize memory access, remap the memory address, and remap the I/O transaction type.

This set consists of the following patches:
1. Addition of new field in the device (powerpc) archdata structure for storing iommu domain information pointer. This pointer is stored when the device is attached to a particular iommu domain.
2. Add PAMU bypass enable register to the ccsr_guts structure.
3. Addition of domain attributes required by the PAMU driver IOMMU API.
4. PAMU driver and IOMMU API implementation.

This patch set is based on the next branch of the iommu git tree maintained by Joerg.

Varun Sethi (4):
store iommu domain pointer in device archdata structure. Add PAMU bypass enable register to ccsr_guts structure. Add attributes for fsl PAMU driver.
FSL PAMU driver.

 arch/powerpc/include/asm/device.h   |    4 +
 arch/powerpc/include/asm/fsl_guts.h |    4 +-
 drivers/iommu/Kconfig               |    8 +
 drivers/iommu/Makefile              |    1 +
 drivers/iommu/fsl_pamu.c            | 1152 +++++++++++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu.h            |  398 ++++++++++++++
 drivers/iommu/fsl_pamu_domain.c     |  978 +++++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h     |  102 ++++
 include/linux/iommu.h               |   43 +++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 2680 insertions(+), 1 deletions(-)
 create mode 100644 drivers/iommu/fsl_pamu.c
 create mode 100644 drivers/iommu/fsl_pamu.h
 create mode 100644 drivers/iommu/fsl_pamu_domain.c
 create mode 100644 drivers/iommu/fsl_pamu_domain.h
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH v2 1/4 iommu/fsl: Store iommu domain information pointer in archdata.

Add a new field in the device (powerpc) archdata structure for storing iommu domain information pointer. This pointer is stored when the device is attached to a particular domain.

---
 arch/powerpc/include/asm/device.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +4 -0
index 77e97dd..6dc79fe 100644
@@ -28,6 +28,10 @@ struct dev_archdata {
 		void		*iommu_table_base;
 	} dma_data;
 
+	/* IOMMU domain information pointer. This would be set
+	 * when this device is attached to an iommu_domain.
+	 */
+	void			*iommu_domain;
 #ifdef CONFIG_SWIOTLB
 	dma_addr_t		max_direct_dma_addr;
 #endif
Signature · 1 line
1.7.4.1
#2 lore raw

RE: [PATCH 1/4 v2] iommu/fsl: Store iommu domain information pointer in archdata.

Hi Kumar,
Can you please apply this patch.

Regards
Varun

Quoted 37 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Tuesday, November 20, 2012 7:25 PM
To: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Tabi Timur-B04825
Cc: Sethi Varun-B16395
Subject: [PATCH 1/4 v2] iommu/fsl: Store iommu domain information pointer
in archdata.

Add a new field in the device (powerpc) archdata structure for storing iommu domain information pointer. This pointer is stored when the device is attached to a particular domain.

---
 arch/powerpc/include/asm/device.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +4 -1
index 77e97dd..6dc79fe 100644
@@ -28,6 +28,10 @@ struct dev_archdata {
 		void		*iommu_table_base;
 	} dma_data;
 
+	/* IOMMU domain information pointer. This would be set
+	 * when this device is attached to an iommu_domain.
+	 */
+	void			*iommu_domain;
 #ifdef CONFIG_SWIOTLB
 	dma_addr_t		max_direct_dma_addr;
 #endif
--

1.7.4.1

#3 lore raw

Re: [PATCH 1/4 v2] iommu/fsl: Store iommu domain information pointer in archdata.

Quoted 5 lines · On Nov 25, 2012, at 11:33 PM, Sethi Varun-B16395 wrote:

Hi Kumar,
Can you please apply this patch.

Regards
Varun

Was waiting on the others to apply this all together. (ie getting an Ack from Joerg, and follow comments from Timur to be resolved)

- k

Quoted 39 lines
Quoted 38 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Tuesday, November 20, 2012 7:25 PM
To: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Tabi Timur-B04825
Cc: Sethi Varun-B16395
Subject: [PATCH 1/4 v2] iommu/fsl: Store iommu domain information pointer
in archdata.

Add a new field in the device (powerpc) archdata structure for storing iommu domain information pointer. This pointer is stored when the device is attached to a particular domain.

---
arch/powerpc/include/asm/device.h | 4 ++++

1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +4 -1
index 77e97dd..6dc79fe 100644
@@ -28,6 +28,10 @@ struct dev_archdata {
 		void		*iommu_table_base;
 	} dma_data;
 
+	/* IOMMU domain information pointer. This would be set
+	 * when this device is attached to an iommu_domain.
+	 */
+	void			*iommu_domain;
 #ifdef CONFIG_SWIOTLB
 	dma_addr_t		max_direct_dma_addr;
 #endif
--

1.7.4.1

#4 lore raw

PATCH 2/4 iommu/fsl: Add PAMU bypass enable register to ccsr_guts structure.

In reply to Varun Sethi

PAMU bypass enable register added to the ccsr_guts structure.

---
 arch/powerpc/include/asm/fsl_guts.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/powerpc/include/asm/fsl_guts.h +3 -1
index aa4c488..bb208eb 100644
@@ -69,7 +69,9 @@ struct ccsr_guts {
 	u8	res0c4[0x224 - 0xc4];
 	__be32  iodelay1;	/* 0x.0224 - IO delay control register 1 */
 	__be32  iodelay2;	/* 0x.0228 - IO delay control register 2 */
-	u8	res22c[0x800 - 0x22c];
+	u8	res22c[0x604 - 0x22c];
+	__be32	pamubypenr; 	/* 0x.604 - PAMU bypass enable register */
+	u8	res608[0x800 - 0x608];
 	__be32	clkdvdr;	/* 0x.0800 - Clock Divide Register */
 	u8	res804[0x900 - 0x804];
 	__be32	ircr;		/* 0x.0900 - Infrared Control Register */
Signature · 1 line
1.7.4.1
Applied
#5 lore raw

Re: [PATCH 2/4] iommu/fsl: Add PAMU bypass enable register to ccsr_guts structure.

Quoted 7 lines · Varun Sethi

PAMU bypass enable register added to the ccsr_guts structure.

---
arch/powerpc/include/asm/fsl_guts.h | 4 +++-

1 files changed, 3 insertions(+), 1 deletions(-)

applied to next

- k

#6 lore raw

PATCH v5 3/4 iommu/fsl: Add iommu domain attributes required by fsl PAMU driver.

In reply to Varun Sethi

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.

---
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(-)
include/linux/iommu.h +43 -0
index f3b99e1..7ca1cda 100644
@@ -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
Signature · 1 line
1.7.4.1
#7 lore raw

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

Quoted 93 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Tuesday, November 20, 2012 7:25 PM
To: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; 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.

---
changes in v5:
- Updated description of the subwindows field. changes in v4:
- Updated comment explaining subwindows(as mentioned by Scott). change in v3:

(quoted diff) +0 -1
-renamed the stash attribute targets
 include/linux/iommu.h |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
include/linux/iommu.h index renamed from include/linux/iommu.h +0 -0

f3b99e1..7ca1cda 100644

include/linux/iommu.h +35 -0
@@ -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 {

include/linux/iommu.h +8 -1
@@ -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

#8 lore raw

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

In reply to Varun Sethi

Ping!!

Quoted 109 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Monday, November 26, 2012 10:55 AM
To: [email protected]
Cc: Sethi Varun-B16395; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; 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

Quoted 18 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Tuesday, November 20, 2012 7:25 PM
To: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; 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.

Quoted 8 lines

---
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

+++++++++++++++++++++++++++++++++++++++++++

Quoted 66 lines
 1 files changed, 43 insertions(+), 0 deletions(-)
include/linux/iommu.h index renamed from include/linux/iommu.h +0 -0

f3b99e1..7ca1cda 100644

include/linux/iommu.h +35 -0
@@ -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 {

include/linux/iommu.h +8 -1
@@ -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

maintainer
#9 lore raw

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

In reply to Varun Sethi

Hmm, we need to work out a good abstraction for this.

Quoted 2 lines · Varun Sethi

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?

include/linux/iommu.h struct iommu_domain_geometry { · line 64

Quoted 7 lines
include/linux/iommu.h +7 -0
+	 * 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?

Quoted 9 lines
include/linux/iommu.h +3 -0
+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,

include/linux/iommu.h struct iommu_domain { · line 106

Quoted 10 lines
include/linux/iommu.h +8 -0
 	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

#10 lore raw

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

Quoted 3 lines · Joerg Roedel

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.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#11 lore raw

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

In reply to Joerg Roedel
Quoted 12 lines

-----Original Message-----
From: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org [mailto:iommu- bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org] On Behalf Of Joerg Roedel
Sent: Sunday, December 02, 2012 7:33 PM
To: Sethi Varun-B16395
Cc: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; Wood Scott-B07421; linuxppc-dev-uLR06cmDAlY/[email protected]; Tabi Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
required by fsl PAMU driver.

Quoted 9 lines

Hmm, we need to work out a good abstraction for this.

Quoted 2 lines · Varun Sethi

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.

Quoted 10 lines

include/linux/iommu.h struct iommu_domain_geometry { · line 64

Quoted 7 lines
include/linux/iommu.h +7 -0
+	 * 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

#12 lore raw

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

Quoted 33 lines · On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:iommu- [email protected]] On Behalf Of Joerg Roedel
Sent: Sunday, December 02, 2012 7:33 PM
To: Sethi Varun-B16395
Cc: [email protected]; [email protected];

Wood

Quoted 11 lines

Scott-B07421; [email protected]; 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.

Quoted 2 lines · Varun Sethi

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

Quoted 2 lines

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.

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * This attribute indicates number of DMA subwindows supported  

by

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * the geometry. If there is a single window that maps the  

entire

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * geometry, attribute must be set to "1". A value of "0"  

implies

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * that this mechanism is not used at all(normal paging is  

used).

Quoted 7 lines
Quoted 6 lines

include/linux/iommu.h struct iommu_domain_geometry { · line 64

Quoted 3 lines
include/linux/iommu.h +3 -0
+	 * 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

#13 lore raw

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

Quoted 55 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Monday, December 03, 2012 10:34 PM
To: Sethi Varun-B16395
Cc: Joerg Roedel; [email protected]; iommu-cunTk1MwBs/[email protected] foundation.org; Wood Scott-B07421; linuxppc-dev-uLR06cmDAlY/[email protected]; Tabi Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
required by fsl PAMU driver.

Quoted 19 lines · On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
Quoted 8 lines

-----Original Message-----
From: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org [mailto:iommu- bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org] On Behalf Of Joerg Roedel
Sent: Sunday, December 02, 2012 7:33 PM
To: Sethi Varun-B16395
Cc: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org;

Wood

Quoted 10 lines

Scott-B07421; linuxppc-dev-uLR06cmDAlY/[email protected]; 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.

Quoted 2 lines · Varun Sethi

Added the following domain attributes required by FSL PAMU driver:
1. Subwindows field added to the iommu domain geometry attribute.

Quoted 8 lines
Quoted 1 line

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

of the

Quoted 2 lines

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.

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * This attribute indicates number of DMA subwindows

supported

Quoted 8 lines

by

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * the geometry. If there is a single window that maps the

entire

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * geometry, attribute must be set to "1". A value of "0"

implies

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * that this mechanism is not used at all(normal paging is

used).

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * Value other than* "0" or "1" indicates the actual number

of

Quoted 5 lines
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	 * subwindows.
+	 */

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

Quoted 5 lines
Quoted 1 line

[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

#14 lore raw

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

Quoted 66 lines · On 12/04/2012 05:53:33 AM, Sethi Varun-B16395 wrote:
Quoted 8 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Monday, December 03, 2012 10:34 PM
To: Sethi Varun-B16395
Cc: Joerg Roedel; [email protected]; [email protected] foundation.org; Wood Scott-B07421; [email protected];

Tabi

Quoted 4 lines

Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes required by fsl PAMU driver.

Quoted 9 lines
Quoted 8 lines · On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:iommu- [email protected]] On Behalf Of Joerg Roedel
Sent: Sunday, December 02, 2012 7:33 PM
To: Sethi Varun-B16395
Cc: [email protected];

[email protected];

Quoted 3 lines
Quoted 3 lines

Wood

Quoted 2 lines

Scott-B07421; [email protected]; Tabi Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain

attributes

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

required by fsl PAMU driver.

Hmm, we need to work out a good abstraction for this.

Quoted 1 line · Varun Sethi

Added the following domain attributes required by FSL PAMU

driver:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

1. Subwindows field added to the iommu domain geometry

attribute.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Are the Subwindows mapped with full size or do you map only

parts

Quoted 4 lines
Quoted 4 lines

of the

Quoted 2 lines

subwindows?

[Sethi Varun-B16395] It's possible to map a part of the subwindow

i.e.

Quoted 6 lines
Quoted 3 lines

size of the mapping can be less than the sub window size.

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * This attribute indicates number of DMA subwindows

supported

Quoted 2 lines

by

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * the geometry. If there is a single window that maps  

the

Quoted 2 lines
Quoted 2 lines

entire

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * geometry, attribute must be set to "1". A value of  

"0"

Quoted 2 lines
Quoted 2 lines

implies

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * that this mechanism is not used at all(normal paging  

is

Quoted 2 lines
Quoted 2 lines

used).

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * Value other than* "0" or "1" indicates the actual  

number

Quoted 6 lines

of

Quoted 5 lines
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	 * subwindows.
+	 */

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

Quoted 7 lines
Quoted 1 line
Quoted 1 line

[Sethi Varun-B16395] A feature mechanism to query the type of

IOMMU?

Quoted 4 lines

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)?

-Scott

#15 lore raw

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

Quoted 90 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Tuesday, December 04, 2012 11:53 PM
To: Sethi Varun-B16395
Cc: Wood Scott-B07421; Joerg Roedel; [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; Tabi Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
required by fsl PAMU driver.

Quoted 69 lines · On 12/04/2012 05:53:33 AM, Sethi Varun-B16395 wrote:
Quoted 8 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Monday, December 03, 2012 10:34 PM
To: Sethi Varun-B16395
Cc: Joerg Roedel; [email protected]; iommu-cunTk1MwBs/[email protected] foundation.org; Wood Scott-B07421; linuxppc-dev-uLR06cmDAlY/[email protected];

Tabi

Quoted 4 lines

Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes required by fsl PAMU driver.

Quoted 9 lines
Quoted 8 lines · On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
Quoted 8 lines

-----Original Message-----
From: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org [mailto:iommu- bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org] On Behalf Of Joerg Roedel
Sent: Sunday, December 02, 2012 7:33 PM
To: Sethi Varun-B16395
Cc: [email protected];

iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org;

Quoted 3 lines
Quoted 3 lines

Wood

Quoted 2 lines

Scott-B07421; linuxppc-dev-uLR06cmDAlY/[email protected]; Tabi Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain

attributes

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

required by fsl PAMU driver.

Hmm, we need to work out a good abstraction for this.

Quoted 1 line · Varun Sethi

Added the following domain attributes required by FSL PAMU

driver:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

1. Subwindows field added to the iommu domain geometry

attribute.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Are the Subwindows mapped with full size or do you map only

parts

Quoted 4 lines
Quoted 4 lines

of the

Quoted 2 lines

subwindows?

[Sethi Varun-B16395] It's possible to map a part of the subwindow

i.e.

Quoted 6 lines
Quoted 3 lines

size of the mapping can be less than the sub window size.

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * This attribute indicates number of DMA subwindows

supported

Quoted 2 lines

by

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * the geometry. If there is a single window that maps

the

Quoted 2 lines
Quoted 2 lines

entire

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * geometry, attribute must be set to "1". A value of

"0"

Quoted 2 lines
Quoted 2 lines

implies

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * that this mechanism is not used at all(normal paging

is

Quoted 2 lines
Quoted 2 lines

used).

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * Value other than* "0" or "1" indicates the actual

number

Quoted 7 lines

of

Quoted 6 lines
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	 * subwindows.
+	 */

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

[Sethi Varun-B16395] A feature mechanism to query the type of

IOMMU?

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

#16 lore raw

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

Quoted 103 lines · On 12/10/2012 04:10:06 AM, Sethi Varun-B16395 wrote:
Quoted 8 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Tuesday, December 04, 2012 11:53 PM
To: Sethi Varun-B16395
Cc: Wood Scott-B07421; Joerg Roedel; [email protected]; [email protected]; [email protected];

Tabi

Quoted 4 lines

Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes required by fsl PAMU driver.

Quoted 8 lines
Quoted 7 lines · On 12/04/2012 05:53:33 AM, Sethi Varun-B16395 wrote:
Quoted 7 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Monday, December 03, 2012 10:34 PM
To: Sethi Varun-B16395
Cc: Joerg Roedel; [email protected];

[email protected]

Quoted 1 line
Quoted 1 line
Quoted 1 line

foundation.org; Wood Scott-B07421;

[email protected];

Quoted 3 lines
Quoted 3 lines

Tabi

Quoted 2 lines

Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain

attributes

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

required by fsl PAMU driver.

Quoted 4 lines · On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
Quoted 4 lines

-----Original Message-----
From: [email protected]

[mailto:iommu-

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

[email protected]] On Behalf Of Joerg

Roedel

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Sent: Sunday, December 02, 2012 7:33 PM
To: Sethi Varun-B16395
Cc: [email protected];

[email protected];

Quoted 2 lines
Quoted 2 lines

Wood

Quoted 1 line

Scott-B07421; [email protected]; Tabi

Timur-B04825

Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain

attributes

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

required by fsl PAMU driver.

Hmm, we need to work out a good abstraction for this.

Quoted 1 line · Varun Sethi

Added the following domain attributes required by FSL PAMU

driver:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

1. Subwindows field added to the iommu domain geometry

Quoted 8 lines
Quoted 8 lines

attribute.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Are the Subwindows mapped with full size or do you map only

parts

Quoted 4 lines
Quoted 4 lines

of the

Quoted 2 lines

subwindows?

[Sethi Varun-B16395] It's possible to map a part of the

subwindow

Quoted 14 lines
Quoted 14 lines

i.e.

Quoted 6 lines
Quoted 3 lines

size of the mapping can be less than the sub window size.

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * This attribute indicates number of DMA subwindows

supported

Quoted 2 lines

by

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * the geometry. If there is a single window that maps

the

Quoted 2 lines
Quoted 2 lines

entire

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * geometry, attribute must be set to "1". A value of

"0"

Quoted 2 lines
Quoted 2 lines

implies

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * that this mechanism is not used at all(normal paging

is

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

used).

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * Value other than* "0" or "1" indicates the actual

number

Quoted 5 lines

of

Quoted 4 lines
Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	 * subwindows.
+	 */

This semantic is ugly, how about a feature detection

mechanism?

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

[Sethi Varun-B16395] A feature mechanism to query the type of

IOMMU?

Quoted 2 lines

A feature mechanism to determine whether this subwindow

mechanism is

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

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

Quoted 1 line
Quoted 1 line

would be specified as a part of the geometry and the valid value

for

Quoted 3 lines
Quoted 1 line

sub windows would 0,1 or actual number of sub windows.

How does a user of the interface find out what values are possible

Quoted 8 lines

for

Quoted 1 line

the "actual number of subwindows"? How does a user of the

interface find

Quoted 1 line

out whether there are any limitations on specifying a value of zero

(in

Quoted 2 lines

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?

Quoted 1 line

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

#17 lore raw

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

Quoted 129 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Tuesday, December 11, 2012 6:31 AM
To: Sethi Varun-B16395
Cc: Wood Scott-B07421; Joerg Roedel; [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; Tabi Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes
required by fsl PAMU driver.

Quoted 107 lines · On 12/10/2012 04:10:06 AM, Sethi Varun-B16395 wrote:
Quoted 8 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Tuesday, December 04, 2012 11:53 PM
To: Sethi Varun-B16395
Cc: Wood Scott-B07421; Joerg Roedel; [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected];

Tabi

Quoted 4 lines

Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain attributes required by fsl PAMU driver.

Quoted 8 lines
Quoted 7 lines · On 12/04/2012 05:53:33 AM, Sethi Varun-B16395 wrote:
Quoted 7 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Monday, December 03, 2012 10:34 PM
To: Sethi Varun-B16395
Cc: Joerg Roedel; [email protected];

iommu-cunTk1MwBs/[email protected]

Quoted 1 line
Quoted 1 line
Quoted 1 line

foundation.org; Wood Scott-B07421;

linuxppc-dev-uLR06cmDAlY/[email protected];

Quoted 3 lines
Quoted 3 lines

Tabi

Quoted 2 lines

Timur-B04825
Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain

attributes

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

required by fsl PAMU driver.

Quoted 4 lines · On 12/03/2012 10:57:29 AM, Sethi Varun-B16395 wrote:
Quoted 4 lines

-----Original Message-----
From: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org

[mailto:iommu-

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org] On Behalf Of Joerg

Roedel

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Sent: Sunday, December 02, 2012 7:33 PM
To: Sethi Varun-B16395
Cc: [email protected];

iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org;

Quoted 2 lines
Quoted 2 lines

Wood

Quoted 1 line

Scott-B07421; linuxppc-dev-uLR06cmDAlY/[email protected]; Tabi

Timur-B04825

Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 3/4 v5] iommu/fsl: Add iommu domain

attributes

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

required by fsl PAMU driver.

Hmm, we need to work out a good abstraction for this.

Quoted 1 line · Varun Sethi

Added the following domain attributes required by FSL PAMU

driver:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

1. Subwindows field added to the iommu domain geometry

Quoted 8 lines
Quoted 8 lines

attribute.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Are the Subwindows mapped with full size or do you map only

parts

Quoted 4 lines
Quoted 4 lines

of the

Quoted 2 lines

subwindows?

[Sethi Varun-B16395] It's possible to map a part of the

subwindow

Quoted 14 lines
Quoted 14 lines

i.e.

Quoted 6 lines
Quoted 3 lines

size of the mapping can be less than the sub window size.

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * This attribute indicates number of DMA subwindows

supported

Quoted 2 lines

by

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * the geometry. If there is a single window that maps

the

Quoted 2 lines
Quoted 2 lines

entire

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * geometry, attribute must be set to "1". A value of

"0"

Quoted 2 lines
Quoted 2 lines

implies

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * that this mechanism is not used at all(normal paging

is

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

used).

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * Value other than* "0" or "1" indicates the actual

number

Quoted 5 lines

of

Quoted 4 lines
Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	 * subwindows.
+	 */

This semantic is ugly, how about a feature detection

mechanism?

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

[Sethi Varun-B16395] A feature mechanism to query the type of

IOMMU?

Quoted 2 lines

A feature mechanism to determine whether this subwindow

mechanism is

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

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

Quoted 1 line
Quoted 1 line

would be specified as a part of the geometry and the valid value

for

Quoted 3 lines
Quoted 1 line

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

Quoted 1 line

the "actual number of subwindows"? How does a user of the

interface find

Quoted 1 line

out whether there are any limitations on specifying a value of zero

Quoted 8 lines

(in

Quoted 2 lines

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.

Quoted 4 lines

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.

Quoted 1 line

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

maintainer
#18 lore raw

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

In reply to Sethi Varun-B16395
Quoted 15 lines · On Mon, Dec 03, 2012 at 04:57:29PM +0000, Sethi Varun-B16395 wrote:
Quoted 15 lines

-----Original Message-----
From: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org [mailto:iommu- bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org] On Behalf Of Joerg Roedel
Sent: Sunday, December 02, 2012 7:33 PM
To: Sethi Varun-B16395
Cc: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; Wood Scott-B07421; linuxppc-dev-uLR06cmDAlY/[email protected]; 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:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

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

#19 lore raw

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

Quoted 24 lines · Joerg Roedel
Quoted 8 lines · On Mon, Dec 03, 2012 at 04:57:29PM +0000, Sethi Varun-B16395 wrote:
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:iommu- [email protected]] On Behalf Of Joerg Roedel
Sent: Sunday, December 02, 2012 7:33 PM
To: Sethi Varun-B16395
Cc: [email protected];

[email protected]; Wood

Quoted 8 lines
Quoted 8 lines

Scott-B07421; [email protected]; 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.

Quoted 1 line · Varun Sethi

Added the following domain attributes required by FSL PAMU

driver:

Quoted 1 line
Quoted 1 line
Quoted 1 line

1. Subwindows field added to the iommu domain geometry

attribute.

Quoted 2 lines
Quoted 2 lines

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

of the

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

subwindows?

[Sethi Varun-B16395] It's possible to map a part of the subwindow

i.e.

Quoted 1 line

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

#20 lore raw

PATCH v5 4/4 iommu/fsl: Freescale PAMU driver and IOMMU API implementation.

In reply to Varun Sethi

Following is a brief description of the PAMU hardware:
PAMU determines what action to take and whether to authorize the action on the basis of the memory address, a Logical IO Device Number (LIODN), and PAACT table (logically) indexed by LIODN and address. Hardware devices which need to access memory must provide an LIODN in addition to the memory address.

Peripheral Access Authorization and Control Tables (PAACTs) are the primary data structures used by PAMU. A PAACT is a table of peripheral access authorization and control entries (PAACE).Each PAACE defines the range of I/O bus address space that is accessible by the LIOD and the associated access capabilities.

There are two types of PAACTs: primary PAACT (PPAACT) and secondary PAACT (SPAACT).A given physical I/O device may be able to act as one or more independent logical I/O devices (LIODs). Each such logical I/O device is assigned an identifier called logical I/O device number (LIODN). A LIODN is allocated a contiguous portion of the I/O bus address space called the DSA window for performing DSA operations. The DSA window may optionally be divided into multiple sub-windows, each of which may be used to map to a region in system storage space. The first sub-window is referred to as the primary sub-window and the remaining are called secondary sub-windows.

This patch provides the PAMU driver (fsl_pamu.c) and the corresponding IOMMU API implementation (fsl_pamu_domain.c). The PAMU hardware driver (fsl_pamu.c) has been derived from the work done by Ashish Kalra and Timur Tabi ([email protected]).

---
changes in v5:
- Addressed comments from Timur.
changes in v4:
- Addressed comments from Timur and Scott.
changes in v3:
- Addressed comments by Kumar Gala
- dynamic fspi allocation
- fixed alignment check in map and unmap

 drivers/iommu/Kconfig           |    8 +
 drivers/iommu/Makefile          |    1 +
 drivers/iommu/fsl_pamu.c        | 1152 +++++++++++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu.h        |  398 ++++++++++++++
 drivers/iommu/fsl_pamu_domain.c |  978 +++++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h |  102 ++++
 6 files changed, 2639 insertions(+), 0 deletions(-)
 create mode 100644 drivers/iommu/fsl_pamu.c
 create mode 100644 drivers/iommu/fsl_pamu.h
 create mode 100644 drivers/iommu/fsl_pamu_domain.c
 create mode 100644 drivers/iommu/fsl_pamu_domain.h
drivers/iommu/Kconfig +8 -0
index e39f9db..f712da2 100644
@@ -17,6 +17,14 @@ config OF_IOMMU
        def_bool y
        depends on OF
 
+config FSL_PAMU
+	bool "Freescale IOMMU support"
+	depends on PPC_E500MC
+	select IOMMU_API
+	select GENERIC_ALLOCATOR
+	help
+	  Freescale PAMU support.
+
 # MSM IOMMU support
 config MSM_IOMMU
 	bool "MSM IOMMU Support"
drivers/iommu/Makefile +1 -0
index 14a4d5f..a565ebe 100644
@@ -12,3 +12,4 @@ obj-$(CONFIG_OMAP_IOMMU_DEBUG) += omap-iommu-debug.o
 obj-$(CONFIG_TEGRA_IOMMU_GART) += tegra-gart.o
 obj-$(CONFIG_TEGRA_IOMMU_SMMU) += tegra-smmu.o
 obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iommu.o
+obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o
drivers/iommu/fsl_pamu.c new file +1152 -0

1,152 lines not on this page · raw message

drivers/iommu/fsl_pamu.h new file +398 -0

398 lines not on this page · raw message

drivers/iommu/fsl_pamu_domain.c new file +978 -0

978 lines not on this page · raw message

drivers/iommu/fsl_pamu_domain.h new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#21 lore raw
Quoted 64 lines · Varun Sethi
drivers/iommu/fsl_pamu.h new file +58 -0
new file mode 100644
index 0000000..6d32fb5
@@ -0,0 +1,398 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ *
+ */
+
+#ifndef __FSL_PAMU_H
+#define __FSL_PAMU_H
+
+/* Bit Field macros
+ * 	v = bit field variable; m = mask, m##_SHIFT = shift, x = value to load
+ */
+#define set_bf(v, m, x)		(v = ((v) & ~(m)) | (((x) << (m##_SHIFT)) & (m)))
+#define get_bf(v, m)		(((v) & (m)) >> (m##_SHIFT))
+
+/* PAMU CCSR space */
+#define PAMU_PGC 0x00000000     /* Allows all peripheral accesses */
+#define PAMU_PE 0x40000000      /* enable PAMU                    */
+
+/* PAMU_OFFSET to the next pamu space in ccsr */
+#define PAMU_OFFSET 0x1000
+
+#define PAMU_MMAP_REGS_BASE 0
+
+struct pamu_mmap_regs {
+	u32 ppbah;
+	u32 ppbal;
+	u32 pplah;
+	u32 pplal;
+	u32 spbah;
+	u32 spbal;
+	u32 splah;
+	u32 splal;
+	u32 obah;
+	u32 obal;
+	u32 olah;
+	u32 olal;
+};
+
+/* PAMU Error Registers */
+#define PAMU_POES1 0x0040
+#define PAMU_POES2 0x0044
+#define PAMU_POEAH 0x0048
+#define PAMU_POEAL 0x004C
+#define PAMU_AVS1  0x0050
+#define PAMU_AVS1_AV    0x1

drivers/iommu/fsl_pamu.h line 68

Quoted 10 lines
drivers/iommu/fsl_pamu.h new file +10 -0
+#define PAMU_AVS1_OTV   0x6
+#define PAMU_AVS1_APV   0x78
+#define PAMU_AVS1_WAV   0x380
+#define PAMU_AVS1_LAV   0x1c00
+#define PAMU_AVS1_GCV   0x2000
+#define PAMU_AVS1_PDV   0x4000
+#define PAMU_AV_MASK    (PAMU_AVS1_AV | PAMU_AVS1_OTV | PAMU_AVS1_APV | PAMU_AVS1_WAV \
+			| PAMU_AVS1_LAV | PAMU_AVS1_GCV | PAMU_AVS1_PDV)
+#define PAMU_AVS1_LIODN_SHIFT 16
+#define PAMU_LAV_LIODN_NOT_IN_PPAACT 0x400

I think you can move most of macros in this .h file into one of the .c files.

drivers/iommu/fsl_pamu_domain.c

Quoted 5 lines
drivers/iommu/fsl_pamu_domain.c new file +0 -0
new file mode 100644
index 0000000..d473447

The code in this file is generally hard to read because you

1) have very few comments
2) you have a lot of expressions that span several lines, like this one:

		if ((iova >= geom_attr->aperture_start &&
			iova < geom_attr->aperture_end - 1 &&
			size <= geom_size) &&
			!align_check) {

Try adding a few more comments (e.g. each function should be commented) and maybe try to break up a few of these lines.

Quoted 11 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
@@ -0,0 +1,978 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *

drivers/iommu/fsl_pamu_domain.c line 20

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ * Author: Varun Sethi <[email protected]>
+ *
+ */
+
+#define pr_fmt(fmt)    "fsl-pamu-domain: %s: " fmt, __func__

You don't use this macro.

Quoted 33 lines
drivers/iommu/fsl_pamu_domain.c new file +33 -0
+
+#include <linux/init.h>
+#include <linux/iommu.h>
+#include <linux/notifier.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/of_platform.h>
+#include <linux/bootmem.h>
+#include <linux/err.h>
+#include <asm/io.h>
+#include <asm/bitops.h>
+
+#include "fsl_pamu_domain.h"
+
+/* This bitmap advertises the page sizes supported by PAMU hardware
+ * to the IOMMU API.
+ */
+#define FSL_PAMU_PGSIZES	(~0xFFFUL)
+
+/* global spinlock that needs to be held while
+ * configuring PAMU.
+ */
+static DEFINE_SPINLOCK(iommu_lock);
+
+static struct kmem_cache *fsl_pamu_domain_cache;
+static struct kmem_cache *iommu_devinfo_cache;
+static DEFINE_SPINLOCK(device_domain_lock);
+
+int __init iommu_init_mempool(void)

drivers/iommu/fsl_pamu_domain.c line 63

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+{
+
+	fsl_pamu_domain_cache = kmem_cache_create("fsl_pamu_domain",
+					 sizeof(struct fsl_dma_domain),
+					 0,
+					 SLAB_HWCACHE_ALIGN,
+
+					 NULL);
+	if (!fsl_pamu_domain_cache) {
+		pr_err("Couldn't create fsl iommu_domain cache\n");

ALL of these pr_xxx functions (in the entire file) need to have a "fsl-pamu-domain:" prefix. Maybe that's why you created pr_fmt(), but you forgot to use it.

The above message should look like this:

	pr_err("fsl-pamu-domain: could not create iommu domain cache\n");
Quoted 89 lines
drivers/iommu/fsl_pamu_domain.c new file +89 -0
+		return -ENOMEM;
+	}
+
+	iommu_devinfo_cache = kmem_cache_create("iommu_devinfo",
+					 sizeof(struct device_domain_info),
+					 0,
+					 SLAB_HWCACHE_ALIGN,
+					 NULL);
+	if (!iommu_devinfo_cache) {
+		pr_err("Couldn't create devinfo cache\n");
+		kmem_cache_destroy(fsl_pamu_domain_cache);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
+
+static int reconfig_win(int liodn, struct fsl_dma_domain *domain)
+{
+	int ret;
+
+	spin_lock(&iommu_lock);
+	ret = pamu_config_ppaace(liodn, domain->mapped_iova,
+				 domain->mapped_size,
+				 ~(u32)0,
+				 domain->paddr >> PAMU_PAGE_SHIFT,
+				 domain->snoop_id, domain->stash_id,
+				 0, domain->prot);
+	spin_unlock(&iommu_lock);
+	if (ret) {
+		pr_err("PAMU PAACE configuration failed for liodn %d\n",
+			 liodn);
+	}
+	return ret;
+}
+
+static void update_domain_subwin(struct fsl_dma_domain *dma_domain,
+				unsigned long iova, size_t size,
+				phys_addr_t paddr, int prot, int status)
+{
+	struct iommu_domain *domain = dma_domain->iommu_domain;
+	u32 subwin_cnt = dma_domain->subwin_cnt;
+	dma_addr_t geom_size = dma_domain->geom_size;
+	u32 subwin_size;
+	u32 mapped_subwin;
+	u32 mapped_subwin_cnt;
+	struct dma_subwindow *sub_win_ptr;
+	int i;
+
+	subwin_size = geom_size >> ilog2(subwin_cnt);
+	mapped_subwin = (iova - domain->geometry.aperture_start)
+				 >> ilog2(subwin_size);
+	sub_win_ptr = &dma_domain->sub_win_arr[mapped_subwin];
+	mapped_subwin_cnt = (size < subwin_size) ? 1 :
+				size >> ilog2(subwin_size);
+	for (i = 0; i < mapped_subwin_cnt; i++) {
+		if (status) {
+			sub_win_ptr[i].paddr = paddr;
+			sub_win_ptr[i].size = (size < subwin_size) ?
+						 size : subwin_size;
+			paddr += subwin_size;
+			sub_win_ptr[i].iova = iova;
+			iova += subwin_size;
+		}
+		sub_win_ptr[i].valid = status;
+		sub_win_ptr[i].prot = prot;
+	}
+
+	dma_domain->mapped_subwin = mapped_subwin;
+	dma_domain->mapped_subwin_cnt =  mapped_subwin_cnt;
+}
+
+static int reconfig_subwin(int liodn, struct fsl_dma_domain *dma_domain)
+{
+	u32 subwin_cnt = dma_domain->subwin_cnt;
+	int ret = 0;
+	u32 mapped_subwin;
+	u32 mapped_subwin_cnt;
+	struct dma_subwindow *sub_win_ptr;
+	unsigned long rpn;
+	int i;
+
+	mapped_subwin = dma_domain->mapped_subwin;
+	mapped_subwin_cnt = dma_domain->mapped_subwin_cnt;
+	sub_win_ptr = &dma_domain->sub_win_arr[mapped_subwin];
+
+	for (i = 0; i < mapped_subwin_cnt; i++) {
+		rpn = sub_win_ptr[i].paddr >> PAMU_PAGE_SHIFT,

drivers/iommu/fsl_pamu_domain.c line 162

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+	
+		spin_lock(&iommu_lock);
+		ret = pamu_config_spaace(liodn, subwin_cnt, mapped_subwin,
+					 sub_win_ptr[i].size,
+					 ~(u32)0, 
+					 rpn, dma_domain->snoop_id,
+					 dma_domain->stash_id, 
+					 (mapped_subwin == 0 &&
+					 !dma_domain->enabled) ?
+					 0 : sub_win_ptr[i].valid,

Break out this expression into another variable. This code is illegible.

	int enabled = 0;
	
	for (...
		if (mapped_subwin || dma_domain->enabled)
			enabled = sub_win_ptr[i].valid;
Quoted 71 lines
drivers/iommu/fsl_pamu_domain.c new file +71 -0
+					 sub_win_ptr[i].prot);
+		spin_unlock(&iommu_lock);
+		if (ret) {
+			pr_err("PAMU SPAACE configuration failed for liodn %d\n",liodn);
+			return ret;
+		}
+		mapped_subwin++;
+	}
+
+	return ret;
+}
+
+static phys_addr_t get_phys_addr(struct fsl_dma_domain *dma_domain, unsigned long iova)
+{
+	u32 subwin_cnt = dma_domain->subwin_cnt;
+
+	if (subwin_cnt) {
+		int i;
+		struct dma_subwindow *sub_win_ptr = 
+					&dma_domain->sub_win_arr[0];
+
+		for (i = 0; i < subwin_cnt; i++) {
+			if (sub_win_ptr[i].valid &&
+			    iova >= sub_win_ptr[i].iova &&
+			    iova < (sub_win_ptr[i].iova +
+			    sub_win_ptr[i].size - 1))
+				return (sub_win_ptr[i].paddr + (iova &
+					(sub_win_ptr[i].size - 1)));
+		}
+	} else {
+		return (dma_domain->paddr + (iova & (dma_domain->mapped_size - 1)));
+	}
+
+	return 0;
+}
+
+static int map_liodn_subwins(int liodn, struct fsl_dma_domain *dma_domain, u32 subwin_cnt)
+{
+	struct dma_subwindow *sub_win_ptr = 
+				&dma_domain->sub_win_arr[0];
+	int i, ret;
+	unsigned long rpn;
+
+	for (i = 0; i < subwin_cnt; i++) {
+		if (sub_win_ptr[i].valid) {
+			rpn = sub_win_ptr[i].paddr >>
+				 PAMU_PAGE_SHIFT,
+			spin_lock(&iommu_lock);
+			ret = pamu_config_spaace(liodn, subwin_cnt, i,
+						 sub_win_ptr[i].size,
+						 ~(u32)0,
+						 rpn,
+						 dma_domain->snoop_id,
+						 dma_domain->stash_id,
+						 (i > 0) ? 1 : 0,
+						 sub_win_ptr[i].prot);
+			spin_unlock(&iommu_lock);
+			if (ret) {
+				pr_err("PAMU SPAACE configuration failed for liodn %d\n",
+					 liodn);
+				return ret;
+			}
+		}
+	}
+
+	return ret;
+}
+
+static int map_liodn_win(int liodn, struct fsl_dma_domain *dma_domain)
+{
+	unsigned long rpn;

drivers/iommu/fsl_pamu_domain.c line 243

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+	int ret;
+
+	rpn = dma_domain->paddr >> PAMU_PAGE_SHIFT;
+	spin_lock(&iommu_lock);
+	ret = pamu_config_ppaace(liodn, dma_domain->mapped_iova,
+				 dma_domain->mapped_size,
+				 ~(u32)0,
+				 rpn,
+				dma_domain->snoop_id, dma_domain->stash_id,
+				0, dma_domain->prot);

Indentation problem

Quoted 68 lines
drivers/iommu/fsl_pamu_domain.c new file +68 -0
+	spin_unlock(&iommu_lock);
+	if (ret)
+		pr_err("PAMU PAACE configuration failed for liodn %d\n",
+			liodn);
+
+	return ret;
+}
+
+static int map_liodn(int liodn, struct fsl_dma_domain *dma_domain)
+{
+	u32 subwin_cnt = dma_domain->subwin_cnt;
+
+	if (subwin_cnt)
+		return map_liodn_subwins(liodn, dma_domain, subwin_cnt);
+	else
+		return map_liodn_win(liodn, dma_domain);
+
+}
+
+static int update_liodn(int liodn, struct fsl_dma_domain *dma_domain)
+{
+	int ret;
+
+	if (dma_domain->subwin_cnt) {
+		ret = reconfig_subwin(liodn, dma_domain);
+		if (ret)
+			pr_err("Subwindow reconfiguration failed for liodn %d\n", liodn);
+	} else {
+		ret = reconfig_win(liodn, dma_domain);
+		if (ret)
+			pr_err("Window reconfiguration failed for liodn %d\n", liodn);
+	}
+
+	return ret;
+}
+
+static int update_liodn_stash(int liodn, struct fsl_dma_domain *dma_domain,
+				 u32 val)
+{
+	int ret = 0, i;
+
+	spin_lock(&iommu_lock);
+	if (!dma_domain->subwin_cnt) {
+		ret = pamu_update_paace_stash(liodn, 0, val);
+		if (ret) {
+			pr_err("Failed to update PAACE field for liodn %d\n ", liodn);
+			spin_unlock(&iommu_lock);
+			return ret;
+		}
+	} else {
+		for (i = 0; i < dma_domain->subwin_cnt; i++) {
+			ret = pamu_update_paace_stash(liodn, i, val);
+			if (ret) {
+				pr_err("Failed to update SPAACE %d field for liodn %d\n ", i, liodn);
+				spin_unlock(&iommu_lock);
+				return ret;
+			}
+		}
+	}
+	spin_unlock(&iommu_lock);
+
+	return ret;
+}
+
+static int configure_liodn(int liodn, struct device *dev,
+			   struct fsl_dma_domain *dma_domain,
+			   struct iommu_domain_geometry *geom_attr,
+			   u32 subwin_cnt)

drivers/iommu/fsl_pamu_domain.c line 321

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+{
+	phys_addr_t window_addr, window_size;
+	phys_addr_t subwin_size;
+	int ret = 0, i;
+	u32 omi_index = ~(u32)0;
+
+	/* Configure the omi_index at the geometry setup time.
+	 * This is a static value which depends on the type of
+	 * device and would not change thereafter.
+	 */
	/*
	 * multi-line comments
	 * look like this
	 */
Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale