Skip to contentSkip to conversation

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

PATCH In review Varun Sethi 3 participants 8 messages Dec 14, 2012 – Jan 6, 2013

Subsystems (2)
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 info in device arch data.
add pamu bypass enable register to guts.
Add iommu attributes for PAMU
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     | 1033 +++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h     |   96 +++
 include/linux/iommu.h               |   49 ++
 9 files changed, 2744 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 v7 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.

---
- no change in this version

 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

PATCH v7 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.
4. Added max_subwindows field to the geometry attribute. This is used to determine the maximum number sub windows available for the geometry.

---
changes in v7:
- Added max_subwindows field to the geometry attribute. 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 |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
include/linux/iommu.h +49 -0
index f3b99e1..01ca1de 100644
@@ -44,6 +44,47 @@ 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;
+	/*
+	 * This is a read only field and indicates the maximum number of
+	 * subwindows that are permitted for the geometry. The user is
+	 * not allowed to write to this field.
+	 */
+	u32 max_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 +101,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
#3 lore raw

PATCH v7 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 v7:
- Set max_subwidows in the geometry attribute.
- Add checking for maximum supported LIODN value.
- Use upper_32_bits and lower_32_bits macros while intializing PAMU data structures.
changes in v6:
- Simplified complex conditional statements.
- Fixed indentation issues.
- Added comments for IOMMU API implementation. 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 | 1033 +++++++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h |   96 ++++
 6 files changed, 2688 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 f66b816..4bc664e 100644
@@ -13,3 +13,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 +1033 -0

1,033 lines not on this page · raw message

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

96 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#4 lore raw
In reply to Varun Sethi

ping!!

Quoted 51 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Friday, December 14, 2012 7:22 PM
To: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; Tabi Timur-B04825; Wood Scott-B07421
Cc: Sethi Varun-B16395
Subject: [PATCH 0/4] 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 info in device arch data.
add pamu bypass enable register to guts.
Add iommu attributes for PAMU
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     | 1033
+++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h     |   96 +++
 include/linux/iommu.h               |   49 ++
 9 files changed, 2744 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

--
1.7.4.1

#5 lore raw
In reply to Varun Sethi

Hi Joerg,
Do you have any comments on the patchset?

Regards
Varun

Quoted 66 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Friday, December 21, 2012 7:17 AM
To: 'Joerg Roedel'
Cc: Sethi Varun-B16395; [email protected]; iommu-cunTk1MwBs/[email protected] foundation.org; linuxppc-dev-uLR06cmDAlY/[email protected]; linux- [email protected]; Tabi Timur-B04825; Wood Scott-B07421
Subject: RE: [PATCH 0/4] iommu/fsl: Freescale PAMU driver and IOMMU API
implementation.

ping!!

Quoted 10 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Friday, December 14, 2012 7:22 PM
To: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; Tabi Timur-B04825; Wood Scott-B07421
Cc: Sethi Varun-B16395
Subject: [PATCH 0/4] iommu/fsl: Freescale PAMU driver and IOMMU API
implementation.

Quoted 5 lines

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.

Quoted 38 lines

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 info in device arch data.
add pamu bypass enable register to guts.
Add iommu attributes for PAMU
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     | 1033
+++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h     |   96 +++
 include/linux/iommu.h               |   49 ++
 9 files changed, 2744 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

--
1.7.4.1

#6 lore raw
In reply to Varun Sethi

Hi Joerg,
It's been a while since I submitted this patch. I have tried to address your comments regarding the subwindow attribute. I would really appreciate if I can get some feedback on this patch.

Regards
Varun

Quoted 66 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Friday, December 21, 2012 7:17 AM
To: 'Joerg Roedel'
Cc: Sethi Varun-B16395; [email protected]; iommu-cunTk1MwBs/[email protected] foundation.org; linuxppc-dev-uLR06cmDAlY/[email protected]; linux- [email protected]; Tabi Timur-B04825; Wood Scott-B07421
Subject: RE: [PATCH 0/4] iommu/fsl: Freescale PAMU driver and IOMMU API
implementation.

ping!!

Quoted 10 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Friday, December 14, 2012 7:22 PM
To: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; Tabi Timur-B04825; Wood Scott-B07421
Cc: Sethi Varun-B16395
Subject: [PATCH 0/4] iommu/fsl: Freescale PAMU driver and IOMMU API
implementation.

Quoted 5 lines

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.

Quoted 38 lines

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 info in device arch data.
add pamu bypass enable register to guts.
Add iommu attributes for PAMU
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     | 1033
+++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h     |   96 +++
 include/linux/iommu.h               |   49 ++
 9 files changed, 2744 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

--
1.7.4.1

maintainer
#7 lore raw

Hi Varun,

Quoted 3 lines · On Thu, Jan 03, 2013 at 05:21:09AM +0000, Sethi Varun-B16395 wrote:

It's been a while since I submitted this patch. I have tried to address your comments regarding the subwindow attribute. I would really appreciate if I can get some feedback on this patch.

I have some ideas in mind how we can abstract this in the IOMMU-API (with an extension to the API). I will send a RFC patchset soon to add these changes and then we can discuss it.

Joerg