Skip to contentSkip to conversation

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

PATCH Superseded Varun Sethi 8 participants 36 messages Feb 18, 2013 – Mar 7, 2013

Subsystems (2)

v8 of 18 Superseded Latest is v18 →

lore
Share & tools
lore
#0 lore raw

v8 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. Store PCI controller platform device information in the PCI controller structure.
3. Add defines for FSL PCI controller BRR1 register.
4. Add window permission flags in the iommu_domain_window_enable API.
5. Add domain attributes for FSL PAMU driver.
6. 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 (6):
Store iommu domain information in the device structure. Store the platform device information corresponding to the pci
controller.
Added defines for the FSL PCI controller BRR1 register. Add window permission flags for iommu_domain_window_enable API. Add addtional attributes specific to the PAMU driver. FSL PAMU driver and IOMMU API implementation.

 arch/powerpc/include/asm/device.h     |    4 +
 arch/powerpc/include/asm/pci-bridge.h |    4 +
 arch/powerpc/sysdev/fsl_pci.c         |    9 +-
 arch/powerpc/sysdev/fsl_pci.h         |    2 +-
 drivers/iommu/Kconfig                 |    8 +
 drivers/iommu/Makefile                |    1 +
 drivers/iommu/fsl_pamu.c              | 1260 +++++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu.h              |  398 +++++++++++
 drivers/iommu/fsl_pamu_domain.c       | 1135 +++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h       |   89 +++
 drivers/iommu/iommu.c                 |    5 +-
 include/linux/iommu.h                 |   40 +-
 12 files changed, 2947 insertions(+), 8 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 v8 1/6 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.

 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
maintainer
#2 lore raw

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

Quoted 16 lines · Varun Sethi

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.

 arch/powerpc/include/asm/device.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +0 -0
index 77e97dd..6dc79fe 100644

arch/powerpc/include/asm/device.h struct dev_archdata { · line 34

Quoted 7 lines
arch/powerpc/include/asm/device.h +4 -0
@@ -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;

Please Cc the PowerPC Maintainers on this, so that they can have a look at it. This also must be put this into an #ifdef CONFIG_IOMMU_API.

Joerg

#3 lore raw

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

Hi Kumar,Ben,
I am implementing the Freescale PAMU (IOMMU) driver using the Linux IOMMU API. In this particular patch, I have added a new field to dev_archdata structure to store the dma domain information. This field is updated whenever we attach a device to an iommu domain.

Regards
Varun

Quoted 42 lines

-----Original Message-----
From: Joerg Roedel [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 5:01 PM
To: Sethi Varun-B16395
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Yoder Stuart-B08248
Subject: Re: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information
pointer in archdata.

Quoted 17 lines · Varun Sethi

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.

 arch/powerpc/include/asm/device.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +0 -0
index 77e97dd..6dc79fe 100644

arch/powerpc/include/asm/device.h struct dev_archdata { · line 34

Quoted 7 lines
arch/powerpc/include/asm/device.h +4 -0
@@ -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;

Please Cc the PowerPC Maintainers on this, so that they can have a look at it. This also must be put this into an #ifdef CONFIG_IOMMU_API.

Joerg

#4 lore raw

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

Quoted 6 lines · On Feb 27, 2013, at 6:04 AM, Sethi Varun-B16395 wrote:

Hi Kumar,Ben,
I am implementing the Freescale PAMU (IOMMU) driver using the Linux IOMMU API. In this particular patch, I have added a new field to dev_archdata structure to store the dma domain information. This field is updated whenever we attach a device to an iommu domain.

Regards
Varun

Would be good to see if this overlaps with Alexey's work for IOMMU driver for powernv.

- k

Quoted 50 lines
Quoted 40 lines

-----Original Message-----
From: Joerg Roedel [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 5:01 PM
To: Sethi Varun-B16395
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Yoder Stuart-B08248
Subject: Re: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information
pointer in archdata.

Quoted 17 lines · Varun Sethi

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.
arch/powerpc/include/asm/device.h | 4 ++++

1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +0 -0
index 77e97dd..6dc79fe 100644

arch/powerpc/include/asm/device.h struct dev_archdata { · line 34

Quoted 7 lines
arch/powerpc/include/asm/device.h +4 -0
@@ -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;

Please Cc the PowerPC Maintainers on this, so that they can have a look at it. This also must be put this into an #ifdef CONFIG_IOMMU_API.

Quoted 3 lines

Joerg

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#5 lore raw

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

Hi!

On POWERNV we use only the part of IOMMU API which handles devices and groups. We do not use IOMMU domains as VFIO containers do everything we need for VFIO and we do not implement iommu_ops as it is not very relevant to our architecture (does not give dma window properties, etc).

So your work does not overlap with my work :)

Quoted 52 lines · Kumar Gala
Quoted 6 lines · On Feb 27, 2013, at 6:04 AM, Sethi Varun-B16395 wrote:

Hi Kumar,Ben,
I am implementing the Freescale PAMU (IOMMU) driver using the Linux IOMMU API. In this particular patch, I have added a new field to dev_archdata structure to store the dma domain information. This field is updated whenever we attach a device to an iommu domain.

Regards
Varun

Would be good to see if this overlaps with Alexey's work for IOMMU driver for powernv.

- k

Quoted 38 lines
Quoted 38 lines

-----Original Message-----
From: Joerg Roedel [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 5:01 PM
To: Sethi Varun-B16395
Cc: [email protected]; [email protected]; [email protected]; Wood Scott-B07421; Yoder Stuart-B08248
Subject: Re: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information pointer in archdata.

Quoted 17 lines · Varun Sethi

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.
arch/powerpc/include/asm/device.h | 4 ++++

1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +0 -0
index 77e97dd..6dc79fe 100644

arch/powerpc/include/asm/device.h struct dev_archdata { · line 34

Quoted 7 lines
arch/powerpc/include/asm/device.h +4 -0
@@ -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;

Please Cc the PowerPC Maintainers on this, so that they can have a look at it. This also must be put this into an #ifdef CONFIG_IOMMU_API.

Signature · 1 line
Alexey	
#6 lore raw

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

Thanks for the clarification Alexey.

Kumar,
We are using this new field (for PAMU) to store the iommu domain (for iommu=
API) information for a device.

Regards
Varun

Quoted 82 lines

-----Original Message-----
From: Alexey Kardashevskiy [mailto:[email protected]]
Sent: Friday, March 01, 2013 6:55 AM
To: Kumar Gala
Cc: Sethi Varun-B16395; Benjamin Herrenschmidt; [email protected] foundation.org; [email protected] list; linux- [email protected] list; Wood Scott-B07421; Yoder Stuart-B08248; Joerg Roedel; Paul Mackerras; David Gibson; Alex Williamson
Subject: Re: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information pointer in archdata.
=20
Hi!
=20
On POWERNV we use only the part of IOMMU API which handles devices and groups. We do not use IOMMU domains as VFIO containers do everything we need for VFIO and we do not implement iommu_ops as it is not very relevant to our architecture (does not give dma window properties, etc). =20
So your work does not overlap with my work :)
=20
=20

Quoted 5 lines · Kumar Gala
Quoted 2 lines · On Feb 27, 2013, at 6:04 AM, Sethi Varun-B16395 wrote:

Hi Kumar,Ben,
I am implementing the Freescale PAMU (IOMMU) driver using the Linux

IOMMU API. In this particular patch, I have added a new field to dev_archdata structure to store the dma domain information.

Quoted 6 lines
Quoted 4 lines

This field is updated whenever we attach a device to an iommu domain.

Regards
Varun

Would be good to see if this overlaps with Alexey's work for IOMMU

driver for powernv.

Quoted 41 lines

- k

Quoted 38 lines
Quoted 38 lines

-----Original Message-----
From: Joerg Roedel [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 5:01 PM
To: Sethi Varun-B16395
Cc: [email protected]; [email protected]; [email protected]; Wood Scott-B07421; Yoder Stuart-B08248
Subject: Re: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information pointer in archdata.

Quoted 17 lines · Varun Sethi

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.
arch/powerpc/include/asm/device.h | 4 ++++

1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +0 -0
index 77e97dd..6dc79fe 100644

arch/powerpc/include/asm/device.h struct dev_archdata { · line 34

Quoted 7 lines
arch/powerpc/include/asm/device.h +4 -0
@@ -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;

Please Cc the PowerPC Maintainers on this, so that they can have a look at it. This also must be put this into an #ifdef

CONFIG_IOMMU_API.
=20
=20
--
Alexey

#7 lore raw

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

btw the device struct already has a pointer to its iommu_group, and the iommu_group struct itself has a pointer void *iommu_data which you could use for anything you want (iommu_group_get_iommudata(), iommu_group_set_iommudata()).

By design you are expected to add iommu groups to a domain but not devices so I am not so sure that you really need a pointer to domain in the device struct.

Quoted 86 lines · On 01/03/13 19:55, Sethi Varun-B16395 wrote:

Thanks for the clarification Alexey.

Kumar,
We are using this new field (for PAMU) to store the iommu domain (for iommu API) information for a device.

Regards
Varun

Quoted 78 lines

-----Original Message-----
From: Alexey Kardashevskiy [mailto:[email protected]]
Sent: Friday, March 01, 2013 6:55 AM
To: Kumar Gala
Cc: Sethi Varun-B16395; Benjamin Herrenschmidt; [email protected] foundation.org; [email protected] list; linux- [email protected] list; Wood Scott-B07421; Yoder Stuart-B08248; Joerg Roedel; Paul Mackerras; David Gibson; Alex Williamson
Subject: Re: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information pointer in archdata.

Hi!

On POWERNV we use only the part of IOMMU API which handles devices and groups. We do not use IOMMU domains as VFIO containers do everything we need for VFIO and we do not implement iommu_ops as it is not very relevant to our architecture (does not give dma window properties, etc).

So your work does not overlap with my work :)

Quoted 5 lines · Kumar Gala
Quoted 2 lines · On Feb 27, 2013, at 6:04 AM, Sethi Varun-B16395 wrote:

Hi Kumar,Ben,
I am implementing the Freescale PAMU (IOMMU) driver using the Linux

IOMMU API. In this particular patch, I have added a new field to dev_archdata structure to store the dma domain information.

Quoted 6 lines
Quoted 4 lines

This field is updated whenever we attach a device to an iommu domain.

Regards
Varun

Would be good to see if this overlaps with Alexey's work for IOMMU

driver for powernv.

Quoted 41 lines

- k

Quoted 38 lines
Quoted 38 lines

-----Original Message-----
From: Joerg Roedel [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 5:01 PM
To: Sethi Varun-B16395
Cc: [email protected]; [email protected]; [email protected]; Wood Scott-B07421; Yoder Stuart-B08248
Subject: Re: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information pointer in archdata.

Quoted 17 lines · Varun Sethi

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.
arch/powerpc/include/asm/device.h | 4 ++++

1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +0 -0
index 77e97dd..6dc79fe 100644

arch/powerpc/include/asm/device.h struct dev_archdata { · line 34

Quoted 7 lines
arch/powerpc/include/asm/device.h +4 -0
@@ -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;

Please Cc the PowerPC Maintainers on this, so that they can have a look at it. This also must be put this into an #ifdef

CONFIG_IOMMU_API.

Signature · 1 line
Alexey
#8 lore raw

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

Quoted 11 lines

-----Original Message-----
From: Alexey Kardashevskiy [mailto:[email protected]]
Sent: Friday, March 01, 2013 4:07 AM
To: Sethi Varun-B16395
Cc: Kumar Gala; Benjamin Herrenschmidt; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected] list; [email protected] list; Wood Scott-B07421; Yoder Stuart-B08248; Joerg Roedel; Paul
Mackerras; David Gibson; Alex Williamson
Subject: Re: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information pointer in archdata.

Quoted 8 lines

btw the device struct already has a pointer to its iommu_group, and the iommu_group struct itself has a pointer void *iommu_data which you could use for anything you want (iommu_group_get_iommudata(), iommu_group_set_iommudata()).

By design you are expected to add iommu groups to a domain but not devices so I am not so sure that you really need a pointer to domain in the device struct.

Well, at the lowest level the IOMMU API does attach devices to domains-- i.e. API attach_dev(). So, it seems to conceptually make sense to have a ptr from the device to the associated domain. When you implement attach_dev() you need to be able to see whether the device is already attached to
a domain. Adding a couple of levels of indirection...from device to
group to domain...doesn't seems to make things simpler or better IMHO.

x86 keeps a pointer to the domain in device archdata and since there is a direct correlation between a device and domain I'd rather see it where this patch has it.

Stuart

#9 lore raw

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

Quoted 45 lines

-----Original Message-----
From: Yoder Stuart-B08248
Sent: Friday, March 01, 2013 9:52 PM
To: Alexey Kardashevskiy; Sethi Varun-B16395
Cc: Kumar Gala; Benjamin Herrenschmidt; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected] list; [email protected] list; Wood Scott-B07421; Joerg Roedel; Paul Mackerras; David Gibson; Alex
Williamson
Subject: RE: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information
pointer in archdata.

Quoted 10 lines

-----Original Message-----
From: Alexey Kardashevskiy [mailto:[email protected]]
Sent: Friday, March 01, 2013 4:07 AM
To: Sethi Varun-B16395
Cc: Kumar Gala; Benjamin Herrenschmidt; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected] list; [email protected] list; Wood Scott-B07421; Yoder
Stuart-B08248; Joerg Roedel; Paul Mackerras; David Gibson; Alex
Williamson
Subject: Re: [PATCH 1/6 v8] iommu/fsl: Store iommu domain information

pointer in archdata.

Quoted 9 lines

btw the device struct already has a pointer to its iommu_group, and the iommu_group struct itself has a pointer void *iommu_data which you could use for anything you want (iommu_group_get_iommudata(), iommu_group_set_iommudata()).

By design you are expected to add iommu groups to a domain but not devices so I am not so sure that you really need a pointer to domain in the device struct.

Well, at the lowest level the IOMMU API does attach devices to domains-- i.e.
API attach_dev(). So, it seems to conceptually make sense to have a ptr from the device to the associated domain. When you implement attach_dev() you need to be able to see whether the device is already attached to
a domain. Adding a couple of levels of indirection...from device to
group to domain...doesn't seems to make things simpler or better IMHO.

Quoted 4 lines

x86 keeps a pointer to the domain in device archdata and since there is a direct correlation between a device and domain I'd rather see it where this patch has it.

As Stuart stated this allows us to maintain the device <-> domain relationship at the lowest level.

-Varun

#10 lore raw

PATCH v8 2/6 powerpc/fsl_pci: Store the platform device information corresponding to the pci controller.

In reply to Varun Sethi

The pci controller structure has a provision to store the device strcuture pointer of the corresponding platform device. Currently this information is not stored during fsl pci controller initialization. This information is required while dealing with iommu groups for pci devices connected to the fsl pci controller. For the case where the pci devices can't be paritioned, they would fall under the same device group as the pci controller.

This patch stores the platform device information in the pci controller structure during initialization.

---
 arch/powerpc/sysdev/fsl_pci.c |    9 +++++++--
 arch/powerpc/sysdev/fsl_pci.h |    2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)
arch/powerpc/sysdev/fsl_pci.c +7 -2
index 92a5915..b393ae7 100644
@@ -421,13 +421,16 @@ void fsl_pcibios_fixup_bus(struct pci_bus *bus)
 	}
 }
 
-int __init fsl_add_bridge(struct device_node *dev, int is_primary)
+int __init fsl_add_bridge(struct platform_device *pdev, int is_primary)
 {
 	int len;
 	struct pci_controller *hose;
 	struct resource rsrc;
 	const int *bus_range;
 	u8 hdr_type, progif;
+	struct device_node *dev;
+
+	dev = pdev->dev.of_node;
 
 	if (!of_device_is_available(dev)) {
 		pr_warning("%s: disabled\n", dev->full_name);
@@ -453,6 +456,8 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary)
 	if (!hose)
 		return -ENOMEM;
 
+	/* set platform device as the parent */
+	hose->parent = &pdev->dev;
 	hose->first_busno = bus_range ? bus_range[0] : 0x0;
 	hose->last_busno = bus_range ? bus_range[1] : 0xff;
 
@@ -880,7 +885,7 @@ static int fsl_pci_probe(struct platform_device *pdev)
 #endif
 
 	node = pdev->dev.of_node;
-	ret = fsl_add_bridge(node, fsl_pci_primary == node);
+	ret = fsl_add_bridge(pdev, fsl_pci_primary == node);
 
 #ifdef CONFIG_SWIOTLB
 	if (ret == 0) {
arch/powerpc/sysdev/fsl_pci.h +1 -1
index d078537..c495c00 100644
@@ -91,7 +91,7 @@ struct ccsr_pci {
 	__be32	pex_err_cap_r3;		/* 0x.e34 - PCIE error capture register 0 */
 };
 
-extern int fsl_add_bridge(struct device_node *dev, int is_primary);
+extern int fsl_add_bridge(struct platform_device *pdev, int is_primary);
 extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
 extern int mpc83xx_add_bridge(struct device_node *dev);
 u64 fsl_pci_immrbar_base(struct pci_controller *hose);
Signature · 1 line
1.7.4.1
#11 lore raw

Re: [PATCH 2/6] powerpc/fsl_pci: Store the platform device information corresponding to the pci controller.

This patch was submitted separately to linuxppc-dev (and was already applied). You don't need it in this patch set, right?

Stuart

Quoted 77 lines · Varun Sethi

The pci controller structure has a provision to store the device strcuture pointer of the corresponding platform device. Currently this information is not stored during fsl pci controller initialization. This information is required while dealing with iommu groups for pci devices connected to the fsl pci controller. For the case where the pci devices can't be paritioned, they would fall under the same device group as the pci controller.

This patch stores the platform device information in the pci controller structure during initialization.

---
 arch/powerpc/sysdev/fsl_pci.c |    9 +++++++--
 arch/powerpc/sysdev/fsl_pci.h |    2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)
arch/powerpc/sysdev/fsl_pci.c +7 -2
index 92a5915..b393ae7 100644
@@ -421,13 +421,16 @@ void fsl_pcibios_fixup_bus(struct pci_bus *bus)
        }
 }
 
-int __init fsl_add_bridge(struct device_node *dev, int is_primary)
+int __init fsl_add_bridge(struct platform_device *pdev, int is_primary)
 {
        int len;
        struct pci_controller *hose;
        struct resource rsrc;
        const int *bus_range;
        u8 hdr_type, progif;
+       struct device_node *dev;
+
+       dev = pdev->dev.of_node;
 
        if (!of_device_is_available(dev)) {
                pr_warning("%s: disabled\n", dev->full_name);
@@ -453,6 +456,8 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary)
        if (!hose)
                return -ENOMEM;
 
+       /* set platform device as the parent */
+       hose->parent = &pdev->dev;
        hose->first_busno = bus_range ? bus_range[0] : 0x0;
        hose->last_busno = bus_range ? bus_range[1] : 0xff;
 
@@ -880,7 +885,7 @@ static int fsl_pci_probe(struct platform_device *pdev)
 #endif
 
        node = pdev->dev.of_node;
-       ret = fsl_add_bridge(node, fsl_pci_primary == node);
+       ret = fsl_add_bridge(pdev, fsl_pci_primary == node);
 
 #ifdef CONFIG_SWIOTLB
        if (ret == 0) {
arch/powerpc/sysdev/fsl_pci.h +1 -2
index d078537..c495c00 100644
@@ -91,7 +91,7 @@ struct ccsr_pci {
        __be32  pex_err_cap_r3;         /* 0x.e34 - PCIE error capture register 0 */
 };
 
-extern int fsl_add_bridge(struct device_node *dev, int is_primary);
+extern int fsl_add_bridge(struct platform_device *pdev, int is_primary);
 extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
 extern int mpc83xx_add_bridge(struct device_node *dev);
 u64 fsl_pci_immrbar_base(struct pci_controller *hose);
--

1.7.4.1

_______________________________________________
iommu mailing list iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#12 lore raw

RE: [PATCH 2/6] powerpc/fsl_pci: Store the platform device information corresponding to the pci controller.

This patch is not present in Joerg's tree and the add_device API in the PAMU driver requires this patch.

-Varun

Quoted 99 lines

-----Original Message-----
From: Stuart Yoder [mailto:[email protected]]
Sent: Tuesday, February 26, 2013 5:39 AM
To: Sethi Varun-B16395
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Joerg Roedel; Yoder Stuart-B08248
Subject: Re: [PATCH 2/6] powerpc/fsl_pci: Store the platform device
information corresponding to the pci controller.

This patch was submitted separately to linuxppc-dev (and was already applied). You don't need it in this patch set, right?

Stuart

Quoted 6 lines · Varun Sethi

The pci controller structure has a provision to store the device strcuture pointer of the corresponding platform device. Currently this information is not stored during fsl pci controller initialization. This information is required while dealing with iommu groups for pci devices connected to the fsl pci controller. For the case where the pci devices can't be paritioned, they would fall under the same device

group as the pci controller.

Quoted 24 lines

This patch stores the platform device information in the pci controller structure during initialization.

---
 arch/powerpc/sysdev/fsl_pci.c |    9 +++++++--
 arch/powerpc/sysdev/fsl_pci.h |    2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/powerpc/sysdev/fsl_pci.c index 92a5915..b393ae7 100644

arch/powerpc/sysdev/fsl_pci.c +2 -1
@@ -421,13 +421,16 @@ void fsl_pcibios_fixup_bus(struct pci_bus *bus)
        }
 }
 
-int __init fsl_add_bridge(struct device_node *dev, int is_primary)
+int __init fsl_add_bridge(struct platform_device *pdev, int
+is_primary)
 {
        int len;
        struct pci_controller *hose;

arch/powerpc/sysdev/fsl_pci.c void fsl_pcibios_fixup_bus(struct pci_bus *bus)

Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +3 -1
        struct resource rsrc;
        const int *bus_range;
        u8 hdr_type, progif;
+       struct device_node *dev;
+
+       dev = pdev->dev.of_node;
 
        if (!of_device_is_available(dev)) {
                pr_warning("%s: disabled\n", dev->full_name); @@
-453,6 +456,8 @@ int __init fsl_add_bridge(struct device_node *dev, int

is_primary)

Quoted 22 lines
        if (!hose)
                return -ENOMEM;
arch/powerpc/sysdev/fsl_pci.c +3 -1
+       /* set platform device as the parent */
+       hose->parent = &pdev->dev;
        hose->first_busno = bus_range ? bus_range[0] : 0x0;
        hose->last_busno = bus_range ? bus_range[1] : 0xff;
@@ -880,7 +885,7 @@ static int fsl_pci_probe(struct platform_device
 *pdev)  #endif
 
        node = pdev->dev.of_node;
-       ret = fsl_add_bridge(node, fsl_pci_primary == node);
+       ret = fsl_add_bridge(pdev, fsl_pci_primary == node);
 
 #ifdef CONFIG_SWIOTLB
        if (ret == 0) {
(quoted diff) +0 -0

b/arch/powerpc/sysdev/fsl_pci.h index d078537..c495c00 100644

arch/powerpc/sysdev/fsl_pci.h struct ccsr_pci { · line 91

Quoted 1 line
arch/powerpc/sysdev/fsl_pci.h +0 -0
@@ -91,7 +91,7 @@ struct ccsr_pci {
        __be32  pex_err_cap_r3;         /* 0x.e34 - PCIE error capture

register 0 */

Quoted 16 lines
arch/powerpc/sysdev/fsl_pci.h +2 -2
 };
 
-extern int fsl_add_bridge(struct device_node *dev, int is_primary);
+extern int fsl_add_bridge(struct platform_device *pdev, int
+is_primary);
 extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);  extern int
 mpc83xx_add_bridge(struct device_node *dev);
 u64 fsl_pci_immrbar_base(struct pci_controller *hose);
--

1.7.4.1

_______________________________________________
iommu mailing list iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

maintainer
#13 lore raw

Re: [PATCH 2/6] powerpc/fsl_pci: Store the platform device information corresponding to the pci controller.

Quoted 2 lines · On Tue, Feb 26, 2013 at 06:16:10AM +0000, Sethi Varun-B16395 wrote:

This patch is not present in Joerg's tree and the add_device API in the PAMU driver requires this patch.

Will this patch be part of v3.9-rc1?

Joerg

#14 lore raw

RE: [PATCH 2/6] powerpc/fsl_pci: Store the platform device information corresponding to the pci controller.

This patch is present in the "next branch" of linux ppc tree maintained by Kumar Gala. Following is the commit id:
52c5affc545053d37c0b05224bbf70f5336caa20

I am not sure if this would be part of 3.9-rc1.

Regards
varun

Quoted 20 lines

-----Original Message-----
From: Joerg Roedel [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 4:15 PM
To: Sethi Varun-B16395
Cc: Stuart Yoder; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Yoder Stuart-B08248
Subject: Re: [PATCH 2/6] powerpc/fsl_pci: Store the platform device
information corresponding to the pci controller.

Quoted 2 lines · On Tue, Feb 26, 2013 at 06:16:10AM +0000, Sethi Varun-B16395 wrote:

This patch is not present in Joerg's tree and the add_device API in the PAMU driver requires this patch.

Will this patch be part of v3.9-rc1?

Joerg

#15 lore raw

Re: [PATCH 2/6] powerpc/fsl_pci: Store the platform device information corresponding to the pci controller.

Quoted 8 lines · On Feb 27, 2013, at 4:56 AM, Sethi Varun-B16395 wrote:

This patch is present in the "next branch" of linux ppc tree maintained by Kumar Gala. Following is the commit id:
52c5affc545053d37c0b05224bbf70f5336caa20

I am not sure if this would be part of 3.9-rc1.

Regards
varun

This is now in Linus's tree so will be in 3.9-rc1

- k

#16 lore raw

RE: [PATCH 2/6] powerpc/fsl_pci: Store the platform device information corresponding to the pci controller.

Hi Joerg,
I have to post the next version of my patchset, should I base it on top of 3.9-rc1? By when would you move the iommu git tree to 3.9-rc1?

Regards
Varun

Quoted 27 lines

-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Thursday, February 28, 2013 9:15 PM
To: Sethi Varun-B16395
Cc: Joerg Roedel; Stuart Yoder; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott- B07421; Yoder Stuart-B08248
Subject: Re: [PATCH 2/6] powerpc/fsl_pci: Store the platform device
information corresponding to the pci controller.

Quoted 1 line · On Feb 27, 2013, at 4:56 AM, Sethi Varun-B16395 wrote:

This patch is present in the "next branch" of linux ppc tree maintained

by Kumar Gala.

Quoted 7 lines

Following is the commit id:
52c5affc545053d37c0b05224bbf70f5336caa20

I am not sure if this would be part of 3.9-rc1.

Regards
varun

This is now in Linus's tree so will be in 3.9-rc1

- k

maintainer
#17 lore raw

Re: [PATCH 2/6] powerpc/fsl_pci: Store the platform device information corresponding to the pci controller.

Yes, please base your patches on the latest upstream-tag. I will move my tree to v3.9-rc1 soon, there are some fixes that need to go upstream.

Quoted 36 lines · On Thu, Mar 07, 2013 at 09:14:21AM +0000, Sethi Varun-B16395 wrote:

Hi Joerg,
I have to post the next version of my patchset, should I base it on top of 3.9-rc1? By when would you move the iommu git tree to 3.9-rc1?

Regards
Varun

Quoted 27 lines

-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Thursday, February 28, 2013 9:15 PM
To: Sethi Varun-B16395
Cc: Joerg Roedel; Stuart Yoder; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott- B07421; Yoder Stuart-B08248
Subject: Re: [PATCH 2/6] powerpc/fsl_pci: Store the platform device
information corresponding to the pci controller.

Quoted 1 line · On Feb 27, 2013, at 4:56 AM, Sethi Varun-B16395 wrote:

This patch is present in the "next branch" of linux ppc tree maintained

by Kumar Gala.

Quoted 7 lines

Following is the commit id:
52c5affc545053d37c0b05224bbf70f5336caa20

I am not sure if this would be part of 3.9-rc1.

Regards
varun

This is now in Linus's tree so will be in 3.9-rc1

- k

#18 lore raw

PATCH v8 3/6 powerpc/fsl_pci: Added defines for the FSL PCI controller BRR1 register.

In reply to Varun Sethi

Macros for checking FSL PCI controller version.

---
 arch/powerpc/include/asm/pci-bridge.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +4 -0
index 025a130..c12ed78 100644
@@ -14,6 +14,10 @@
 
 struct device_node;
 
+/* FSL PCI controller BRR1 register */
+#define PCI_FSL_BRR1      0xbf8
+#define PCI_FSL_BRR1_VER 0xffff
+
 /*
  * Structure of a PCI controller (host bridge)
  */
Signature · 1 line
1.7.4.1
maintainer
#19 lore raw

Re: [PATCH 3/6] powerpc/fsl_pci: Added defines for the FSL PCI controller BRR1 register.

Quoted 12 lines · Varun Sethi

Macros for checking FSL PCI controller version.

---
 arch/powerpc/include/asm/pci-bridge.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +0 -0
index 025a130..c12ed78 100644

arch/powerpc/include/asm/pci-bridge.h line 20

Quoted 7 lines
arch/powerpc/include/asm/pci-bridge.h +4 -0
@@ -14,6 +14,10 @@
 
 struct device_node;
 
+/* FSL PCI controller BRR1 register */
+#define PCI_FSL_BRR1      0xbf8
+#define PCI_FSL_BRR1_VER 0xffff
+

Please merge this patch with the one where you actually make use of these defines for the first time.

Joerg

#20 lore raw

Re: [PATCH 3/6] powerpc/fsl_pci: Added defines for the FSL PCI controller BRR1 register.

Quoted 9 lines · Joerg Roedel

=

Quoted 8 lines · Varun Sethi

Macros for checking FSL PCI controller version.
=20

---
arch/powerpc/include/asm/pci-bridge.h | 4 ++++

1 files changed, 4 insertions(+), 0 deletions(-)

=20

= renamed from arch/powerpc/include/asm/pci-bridge.h +0 -0

b/arch/powerpc/include/asm/pci-bridge.h

Quoted 10 lines
Quoted 10 lines

index 025a130..c12ed78 100644

arch/powerpc/include/asm/pci-bridge.h +0 -0
@@ -14,6 +14,10 @@

=20
struct device_node;
=20

arch/powerpc/include/asm/pci-bridge.h +3 -0
+/* FSL PCI controller BRR1 register */
+#define PCI_FSL_BRR1      0xbf8
+#define PCI_FSL_BRR1_VER 0xffff
Quoted 8 lines
Quoted 1 line

+

=20
=20
Please merge this patch with the one where you actually make use of these defines for the first time.
=20
=20
Joerg

This also seems an odd place for these defines.

- k=

#21 lore raw

PATCH v8 4/6 iommu/fsl: Add window permission flags for iommu_domain_window_enable API.

In reply to Varun Sethi

Each iommu window can have access permissions associated with it. Extended the window_enable API to incorporate window access permissions.

---
 drivers/iommu/iommu.c |    5 +++--
 include/linux/iommu.h |    7 ++++---
 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/iommu/iommu.c +3 -2
index b972d43..1a2564d 100644
@@ -854,12 +854,13 @@ EXPORT_SYMBOL_GPL(iommu_unmap);
 
 
 int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr,
-			       phys_addr_t paddr, u64 size)
+			       phys_addr_t paddr, u64 size, int iommu_prot)
 {
 	if (unlikely(domain->ops->domain_window_enable == NULL))
 		return -ENODEV;
 
-	return domain->ops->domain_window_enable(domain, wnd_nr, paddr, size);
+	return domain->ops->domain_window_enable(domain, wnd_nr, paddr, size,
+						 iommu_prot);
 }
 EXPORT_SYMBOL_GPL(iommu_domain_window_enable);
 
include/linux/iommu.h +4 -3
index ba3b8a9..529987c 100644
@@ -105,7 +105,7 @@ struct iommu_ops {
 
 	/* Window handling functions */
 	int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr,
-				    phys_addr_t paddr, u64 size);
+				    phys_addr_t paddr, u64 size, int iommu_prot);
 	void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr);
 	/* Set the numer of window per domain */
 	int (*domain_set_windows)(struct iommu_domain *domain, u32 w_count);
@@ -171,7 +171,8 @@ extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr,
 
 /* Window handling function prototypes */
 extern int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr,
-				      phys_addr_t offset, u64 size);
+				      phys_addr_t offset, u64 size,
+				      int iommu_prot);
 extern void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr);
 /**
  * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework
@@ -257,7 +258,7 @@ static inline int iommu_unmap(struct iommu_domain *domain, unsigned long iova,
 
 static inline int iommu_domain_window_enable(struct iommu_domain *domain,
 					     u32 wnd_nr, phys_addr_t paddr,
-					     u64 size)
+					     u64 size, int iommu_prot)
 {
 	return -ENODEV;
 }
Signature · 1 line
1.7.4.1
#22 lore raw

PATCH v8 5/6 iommu/fsl: Add addtional attributes specific to the PAMU driver.

In reply to Varun Sethi

Added the following domain attributes for the FSL PAMU driver:
1. Added new iommu stash attribute, which allows setting of the LIODN specific stash id parameter through IOMMU API.
2. Added an attribute for enabling/disabling DMA to a particular memory window.
3. Added domain attribute to check for PAMUV1 specific constraints.

---
 include/linux/iommu.h |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
include/linux/iommu.h +33 -0
index 529987c..c44e38b 100644
@@ -40,6 +40,23 @@ struct notifier_block;
 typedef int (*iommu_fault_handler_t)(struct iommu_domain *,
 			struct device *, unsigned long, int, void *);
 
+/* 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_geometry {
 	dma_addr_t aperture_start; /* First address that can be mapped    */
 	dma_addr_t aperture_end;   /* Last address that can be mapped     */
@@ -57,10 +74,26 @@ struct iommu_domain {
 #define IOMMU_CAP_CACHE_COHERENCY	0x1
 #define IOMMU_CAP_INTR_REMAP		0x2	/* isolates device intrs */
 
+/*
+ * Following constraints are specifc to PAMUV1:
+ *  -aperture must be power of 2, and naturally aligned
+ *  -number of windows must be power of 2, and address space size
+ *   of each window is determined by aperture size / # of windows
+ *  -the actual size of the mapped region of a window must be power
+ *   of 2 starting with 4KB and physical address must be naturally
+ *   aligned.
+ * DOMAIN_ATTR_FSL_PAMUV1 corresponds to the above mentioned contraints.
+ * The caller can invoke iommu_domain_get_attr to check if the underlying
+ * iommu implementation supports these constraints.
+ */
+
 enum iommu_attr {
 	DOMAIN_ATTR_GEOMETRY,
 	DOMAIN_ATTR_PAGING,
 	DOMAIN_ATTR_WINDOWS,
+	DOMAIN_ATTR_PAMU_STASH,
+	DOMAIN_ATTR_PAMU_ENABLE,
+	DOMAIN_ATTR_FSL_PAMUV1,
 	DOMAIN_ATTR_MAX,
 };
 
Signature · 1 line
1.7.4.1
maintainer
#23 lore raw

Re: [PATCH 5/6 v8] iommu/fsl: Add addtional attributes specific to the PAMU driver.

Quoted 27 lines · Varun Sethi

Added the following domain attributes for the FSL PAMU driver:
1. Added new iommu stash attribute, which allows setting of the LIODN specific stash id parameter through IOMMU API.
2. Added an attribute for enabling/disabling DMA to a particular memory window.
3. Added domain attribute to check for PAMUV1 specific constraints.

---
 include/linux/iommu.h |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
include/linux/iommu.h +6 -0
index 529987c..c44e38b 100644
@@ -40,6 +40,23 @@ struct notifier_block;
 typedef int (*iommu_fault_handler_t)(struct iommu_domain *,
 			struct device *, unsigned long, int, void *);
 
+/* 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

include/linux/iommu.h struct notifier_block; · line 58

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

Please make the cache-attribute an enum instead of using defines.

Joerg

#24 lore raw

PATCH v8 6/6 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.

Signed-off-by Timur Tabi

---
changes in v8:
- implemented the new API for window based IOMMUs. 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        | 1260 +++++++++++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu.h        |  398 ++++++++++++
 drivers/iommu/fsl_pamu_domain.c | 1135 +++++++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h |   89 +++
 6 files changed, 2891 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 3f0b15a1..a7dedcb 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 +1260 -0

1,260 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 +1135 -0

1,135 lines not on this page · raw message

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

89 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#25 lore raw

drivers/iommu/fsl_pamu.h line 217

Quoted 5 lines · Varun Sethi
drivers/iommu/fsl_pamu.h new file +5 -0
+
+#define PAACE_TCEF_FORMAT0_8B   0x00
+#define PAACE_TCEF_FORMAT1_RSVD 0x01
+
+#define PAACE_NUMBER_ENTRIES    0x1FF

Where is this number coming from?

Diana

#26 lore raw
Quoted 12 lines

-----Original Message-----
From: Craciun Diana Madalina-STFD002
Sent: Tuesday, February 19, 2013 3:34 PM
To: Sethi Varun-B16395
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; [email protected]; Yoder Stuart-B08248
Subject: Re: [PATCH 6/6 v8] iommu/fsl: Freescale PAMU driver and IOMMU
API implementation.

Quoted 9 lines

drivers/iommu/fsl_pamu.h line 217

Quoted 5 lines · Varun Sethi
drivers/iommu/fsl_pamu.h new file +5 -0
+
+#define PAACE_TCEF_FORMAT0_8B   0x00
+#define PAACE_TCEF_FORMAT1_RSVD 0x01
+
+#define PAACE_NUMBER_ENTRIES    0x1FF

Where is this number coming from?

This is currently hard coded. We will not require these many entries once we implement the LIODN allocation scheme.

-Varun

#27 lore raw
In reply to Varun Sethi

drivers/iommu/fsl_pamu.c line 78

Quoted 10 lines · Varun Sethi
drivers/iommu/fsl_pamu.c new file +10 -0
+/**
+ * pamu_get_ppaace() - Return the primary PACCE
+ * @liodn: liodn PAACT index for desired PAACE
+ *
+ * Returns the ppace pointer upon success else return
+ * null.
+ */
+static struct paace *pamu_get_ppaace(int liodn)
+{
+	if (!ppaact || liodn > PAACE_NUMBER_ENTRIES) {

Shouldn't be "liodn >= PAACE_NUMBER_ENTRIES" ?

drivers/iommu/fsl_pamu.c line 85

Quoted 7 lines
drivers/iommu/fsl_pamu.c new file +7 -0
+		pr_err("PPAACT doesn't exist\n");
+		return NULL;
+	}
+
+	return &ppaact[liodn];
+}
+

Diana

#28 lore raw
Quoted 13 lines

-----Original Message-----
From: Craciun Diana Madalina-STFD002
Sent: Tuesday, February 19, 2013 9:30 PM
To: Sethi Varun-B16395
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; [email protected]; Yoder Stuart-B08248
Subject: Re: [PATCH 6/6 v8] iommu/fsl: Freescale PAMU driver and IOMMU
API implementation.

On 02/18/2013 02:52 PM, Varun Sethi wrote:

Quoted 11 lines

drivers/iommu/fsl_pamu.c line 78

Quoted 9 lines
drivers/iommu/fsl_pamu.c new file +9 -0
+/**
+ * pamu_get_ppaace() - Return the primary PACCE
+ * @liodn: liodn PAACT index for desired PAACE
+ *
+ * Returns the ppace pointer upon success else return
+ * null.
+ */
+static struct paace *pamu_get_ppaace(int liodn) {
+	if (!ppaact || liodn > PAACE_NUMBER_ENTRIES) {

Shouldn't be "liodn >= PAACE_NUMBER_ENTRIES" ?

Yes, will fix this.

-Varun

#29 lore raw
In reply to Varun Sethi

Have not got through the entire file, but have a few comments...

+/*
+ * Set the PAACE type as primary and set the coherency required domain
+ * attribute
+ */
+static void pamu_setup_default_xfer_to_host_ppaace(struct paace *ppaace) +{
+ set_bf(ppaace->addr_bitfields, PAACE_AF_PT, PAACE_PT_PRIMARY);
+
+ set_bf(ppaace->domain_attr.to_host.coherency_required, PAACE_DA_HOST_CR,
+ PAACE_M_COHERENCE_REQ);
+}
+
+/*
+ * Set the PAACE type as secondary and set the coherency required domain
+ * attribute.
+ */
+static void pamu_setup_default_xfer_to_host_spaace(struct paace *spaace) +{
+ set_bf(spaace->addr_bitfields, PAACE_AF_PT, PAACE_PT_SECONDARY);
+ set_bf(spaace->domain_attr.to_host.coherency_required, PAACE_DA_HOST_CR,
+ PAACE_M_COHERENCE_REQ);
+}

Can we change the names of the above functions... I know there is some history
with the name, but "xfer_to_host" is confusing.

Maybe just call them:

pamu_init_paace()
pamu_init_spaace()

Quoted 21 lines
drivers/iommu/fsl_pamu.c new file +21 -0
+/**
+ * pamu_config_spaace() - Sets up SPAACE entry for specified subwindow
+ *
+ * @liodn:  Logical IO device number
+ * @subwin_cnt:  number of sub-windows associated with dma-window
+ * @subwin_addr: starting address of subwindow
+ * @subwin_size: size of subwindow
+ * @omi: Operation mapping index
+ * @rpn: real (true physical) page number
+ * @snoopid: snoop id for hardware coherency -- if ~snoopid == 0 then
+ *                       snoopid not defined
+ * @stashid: cache stash id for associated cpu
+ * @enable: enable/disable subwindow after reconfiguration
+ * @prot: sub window permissions
+ *
+ * Returns 0 upon success else error code < 0 returned
+ */
+int pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin_addr,
+                      phys_addr_t subwin_size, u32 omi, unsigned long rpn,
+                      u32 snoopid, u32 stashid, int enable, int prot)
+{

drivers/iommu/fsl_pamu.c line 421

Quoted 10 lines
drivers/iommu/fsl_pamu.c new file +10 -0
+       struct paace *paace;
+
+       /* setup sub-windows */
+       if (!subwin_cnt) {
+               pr_err("Invalid subwindow count\n");
+               return -EINVAL;
+       }
+
+       paace = pamu_get_ppaace(liodn);
+       if (subwin_addr > 0 && subwin_addr < subwin_cnt && paace) {

Why is the comparison subwin_addr < subwin_cnt? Seems wrong...

Quoted 13 lines
drivers/iommu/fsl_pamu.c new file +13 -0
+               paace = pamu_get_spaace(paace, subwin_addr - 1);
+
+               if (paace && !(paace->addr_bitfields & PAACE_V_VALID)) {
+                       pamu_setup_default_xfer_to_host_spaace(paace);
+                       set_bf(paace->addr_bitfields, SPAACE_AF_LIODN, liodn);
+               }
+       }
+
+       if (!paace) {
+               pr_err("Invalid liodn entry\n");
+               return -ENOENT;
+       }
+

drivers/iommu/fsl_pamu.c line 444

Quoted 10 lines
drivers/iommu/fsl_pamu.c new file +10 -0
+       if (!enable && prot == PAACE_AP_PERMS_DENIED) {
+               if (subwin_addr > 0)
+                       set_bf(paace->addr_bitfields, PAACE_AF_V,
+                                PAACE_V_INVALID);
+               else
+                       set_bf(paace->addr_bitfields, PAACE_AF_AP,
+                                prot);
+               mb();
+               return 0;
+       }

Can you add a comment to the above if statement...when is this function called with PAACE_AP_PERMS_DENIED?

Quoted 44 lines
drivers/iommu/fsl_pamu.c new file +44 -0
+       if (subwin_size & (subwin_size - 1) || subwin_size < PAMU_PAGE_SIZE) {
+               pr_err("subwindow size out of range, or not a power of 2\n");
+               return -EINVAL;
+       }
+
+       if (rpn == ULONG_MAX) {
+               pr_err("real page number out of range\n");
+               return -EINVAL;
+       }
+
+       /* window size is 2^(WSE+1) bytes */
+       set_bf(paace->win_bitfields, PAACE_WIN_SWSE,
+              map_addrspace_size_to_wse(subwin_size));
+
+       set_bf(paace->impl_attr, PAACE_IA_ATM, PAACE_ATM_WINDOW_XLATE);
+       paace->twbah = rpn >> 20;
+       set_bf(paace->win_bitfields, PAACE_WIN_TWBAL, rpn);
+       set_bf(paace->addr_bitfields, PAACE_AF_AP, prot);
+
+       /* configure snoop id */
+       if (~snoopid != 0)
+               paace->domain_attr.to_host.snpid = snoopid;
+
+       /* set up operation mapping if it's configured */
+       if (omi < OME_NUMBER_ENTRIES) {
+               set_bf(paace->impl_attr, PAACE_IA_OTM, PAACE_OTM_INDEXED);
+               paace->op_encode.index_ot.omi = omi;
+       } else if (~omi != 0) {
+               pr_err("bad operation mapping index: %d\n", omi);
+               return -EINVAL;
+       }
+
+       if (~stashid != 0)
+               set_bf(paace->impl_attr, PAACE_IA_CID, stashid);
+
+       smp_wmb();
+
+       if (enable)
+               paace->addr_bitfields |= PAACE_V_VALID;
+
+       mb();
+
+       return 0;
+}
#30 lore raw
Quoted 40 lines

-----Original Message-----
From: Stuart Yoder [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 4:03 AM
To: Sethi Varun-B16395
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Joerg Roedel; Yoder Stuart-B08248
Subject: Re: [PATCH 6/6 v8] iommu/fsl: Freescale PAMU driver and IOMMU
API implementation.

Have not got through the entire file, but have a few comments...

drivers/iommu/fsl_pamu.c new file +9 -0
+/*
+ * Set the PAACE type as primary and set the coherency required domain
+ * attribute
+ */
+static void pamu_setup_default_xfer_to_host_ppaace(struct paace
+*ppaace) {
+       set_bf(ppaace->addr_bitfields, PAACE_AF_PT, PAACE_PT_PRIMARY);
+
+       set_bf(ppaace->domain_attr.to_host.coherency_required,

PAACE_DA_HOST_CR,

drivers/iommu/fsl_pamu.c new file +12 -0
+              PAACE_M_COHERENCE_REQ);
+}
+
+/*
+ * Set the PAACE type as secondary and set the coherency required
+domain
+ * attribute.
+ */
+static void pamu_setup_default_xfer_to_host_spaace(struct paace
+*spaace) {
+       set_bf(spaace->addr_bitfields, PAACE_AF_PT, PAACE_PT_SECONDARY);
+       set_bf(spaace->domain_attr.to_host.coherency_required,

PAACE_DA_HOST_CR,

(quoted diff) +2 -0
+              PAACE_M_COHERENCE_REQ);
+}
Quoted 9 lines

Can we change the names of the above functions... I know there is some
history
with the name, but "xfer_to_host" is confusing.

Maybe just call them:

pamu_init_paace()
pamu_init_spaace()

[Sethi Varun-B16395] ok, will change the function names.

Quoted 20 lines
Quoted 9 lines
drivers/iommu/fsl_pamu.c new file +9 -0
+/**
+ * pamu_config_spaace() - Sets up SPAACE entry for specified
+subwindow
+ *
+ * @liodn:  Logical IO device number
+ * @subwin_cnt:  number of sub-windows associated with dma-window
+ * @subwin_addr: starting address of subwindow
+ * @subwin_size: size of subwindow
+ * @omi: Operation mapping index

drivers/iommu/fsl_pamu.c

Quoted 10 lines
drivers/iommu/fsl_pamu.c new file +10 -0
+ * @rpn: real (true physical) page number
+ * @snoopid: snoop id for hardware coherency -- if ~snoopid == 0 then
+ *                       snoopid not defined
+ * @stashid: cache stash id for associated cpu
+ * @enable: enable/disable subwindow after reconfiguration
+ * @prot: sub window permissions
+ *
+ * Returns 0 upon success else error code < 0 returned  */ int
+pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin_addr,
+                      phys_addr_t subwin_size, u32 omi, unsigned long

rpn,

Quoted 15 lines

drivers/iommu/fsl_pamu.c line 421

Quoted 12 lines
drivers/iommu/fsl_pamu.c new file +12 -0
+                      u32 snoopid, u32 stashid, int enable, int prot)
+{
+       struct paace *paace;
+
+       /* setup sub-windows */
+       if (!subwin_cnt) {
+               pr_err("Invalid subwindow count\n");
+               return -EINVAL;
+       }
+
+       paace = pamu_get_ppaace(liodn);
+       if (subwin_addr > 0 && subwin_addr < subwin_cnt && paace) {

Why is the comparison subwin_addr < subwin_cnt? Seems wrong...

[Sethi Varun-B16395] It's actually the subwindow index. I will rename the variable.

Quoted 20 lines

drivers/iommu/fsl_pamu.c

Quoted 3 lines
drivers/iommu/fsl_pamu.c new file +3 -0
+               paace = pamu_get_spaace(paace, subwin_addr - 1);
+
+               if (paace && !(paace->addr_bitfields & PAACE_V_VALID))

{

Review

Quoted 2 lines
(quoted diff) +2 -0
+                       pamu_setup_default_xfer_to_host_spaace(paace);
+                       set_bf(paace->addr_bitfields, SPAACE_AF_LIODN,

liodn);

Quoted 13 lines
drivers/iommu/fsl_pamu.c new file +13 -0
+               }
+       }
+
+       if (!paace) {
+               pr_err("Invalid liodn entry\n");
+               return -ENOENT;
+       }
+
+       if (!enable && prot == PAACE_AP_PERMS_DENIED) {
+               if (subwin_addr > 0)
+                       set_bf(paace->addr_bitfields, PAACE_AF_V,
+                                PAACE_V_INVALID);
+               else
Quoted 9 lines

drivers/iommu/fsl_pamu.c line 444

Quoted 5 lines
drivers/iommu/fsl_pamu.c new file +5 -0
+                       set_bf(paace->addr_bitfields, PAACE_AF_AP,
+                                prot);
+               mb();
+               return 0;
+       }

Can you add a comment to the above if statement...when is this function called with PAACE_AP_PERMS_DENIED?

[Sethi Varun-B16395] Actually, this piece of code is redundant in case of the window based API. I will remove this. PAACE_AP_PERMS_DENIED is primarily used for disabling the primary subwindow.

-Varun

#31 lore raw
In reply to Varun Sethi

Some more comments...

Quoted 6 lines · Varun Sethi
drivers/iommu/fsl_pamu.c new file +6 -0
+/* Handling access violations */
+#define make64(high, low) (((u64)(high) << 32) | (low))
+
+struct pamu_isr_data {
+       void __iomem *pamu_reg_base;    /* Base address of PAMU regs*/
+       unsigned int count;             /* The number of PAMUs */

drivers/iommu/fsl_pamu.c line 59

Quoted 10 lines
drivers/iommu/fsl_pamu.c new file +10 -0
+};
+
+static struct paace *ppaact;
+static struct paace *spaact;
+static struct ome *omt;
+
+/* maximum subwindows permitted per liodn */
+unsigned int max_subwindow_count;
+/* Number of SPAACT entries */
+unsigned long max_subwins;

I don't like that these variables are not static... and they are referenced directly
from code in fsl_pamu_domain.c. It would be better if fsl_pamu_domain.c called an accessor function-- like pamu_get_max_subwins.

drivers/iommu/fsl_pamu.c line 62

Quoted 2 lines
drivers/iommu/fsl_pamu.c new file +2 -0
+/* Pool for fspi allocation */
+struct gen_pool *spaace_pool;

spaace_pool should be static?

I'm wondering if you should change pamu_isr_data into a more
general struct analagous to struct intel_iommu. You could
put in there the max # of subwins, etc. You could then
provide an accessor to get at that data.

[cut]

Quoted 17 lines
drivers/iommu/fsl_pamu.c new file +17 -0
+/**
+ * pamu_get_fspi_and_allocate() - Allocates fspi index and reserves subwindows
+ *                                required for primary PAACE in the secondary
+ *                                PAACE table.
+ * @subwin_cnt: Number of subwindows to be reserved.
+ *
+ * A PPAACE entry may have a number of associated subwindows. A subwindow
+ * corresponds to a SPAACE entry in the SPAACT table. Each PAACE entry stores
+ * the index (fspi) of the first SPAACE entry in the SPAACT table. This
+ * function returns the index of the first SPAACE entry. The remaining
+ * SPAACE entries are reserved contiguously from that index.
+ *
+ * Returns a valid fspi index in the range of 0 - max_subwins on success.
+ * If no SPAACE entry is available or the allocator can not reserve the required
+ * number of contiguous entries function returns ULONG_MAX indicating a failure.
+ *
+*/

drivers/iommu/fsl_pamu.c line 223

Quoted 10 lines
drivers/iommu/fsl_pamu.c new file +10 -0
+static unsigned long pamu_get_fspi_and_allocate(u32 subwin_cnt)
+{
+       unsigned long spaace_addr;
+
+       spaace_addr = gen_pool_alloc(spaace_pool, subwin_cnt * sizeof(struct paace));
+       if (!spaace_addr)
+               return ULONG_MAX;
+
+       return (spaace_addr - (unsigned long)spaact) / (sizeof(struct paace));
+}

In order to keep things symmetric (with the free function) can we just call the above
function:

pamu_alloc_subwins()

Quoted 19 lines
drivers/iommu/fsl_pamu.c new file +19 -0
+/* Release the subwindows reserved for a particular LIODN */
+void pamu_free_subwins(int liodn)
+{
+       struct paace *ppaace;
+       u32 subwin_cnt, size;
+
+       ppaace = pamu_get_ppaace(liodn);
+       if (!ppaace) {
+               pr_err("Invalid liodn entry\n");
+               return;
+       }
+
+       if (get_bf(ppaace->addr_bitfields, PPAACE_AF_MW)) {
+               subwin_cnt = 1UL << (get_bf(ppaace->impl_attr, PAACE_IA_WCE) + 1);
+               size = (subwin_cnt - 1) * sizeof(struct paace);
+               gen_pool_free(spaace_pool, (unsigned long)&spaact[ppaace->fspi], size);
+               set_bf(ppaace->addr_bitfields, PPAACE_AF_MW, 0);
+       }
+}

[cut]

drivers/iommu/fsl_pamu.c line 515

Quoted 11 lines
drivers/iommu/fsl_pamu.c new file +11 -0
+/**
+ * get_stash_id - Returns stash destination id corresponding to a
+ *                cache type and vcpu.
+ * @stash_dest_hint: L1, L2 or L3
+ * @vcpu: vpcu target for a particular cache type.
+ *
+ * Returs stash on success or ~(u32)0 on failure.
+ *
+ */
+u32 get_stash_id(u32 stash_dest_hint, u32 vcpu)
+{

The stash dest is really not a hint, right? It's the requested stash destination. So maybe just drop 'hint' from the name.

The CPU here is really a physical CPU number and has nothing to do with vcpus I think. vcpu implies the index is inside a virtual machine...but this API is generic and may or may not be used with KVM.

Quoted 5 lines
drivers/iommu/fsl_pamu.c new file +5 -0
+
+/*
+ * Get the maximum number of PAACT table entries
+ * and subwindows supported by PAMU
+ */

drivers/iommu/fsl_pamu.c line 666

Quoted 10 lines
drivers/iommu/fsl_pamu.c new file +10 -0
+static void get_pamu_cap_values(unsigned long pamu_reg_base)
+{
+       u32 pc_val;
+
+       pc_val = in_be32((u32 *)(pamu_reg_base + PAMU_PC3));
+       /* Maximum number of subwindows per liodn */
+       max_subwindow_count = 1 << (1 + PAMU_PC3_MWCE(pc_val));
+       /* Total number of SPACCT entries */
+       max_subwins = PAACE_NUMBER_ENTRIES * max_subwindow_count;
+}

If you follow the suggestion at the top of this file, this function
would become something like-- init_pamu_capabilities(). And then
create an accessor function to access max subwins, etc.

Also, BTW, I don't see any support for the DOMAIN_ATTR_WINDOWS attribute in your patch. Was that coming in a later patch?

[cut

Quoted 20 lines
drivers/iommu/fsl_pamu.c new file +20 -0
+static int __init fsl_pamu_probe(struct platform_device *pdev)
+{
+       void __iomem *pamu_regs = NULL;
+       struct ccsr_guts __iomem *guts_regs = NULL;
+       u32 pamubypenr, pamu_counter;
+       unsigned long pamu_reg_off;
+       unsigned long pamu_reg_base;
+       struct pamu_isr_data *data;
+       struct device_node *guts_node;
+       u64 size;
+       struct page *p;
+       int ret = 0;
+       int irq;
+       phys_addr_t ppaact_phys;
+       phys_addr_t spaact_phys;
+       phys_addr_t omt_phys;
+       size_t mem_size = 0;
+       unsigned int order = 0;
+       u32 csd_port_id = 0;
+       unsigned i;

drivers/iommu/fsl_pamu.c line 1005

Quoted 10 lines
drivers/iommu/fsl_pamu.c new file +10 -0
+       /*
+        * enumerate all PAMUs and allocate and setup PAMU tables
+        * for each of them,
+        * NOTE : All PAMUs share the same LIODN tables.
+        */
+
+       pamu_regs = of_iomap(pdev->dev.of_node, 0);
+       if (!pamu_regs) {
+               dev_err(&pdev->dev, "ioremap of PAMU node failed\n");
+               return -ENOMEM;

Any reason not to be consistent with the other error handling-- set ret and goto error"?

drivers/iommu/fsl_pamu.c line 1018

Quoted 13 lines
drivers/iommu/fsl_pamu.c new file +13 -0
+       }
+       of_get_address(pdev->dev.of_node, 0, &size, NULL);
+
+       irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+       if (irq == NO_IRQ) {
+               dev_warn(&pdev->dev, "no interrupts listed in PAMU node\n");
+               goto error;
+       }
+
+       data = kzalloc(sizeof(struct pamu_isr_data), GFP_KERNEL);
+       if (!data) {
+               iounmap(pamu_regs);
+               return -ENOMEM;

Any reason not to be consistent with the other error handling-- set ret and goto error"?

Stuart

#32 lore raw
In reply to Varun Sethi

On Mon, Feb 18, 2013 at 6:52 AM, Varun Sethi <[email protected]> wrote:
[cut]

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+static phys_addr_t get_phys_addr(struct fsl_dma_domain *dma_domain, unsigned long iova)
+{
+       u32 win_cnt = dma_domain->win_cnt;
+       struct dma_window *win_ptr =
+                               &dma_domain->win_arr[0];
+       struct iommu_domain_geometry *geom;
+
+       geom = &dma_domain->iommu_domain->geometry;
+
+       if (!win_cnt || !dma_domain->geom_size) {

drivers/iommu/fsl_pamu_domain.c line 98

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+               pr_err("Number of windows/geometry not configured for the domain\n");
+               return 0;
+       }
+
+       if (win_cnt > 1) {
+               u64 subwin_size;
+               unsigned long subwin_iova;
+               u32 wnd;
+
+               subwin_size = dma_domain->geom_size >> ilog2(win_cnt);

Could it be just geom_size / win_cnt ??

drivers/iommu/fsl_pamu_domain.c line 110

Quoted 12 lines
drivers/iommu/fsl_pamu_domain.c new file +12 -0
+               subwin_iova = iova & ~(subwin_size - 1);
+               wnd = (subwin_iova - geom->aperture_start) >> ilog2(subwin_size);
+               win_ptr = &dma_domain->win_arr[wnd];
+       }
+
+       if (win_ptr->valid)
+               return (win_ptr->paddr + (iova & (win_ptr->size - 1)));
+
+       return 0;
+}
+
+static int map_liodn_subwins(int liodn, struct fsl_dma_domain *dma_domain)

Just call it map_subwins(). They are just sub windows, not "liodn sub windows".

[cut]

Quoted 1 line

+static int map_liodn_win(int liodn, struct fsl_dma_domain *dma_domain)

Call it map_win().

[cut]

drivers/iommu/fsl_pamu_domain.c line 321

Quoted 11 lines
drivers/iommu/fsl_pamu_domain.c new file +11 -0
+static struct fsl_dma_domain *iommu_alloc_dma_domain(void)
+{
+       struct fsl_dma_domain *domain;
+
+       domain = kmem_cache_zalloc(fsl_pamu_domain_cache, GFP_KERNEL);
+       if (!domain)
+               return NULL;
+
+       domain->stash_id = ~(u32)0;
+       domain->snoop_id = ~(u32)0;
+       domain->win_cnt = max_subwindow_count;

To align with my previous comments on fsl_pamu.c, I think instead of referencing a global variable (in fsl_pamu.c) you should be making an accessor API call here to get
the max subwindow _count.

Quoted 17 lines
drivers/iommu/fsl_pamu_domain.c new file +17 -0
+       domain->geom_size = 0;
+
+       INIT_LIST_HEAD(&domain->devices);
+
+       spin_lock_init(&domain->domain_lock);
+
+       return domain;
+}
+
+static inline struct device_domain_info *find_domain(struct device *dev)
+{
+       return dev->archdata.iommu_domain;
+}
+
+static void remove_domain_ref(struct device_domain_info *info, u32 win_cnt)
+{
+               list_del(&info->link);

drivers/iommu/fsl_pamu_domain.c line 348

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+               spin_lock(&iommu_lock);
+               if (win_cnt)
+                       pamu_free_subwins(info->liodn);
+               pamu_disable_liodn(info->liodn);
+               spin_unlock(&iommu_lock);
+               spin_lock(&device_domain_lock);
+               info->dev->archdata.iommu_domain = NULL;
+               kmem_cache_free(iommu_devinfo_cache, info);
+               spin_unlock(&device_domain_lock);
+}

The above function is literally removing the _device_ reference from the domain.
The name implies that it is removing a "domain reference". Suggestion is
to call it "remove_device_ref".

Also, the whitespace is messed up there. You have 2 tabs instead of 1.

drivers/iommu/fsl_pamu_domain.c line 360

Quoted 11 lines
drivers/iommu/fsl_pamu_domain.c new file +11 -0
+static void destroy_domain(struct fsl_dma_domain *dma_domain)
+{
+       struct device_domain_info *info;
+
+       /* Dissociate all the devices from this domain */
+       while (!list_empty(&dma_domain->devices)) {
+               info = list_entry(dma_domain->devices.next,
+                       struct device_domain_info, link);
+               remove_domain_ref(info, dma_domain->win_cnt);
+       }
+}

This function is removing all devices from a domain...maybe to be consistent with my
suggestion below on detach_domain(), call this detach_all_devices().
We have 2 functions
doing almost the same thing....one detaches a single device, one detaches all devices.
The current names "destroy_domain" and "detach_domain" are not as clear to me.

Quoted 7 lines
drivers/iommu/fsl_pamu_domain.c new file +7 -0
+static void detach_domain(struct device *dev, struct fsl_dma_domain *dma_domain)
+{
+       struct device_domain_info *info;
+       struct list_head *entry, *tmp;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dma_domain->domain_lock, flags);

drivers/iommu/fsl_pamu_domain.c line 378

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+       /* Remove the device from the domain device list */
+       if (!list_empty(&dma_domain->devices)) {
+               list_for_each_safe(entry, tmp, &dma_domain->devices) {
+                       info = list_entry(entry, struct device_domain_info, link);
+                       if (info->dev == dev)
+                               remove_domain_ref(info, dma_domain->win_cnt);
+               }
+       }
+       spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
+}

This function is not "detaching a domain", but is detaching a device.
Call it detach_device().

drivers/iommu/fsl_pamu_domain.c line 381

Quoted 2 lines
drivers/iommu/fsl_pamu_domain.c new file +2 -0
+static void attach_domain(struct fsl_dma_domain *dma_domain, int liodn, struct device *dev)
+{

Same thing here. This is not attaching a domain, but attaching a
device. Call it attach_device.

Quoted 32 lines
drivers/iommu/fsl_pamu_domain.c new file +32 -0
+       struct device_domain_info *info, *old_domain_info;
+
+       spin_lock(&device_domain_lock);
+       /*
+        * Check here if the device is already attached to domain or not.
+        * If the device is already attached to a domain detach it.
+        */
+       old_domain_info = find_domain(dev);
+       if (old_domain_info && old_domain_info->domain != dma_domain) {
+               spin_unlock(&device_domain_lock);
+               detach_domain(dev, old_domain_info->domain);
+               spin_lock(&device_domain_lock);
+       }
+
+       info = kmem_cache_zalloc(iommu_devinfo_cache, GFP_KERNEL);
+
+       info->dev = dev;
+       info->liodn = liodn;
+       info->domain = dma_domain;
+
+       list_add(&info->link, &dma_domain->devices);
+       /*
+        * In case of devices with multiple LIODNs just store
+        * the info for the first LIODN as all
+        * LIODNs share the same domain
+        */
+       if (!old_domain_info)
+               dev->archdata.iommu_domain = info;
+       spin_unlock(&device_domain_lock);
+
+}
+

[cut]

drivers/iommu/fsl_pamu_domain.c line 468

Quoted 4 lines
drivers/iommu/fsl_pamu_domain.c new file +4 -0
+/* Configure geometry settings for all LIODNs associated with domain */
+static int configure_domain(struct fsl_dma_domain *dma_domain,
+                           struct iommu_domain_geometry *geom_attr,
+                           u32 win_cnt)

This function is not configuring the iommu domain...which is a concept in the Linux driver, it is taking the domain geometry and setting up the PAMU tables for all LIODNs currently in the domain.

Maybe it would help if you used a prefix like "pamu" or "paact" to identify functions that operate on the actual PAMU tables.

maybe: pamu_set_domain_geometry()

drivers/iommu/fsl_pamu_domain.c line 476

Quoted 8 lines
drivers/iommu/fsl_pamu_domain.c new file +8 -0
+{
+       struct device_domain_info *info;
+       int ret = 0;
+
+       if (!list_empty(&dma_domain->devices)) {
+               list_for_each_entry(info, &dma_domain->devices, link) {
+                       ret = configure_liodn(info->liodn, info->dev, dma_domain,
+                                             geom_attr, win_cnt);

...and following the above naming convention, call this (?): pamu_set_liodn

Quoted 8 lines
drivers/iommu/fsl_pamu_domain.c new file +8 -0
+                       if (ret)
+                               break;
+               }
+       }
+
+       return ret;
+}
+

[cut]

Quoted 19 lines
drivers/iommu/fsl_pamu_domain.c new file +19 -0
+static int fsl_pamu_window_enable(struct iommu_domain *domain, u32 wnd_nr,
+                                 phys_addr_t paddr, u64 size, int iommu_prot)
+{
+       struct fsl_dma_domain *dma_domain = domain->priv;
+       struct dma_window *wnd;
+       int prot = 0;
+       int ret;
+       unsigned long flags;
+       u64 win_size;
+
+       if (iommu_prot & IOMMU_READ)
+               prot |= PAACE_AP_PERMS_QUERY;
+       if (iommu_prot & IOMMU_WRITE)
+               prot |= PAACE_AP_PERMS_UPDATE;
+
+       spin_lock_irqsave(&dma_domain->domain_lock, flags);
+       if (!dma_domain->win_arr) {
+               pr_err("Number of windows not configured\n");
+               spin_unlock_irqrestore(&dma_domain->domain_lock, flags);

drivers/iommu/fsl_pamu_domain.c line 597

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+               return -ENODEV;
+       }
+
+       if (wnd_nr >= dma_domain->win_cnt) {
+               pr_err("Invalid window index\n");
+               spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
+               return -EINVAL;
+       }
+
+       win_size = dma_domain->geom_size >> ilog2(dma_domain->win_cnt);

Isn't size just geom_size / win_cnt. Not sure why you do the ilog2()
and right shift...
We already validated that win_cnt is power of 2 when it was set.

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+       if (size > win_size) {
+               pr_err("Invalid window size \n");
+               spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
+               return -EINVAL;
+       }
+
+       if (dma_domain->win_cnt == 1) {
+               if (dma_domain->enabled) {
+                       pr_err("Disable the window before updating the mapping\n");
+                       spin_unlock_irqrestore(&dma_domain->domain_lock, flags);

drivers/iommu/fsl_pamu_domain.c line 617

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+                       return -EBUSY;
+               }
+
+               ret = check_size(size, domain->geometry.aperture_start);
+               if (ret) {
+                       pr_err("Aperture start not aligned to the size\n");
+                       spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
+                       return -EINVAL;
+               }
+       }

Why is win_cnt==1 a special case? Would the geometry not have been verified
when it was originally set up?

Also, do you need a check here to verify if the geometry has been set. Is it a requirement to set the geometry prior to window enable?

Quoted 22 lines
drivers/iommu/fsl_pamu_domain.c new file +22 -0
+       wnd = &dma_domain->win_arr[wnd_nr];
+       if (!wnd->valid) {
+               wnd->paddr = paddr;
+               wnd->size = size;
+               wnd->prot = prot;
+
+               ret = update_domain_mapping(dma_domain, wnd_nr);
+               if (!ret) {
+                       wnd->valid = 1;
+                       dma_domain->mapped++;
+               }
+       } else {
+               pr_err("Disable the window before updating the mapping\n");
+               ret = -EBUSY;
+       }
+
+       spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
+
+       return ret;
+}
+
+/*

[cut]

Quoted 4 lines
drivers/iommu/fsl_pamu_domain.c new file +4 -0
+static int fsl_pamu_attach_device(struct iommu_domain *domain,
+                                 struct device *dev)
+{
+       struct fsl_dma_domain *dma_domain = domain->priv;

drivers/iommu/fsl_pamu_domain.c line 706

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+       const u32 *prop;
+       u32 prop_cnt;
+       int len, ret = 0;
+       struct pci_dev *pdev = NULL;
+       struct pci_controller *pci_ctl;
+
+       /*
+        * Hack to make attach device work for the PCI devices. Simply assign the
+        * the LIODN for the PCI controller to the PCI device.
+        */

Instead of "Simply assign...", perhaps say instead: Use the LIODN for the PCI controller when attaching a PCI device.

drivers/iommu/fsl_pamu_domain.c line 718

Quoted 12 lines
drivers/iommu/fsl_pamu_domain.c new file +12 -0
+       if (dev->bus == &pci_bus_type) {
+               pdev = to_pci_dev(dev);
+               pci_ctl = pci_bus_to_host(pdev->bus);
+               /*
+                * make dev point to pci controller device
+                * so we can get the LIODN programmed by
+                * u-boot;
+                */
+               dev = pci_ctl->parent;
+       }
+
+       prop = of_get_property(dev->of_node, "fsl,liodn", &len);

suggestion: name "prop" to be "liodn" and "prop_cnt" to be "liodn_cnt". That will be more clear.

Quoted 34 lines
drivers/iommu/fsl_pamu_domain.c new file +34 -0
+       if (prop) {
+               prop_cnt = len / sizeof(u32);
+               ret = handle_attach_device(dma_domain, dev,
+                                        prop, prop_cnt);
+       } else {
+               pr_err("missing fsl,liodn property at %s\n",
+                         dev->of_node->full_name);
+                       ret = -EINVAL;
+       }
+
+       return ret;
+}
+
+static void fsl_pamu_detach_device(struct iommu_domain *domain,
+                                     struct device *dev)
+{
+       struct fsl_dma_domain *dma_domain = domain->priv;
+       const u32 *prop;
+       int len;
+       struct pci_dev *pdev = NULL;
+       struct pci_controller *pci_ctl;
+
+       /*
+        * Hack to make detach device work for the PCI devices. Simply assign the
+        * the LIODN for the PCI controller to the PCI device.
+        */
+       if (dev->bus == &pci_bus_type) {
+               pdev = to_pci_dev(dev);
+               pci_ctl = pci_bus_to_host(pdev->bus);
+               /*
+                * make dev point to pci controller device
+                * so we can get the LIODN programmed by
+                * u-boot;
+                */

drivers/iommu/fsl_pamu_domain.c line 762

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+               dev = pci_ctl->parent;
+       }
+
+       prop = of_get_property(dev->of_node, "fsl,liodn", &len);
+       if (prop)
+               detach_domain(dev, dma_domain);
+       else
+               pr_err("missing fsl,liodn property at %s\n",
+                         dev->of_node->full_name);
+}

I understand why you need the LIODN when attaching, but why do you get it
in the detatch function. You are not using "prop" here.

[cut]

drivers/iommu/fsl_pamu_domain.c line 939

Quoted 13 lines
drivers/iommu/fsl_pamu_domain.c new file +13 -0
+static  bool check_pci_ctl_endpt_part(struct pci_controller *pci_ctl)
+{
+       u32 version;
+
+       /* Check the PCI controller version number by readding BRR1 register */
+       version = in_be32(pci_ctl->cfg_addr + (PCI_FSL_BRR1 >> 2));
+       version &= PCI_FSL_BRR1_VER;
+       /* If PCI controller version is >= 0x204 we can partition endpoints*/
+       if (version >= 0x204)
+               return 1;
+
+       return 0;
+}

Can we just use the compatible string here to identify the different kinds of PCI
controllers? Reading the actual device registers is ugly right now because
you are #defining the BRR1 stuff in a generic powerpc header.

Quoted 4 lines
drivers/iommu/fsl_pamu_domain.c new file +4 -0
+static int fsl_pamu_add_device(struct device *dev)
+{
+       struct iommu_group *group = NULL;
+       struct pci_dev *pdev;

drivers/iommu/fsl_pamu_domain.c line 954

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+       struct pci_dev *bridge, *dma_pdev = NULL;
+       struct pci_controller *pci_ctl;
+       int ret;
+
+       /*
+        * For platform devices we allocate a separate group for
+        * each of the devices.
+        */
+       if (dev->bus == &pci_bus_type) {
+               bool pci_endpt_part;

That variable name is not clear, the abbreviations are not natural. I would just
call it pci_endpoint_partitioning.

Quoted 79 lines
drivers/iommu/fsl_pamu_domain.c new file +79 -0
+               pdev = to_pci_dev(dev);
+               /* Don't create device groups for virtual PCI bridges */
+               if (pdev->subordinate)
+                       return 0;
+
+               pci_ctl = pci_bus_to_host(pdev->bus);
+               pci_endpt_part = check_pci_ctl_endpt_part(pci_ctl);
+               /* We can partition PCIe devices so assign device group to the device */
+               if (pci_endpt_part) {
+                       bridge = pci_find_upstream_pcie_bridge(pdev);
+                       if (bridge) {
+                               if (pci_is_pcie(bridge))
+                                       dma_pdev = pci_get_domain_bus_and_slot(
+                                                               pci_domain_nr(pdev->bus),
+                                                               bridge->subordinate->number, 0);
+                               if (!dma_pdev)
+                                       dma_pdev = pci_dev_get(bridge);
+                       } else
+                               dma_pdev = pci_dev_get(pdev);
+                       /* Account for quirked devices */
+                       swap_pci_ref(&dma_pdev, pci_get_dma_source(dma_pdev));
+                       group = get_device_iommu_group(&pdev->dev);
+                       pci_dev_put(pdev);
+                       /*
+                        * PCIe controller is not a paritionable entity
+                        * free the controller device iommu_group.
+                        */
+                       if (pci_ctl->parent->iommu_group)
+                               iommu_group_remove_device(pci_ctl->parent);
+               } else {
+                       /*
+                        * All devices connected to the controller will share the
+                        * PCI controllers device group. If this is the first
+                        * device to be probed for the pci controller, copy the
+                        * device group information from the PCI controller device
+                        * node and remove the PCI controller iommu group.
+                        * For subsequent devices, the iommu group information can
+                        * be obtained from sibling devices (i.e. from the bus_devices
+                        * link list).
+                        */
+                       if (pci_ctl->parent->iommu_group) {
+                               group = get_device_iommu_group(pci_ctl->parent);
+                               iommu_group_remove_device(pci_ctl->parent);
+                       } else {
+                               /* check if this is the first device on the bus*/
+                               if (pdev->bus_list.next == pdev->bus_list.prev) {
+                                       struct pci_bus *bus = pdev->bus->parent;
+                                       int found = 0;
+                                       /* Traverese the parent bus list to get
+                                        * pdev & dev for the sibling device.
+                                        */
+                                       while (bus) {
+                                               if (!list_empty(&bus->devices)) {
+                                                       pdev = container_of(bus->devices.next,
+                                                                struct pci_dev, bus_list);
+                                                       group = iommu_group_get(&pdev->dev);
+                                                       /*
+                                                        * All devices should be associated with
+                                                        * a group.
+                                                        */
+                                                       if (group)
+                                                               found = 1;
+                                                       break;
+                                               } else
+                                                       bus = bus->parent;
+                                       }
+                                       if (!found)
+                                               dev_err(&pdev->dev, "Failed to allocate group for the device\n");
+                               } else {
+                                       /*
+                                        * Get the pdev & dev for the sibling device
+                                        */
+                                       pdev = container_of(pdev->bus_list.prev, struct pci_dev, bus_list);
+                                       group = iommu_group_get(&pdev->dev);
+                               }
+                       }
+               }
+       } else
+               group = get_device_iommu_group(dev);

drivers/iommu/fsl_pamu_domain.c line 1044

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+
+       if (IS_ERR(group))
+               return PTR_ERR(group);
+
+       ret = iommu_group_add_device(group, dev);
+
+       iommu_group_put(group);
+       return ret;
+}
+

Regards,
Stuart

#33 lore raw
Quoted 27 lines

-----Original Message-----
From: Stuart Yoder [mailto:[email protected]]
Sent: Saturday, March 02, 2013 4:58 AM
To: Sethi Varun-B16395
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Joerg Roedel; Yoder Stuart-B08248
Subject: Re: [PATCH 6/6 v8] iommu/fsl: Freescale PAMU driver and IOMMU
API implementation.

On Mon, Feb 18, 2013 at 6:52 AM, Varun Sethi <[email protected]> wrote:
[cut]

drivers/iommu/fsl_pamu_domain.c

Quoted 11 lines
drivers/iommu/fsl_pamu_domain.c new file +11 -0
+static phys_addr_t get_phys_addr(struct fsl_dma_domain *dma_domain,
+unsigned long iova) {
+       u32 win_cnt = dma_domain->win_cnt;
+       struct dma_window *win_ptr =
+                               &dma_domain->win_arr[0];
+       struct iommu_domain_geometry *geom;
+
+       geom = &dma_domain->iommu_domain->geometry;
+
+       if (!win_cnt || !dma_domain->geom_size) {
+               pr_err("Number of windows/geometry not configured for

the domain\n");

Quoted 11 lines

drivers/iommu/fsl_pamu_domain.c line 98

Quoted 9 lines
drivers/iommu/fsl_pamu_domain.c new file +9 -0
+               return 0;
+       }
+
+       if (win_cnt > 1) {
+               u64 subwin_size;
+               unsigned long subwin_iova;
+               u32 wnd;
+
+               subwin_size = dma_domain->geom_size >> ilog2(win_cnt);

Could it be just geom_size / win_cnt ??

[Sethi Varun-B16395] You would run in to linking issues with respect to u64 division on 32 bit kernels.

Quoted 4 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+               subwin_iova = iova & ~(subwin_size - 1);
+               wnd = (subwin_iova - geom->aperture_start) >>

ilog2(subwin_size);

Quoted 16 lines

drivers/iommu/fsl_pamu_domain.c

Quoted 12 lines
drivers/iommu/fsl_pamu_domain.c new file +12 -0
+               win_ptr = &dma_domain->win_arr[wnd];
+       }
+
+       if (win_ptr->valid)
+               return (win_ptr->paddr + (iova & (win_ptr->size -
+ 1)));
+
+       return 0;
+}
+
+static int map_liodn_subwins(int liodn, struct fsl_dma_domain
+*dma_domain)

Just call it map_subwins(). They are just sub windows, not "liodn sub windows".

[Sethi Varun-B16395] This would be called per liodn.

Quoted 6 lines

[cut]

Review

Quoted 2 lines
(quoted diff) +2 -0
+static int map_liodn_win(int liodn, struct fsl_dma_domain
+*dma_domain)

Call it map_win().

[Sethi Varun-B16395] This would again be called per liodn.

Quoted 17 lines

[cut]

drivers/iommu/fsl_pamu_domain.c line 321

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+static struct fsl_dma_domain *iommu_alloc_dma_domain(void) {
+       struct fsl_dma_domain *domain;
+
+       domain = kmem_cache_zalloc(fsl_pamu_domain_cache, GFP_KERNEL);
+       if (!domain)
+               return NULL;
+
+       domain->stash_id = ~(u32)0;
+       domain->snoop_id = ~(u32)0;
+       domain->win_cnt = max_subwindow_count;

To align with my previous comments on fsl_pamu.c, I think instead of referencing a global variable (in fsl_pamu.c) you should be making an accessor API call here to get the max subwindow _count.

[Sethi Varun-B16395] ok, I will make a accessor API call.

Quoted 32 lines
Quoted 15 lines
drivers/iommu/fsl_pamu_domain.c new file +15 -0
+       domain->geom_size = 0;
+
+       INIT_LIST_HEAD(&domain->devices);
+
+       spin_lock_init(&domain->domain_lock);
+
+       return domain;
+}
+
+static inline struct device_domain_info *find_domain(struct device
+*dev) {
+       return dev->archdata.iommu_domain; }
+
+static void remove_domain_ref(struct device_domain_info *info, u32
+win_cnt) {

drivers/iommu/fsl_pamu_domain.c

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+               list_del(&info->link);
+               spin_lock(&iommu_lock);
+               if (win_cnt)
+                       pamu_free_subwins(info->liodn);
+               pamu_disable_liodn(info->liodn);
+               spin_unlock(&iommu_lock);
+               spin_lock(&device_domain_lock);
+               info->dev->archdata.iommu_domain = NULL;
+               kmem_cache_free(iommu_devinfo_cache, info);
+               spin_unlock(&device_domain_lock); }

The above function is literally removing the _device_ reference from the domain.
The name implies that it is removing a "domain reference". Suggestion
is
to call it "remove_device_ref".

Quoted 1 line

Also, the whitespace is messed up there. You have 2 tabs instead of 1.

[Sethi Varun-B16395] ok will make the change.

Quoted 12 lines

drivers/iommu/fsl_pamu_domain.c line 360

Quoted 11 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+static void destroy_domain(struct fsl_dma_domain *dma_domain) {
+       struct device_domain_info *info;
+
+       /* Dissociate all the devices from this domain */
+       while (!list_empty(&dma_domain->devices)) {
+               info = list_entry(dma_domain->devices.next,
+                       struct device_domain_info, link);
+               remove_domain_ref(info, dma_domain->win_cnt);
+       }
+}
Quoted 9 lines

This function is removing all devices from a domain...maybe to be consistent with my suggestion below on detach_domain(), call this detach_all_devices().
We have 2 functions
doing almost the same thing....one detaches a single device, one detaches all devices.
The current names "destroy_domain" and "detach_domain" are not as clear to me.

[Sethi Varun-B16395]ok

Quoted 19 lines

drivers/iommu/fsl_pamu_domain.c

Quoted 11 lines
drivers/iommu/fsl_pamu_domain.c new file +11 -0
+static void detach_domain(struct device *dev, struct fsl_dma_domain
+*dma_domain) {
+       struct device_domain_info *info;
+       struct list_head *entry, *tmp;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dma_domain->domain_lock, flags);
+       /* Remove the device from the domain device list */
+       if (!list_empty(&dma_domain->devices)) {
+               list_for_each_safe(entry, tmp, &dma_domain->devices) {
+                       info = list_entry(entry, struct

device_domain_info, link);

drivers/iommu/fsl_pamu.c

Quoted 6 lines
(quoted diff) +2 -0
+                       if (info->dev == dev)
+                               remove_domain_ref(info, dma_domain-

win_cnt);

drivers/iommu/fsl_pamu.c new file +3 -0
+               }
+       }
+       spin_unlock_irqrestore(&dma_domain->domain_lock, flags); }
Quoted 3 lines

This function is not "detaching a domain", but is detaching a device.
Call it detach_device().

[Sethi Varun-B16395] ok, will address this.

Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+static void attach_domain(struct fsl_dma_domain *dma_domain, int
+liodn, struct device *dev) {

Same thing here. This is not attaching a domain, but attaching a
device. Call it attach_device.

[Sethi Varun-B16395] ok.

Quoted 44 lines

drivers/iommu/fsl_pamu_domain.c

Quoted 5 lines
drivers/iommu/fsl_pamu_domain.c new file +5 -0
+       struct device_domain_info *info, *old_domain_info;
+
+       spin_lock(&device_domain_lock);
+       /*
+        * Check here if the device is already attached to domain or

not.

Quoted 27 lines
drivers/iommu/fsl_pamu_domain.c new file +27 -0
+        * If the device is already attached to a domain detach it.
+        */
+       old_domain_info = find_domain(dev);
+       if (old_domain_info && old_domain_info->domain != dma_domain) {
+               spin_unlock(&device_domain_lock);
+               detach_domain(dev, old_domain_info->domain);
+               spin_lock(&device_domain_lock);
+       }
+
+       info = kmem_cache_zalloc(iommu_devinfo_cache, GFP_KERNEL);
+
+       info->dev = dev;
+       info->liodn = liodn;
+       info->domain = dma_domain;
+
+       list_add(&info->link, &dma_domain->devices);
+       /*
+        * In case of devices with multiple LIODNs just store
+        * the info for the first LIODN as all
+        * LIODNs share the same domain
+        */
+       if (!old_domain_info)
+               dev->archdata.iommu_domain = info;
+       spin_unlock(&device_domain_lock);
+
+}
+

[cut]

drivers/iommu/fsl_pamu_domain.c line 243

Quoted 4 lines
drivers/iommu/fsl_pamu_domain.c new file +4 -0
+/* Configure geometry settings for all LIODNs associated with domain
+*/ static int configure_domain(struct fsl_dma_domain *dma_domain,
+                           struct iommu_domain_geometry *geom_attr,
+                           u32 win_cnt)

This function is not configuring the iommu domain...which is a concept in the Linux driver, it is taking the domain geometry and setting up the PAMU tables for all LIODNs currently in the domain.

Quoted 5 lines

Maybe it would help if you used a prefix like "pamu" or "paact" to identify functions that operate on the actual PAMU tables.

maybe: pamu_set_domain_geometry()

[Sethi Varun-B16395] ok.

Quoted 8 lines

drivers/iommu/fsl_pamu_domain.c

Quoted 7 lines
drivers/iommu/fsl_pamu_domain.c new file +7 -0
+{
+       struct device_domain_info *info;
+       int ret = 0;
+
+       if (!list_empty(&dma_domain->devices)) {
+               list_for_each_entry(info, &dma_domain->devices, link) {
+                       ret = configure_liodn(info->liodn, info->dev,

dma_domain,

Quoted 4 lines
Quoted 1 line

+ geom_attr, win_cnt);

...and following the above naming convention, call this (?):
pamu_set_liodn

[Sethi Varun-B16395] ok.

Quoted 45 lines
Quoted 9 lines
drivers/iommu/fsl_pamu_domain.c new file +8 -0
+                       if (ret)
+                               break;
+               }
+       }
+
+       return ret;
+}
+

[cut]

Quoted 1 line

+static int fsl_pamu_window_enable(struct iommu_domain *domain, u32

wnd_nr,

Quoted 8 lines
drivers/iommu/fsl_pamu_domain.c new file +8 -0
+                                 phys_addr_t paddr, u64 size, int
+iommu_prot) {
+       struct fsl_dma_domain *dma_domain = domain->priv;
+       struct dma_window *wnd;
+       int prot = 0;
+       int ret;
+       unsigned long flags;
+       u64 win_size;

drivers/iommu/fsl_pamu_domain.c

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+
+       if (iommu_prot & IOMMU_READ)
+               prot |= PAACE_AP_PERMS_QUERY;
+       if (iommu_prot & IOMMU_WRITE)
+               prot |= PAACE_AP_PERMS_UPDATE;
+
+       spin_lock_irqsave(&dma_domain->domain_lock, flags);
+       if (!dma_domain->win_arr) {
+               pr_err("Number of windows not configured\n");
+               spin_unlock_irqrestore(&dma_domain->domain_lock,

flags);

drivers/iommu/fsl_pamu_domain.c

Quoted 6 lines
drivers/iommu/fsl_pamu_domain.c new file +6 -0
+               return -ENODEV;
+       }
+
+       if (wnd_nr >= dma_domain->win_cnt) {
+               pr_err("Invalid window index\n");
+               spin_unlock_irqrestore(&dma_domain->domain_lock,

flags);

drivers/iommu/fsl_pamu.c

Quoted 5 lines
drivers/iommu/fsl_pamu.c new file +5 -0
+               return -EINVAL;
+       }
+
+       win_size = dma_domain->geom_size >>
+ ilog2(dma_domain->win_cnt);
Quoted 4 lines

Isn't size just geom_size / win_cnt. Not sure why you do the ilog2()
and right shift...
We already validated that win_cnt is power of 2 when it was set.

[Sethi Varun-B16395] problem with u64 division.

Quoted 27 lines

drivers/iommu/fsl_pamu_domain.c

Quoted 3 lines
drivers/iommu/fsl_pamu_domain.c new file +3 -0
+       if (size > win_size) {
+               pr_err("Invalid window size \n");
+               spin_unlock_irqrestore(&dma_domain->domain_lock,

flags);

drivers/iommu/fsl_pamu_domain.c

Quoted 6 lines
drivers/iommu/fsl_pamu_domain.c new file +6 -0
+               return -EINVAL;
+       }
+
+       if (dma_domain->win_cnt == 1) {
+               if (dma_domain->enabled) {
+                       pr_err("Disable the window before updating the

mapping\n");

Review

Quoted 9 lines

+ spin_unlock_irqrestore(&dma_domain-
domain_lock, flags);

drivers/iommu/fsl_pamu_domain.c new file +4 -0
+                       return -EBUSY;
+               }
+
+               ret = check_size(size, domain-

geometry.aperture_start);

(quoted diff) +2 -0
+               if (ret) {
+                       pr_err("Aperture start not aligned to the

size\n");

drivers/iommu/fsl_pamu.c line 114

Quoted 5 lines

+ spin_unlock_irqrestore(&dma_domain-
domain_lock, flags);

drivers/iommu/fsl_pamu.c new file +3 -0
+                       return -EINVAL;
+               }
+       }
Quoted 4 lines

Why is win_cnt==1 a special case? Would the geometry not have been
verified
when it was originally set up?

[Sethi Varun-B16395] Yes, but in case of a single window you can still have the flexibility of specifying a different size range. But the start address should still be aligned to the new size.

Quoted 2 lines

Also, do you need a check here to verify if the geometry has been set. Is it a requirement to set the geometry prior to window enable?

[Sethi Varun-B16395] That is already checked with the subwindow array check.

Quoted 38 lines
Quoted 4 lines
drivers/iommu/fsl_pamu_domain.c new file +3 -0
+       wnd = &dma_domain->win_arr[wnd_nr];
+       if (!wnd->valid) {
+               wnd->paddr = paddr;

drivers/iommu/fsl_pamu_domain.c

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+               wnd->size = size;
+               wnd->prot = prot;
+
+               ret = update_domain_mapping(dma_domain, wnd_nr);
+               if (!ret) {
+                       wnd->valid = 1;
+                       dma_domain->mapped++;
+               }
+       } else {
+               pr_err("Disable the window before updating the

mapping\n");

Quoted 9 lines
drivers/iommu/fsl_pamu_domain.c new file +9 -0
+               ret = -EBUSY;
+       }
+
+       spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
+
+       return ret;
+}
+
+/*

[cut]

drivers/iommu/fsl_pamu_domain.c

Quoted 11 lines
drivers/iommu/fsl_pamu_domain.c new file +11 -0
+static int fsl_pamu_attach_device(struct iommu_domain *domain,
+                                 struct device *dev) {
+       struct fsl_dma_domain *dma_domain = domain->priv;
+       const u32 *prop;
+       u32 prop_cnt;
+       int len, ret = 0;
+       struct pci_dev *pdev = NULL;
+       struct pci_controller *pci_ctl;
+
+       /*
+        * Hack to make attach device work for the PCI devices. Simply

assign the

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+        * the LIODN for the PCI controller to the PCI device.
+        */

Instead of "Simply assign...", perhaps say instead: Use the LIODN for the PCI controller when attaching a PCI device.

[Sethi Varun-B16395] ok.

Quoted 14 lines

drivers/iommu/fsl_pamu_domain.c line 718

Quoted 13 lines
drivers/iommu/fsl_pamu_domain.c new file +12 -0
+       if (dev->bus == &pci_bus_type) {
+               pdev = to_pci_dev(dev);
+               pci_ctl = pci_bus_to_host(pdev->bus);
+               /*
+                * make dev point to pci controller device
+                * so we can get the LIODN programmed by
+                * u-boot;
+                */
+               dev = pci_ctl->parent;
+       }
+
+       prop = of_get_property(dev->of_node, "fsl,liodn", &len);
Quoted 2 lines

suggestion: name "prop" to be "liodn" and "prop_cnt" to be "liodn_cnt". That will be more clear.

[Sethi Varun-B16395] ok.

Quoted 45 lines
Quoted 14 lines
drivers/iommu/fsl_pamu_domain.c new file +13 -0
+       if (prop) {
+               prop_cnt = len / sizeof(u32);
+               ret = handle_attach_device(dma_domain, dev,
+                                        prop, prop_cnt);
+       } else {
+               pr_err("missing fsl,liodn property at %s\n",
+                         dev->of_node->full_name);
+                       ret = -EINVAL;
+       }
+
+       return ret;
+}
+

drivers/iommu/fsl_pamu_domain.c

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+static void fsl_pamu_detach_device(struct iommu_domain *domain,
+                                     struct device *dev) {
+       struct fsl_dma_domain *dma_domain = domain->priv;
+       const u32 *prop;
+       int len;
+       struct pci_dev *pdev = NULL;
+       struct pci_controller *pci_ctl;
+
+       /*
+        * Hack to make detach device work for the PCI devices. Simply

assign the

Quoted 9 lines
drivers/iommu/fsl_pamu_domain.c new file +9 -0
+        * the LIODN for the PCI controller to the PCI device.
+        */
+       if (dev->bus == &pci_bus_type) {
+               pdev = to_pci_dev(dev);
+               pci_ctl = pci_bus_to_host(pdev->bus);
+               /*
+                * make dev point to pci controller device
+                * so we can get the LIODN programmed by
+                * u-boot;

drivers/iommu/fsl_pamu_domain.c

Quoted 10 lines
drivers/iommu/fsl_pamu_domain.c new file +10 -0
+                */
+               dev = pci_ctl->parent;
+       }
+
+       prop = of_get_property(dev->of_node, "fsl,liodn", &len);
+       if (prop)
+               detach_domain(dev, dma_domain);
+       else
+               pr_err("missing fsl,liodn property at %s\n",
+                         dev->of_node->full_name); }
Quoted 2 lines

I understand why you need the LIODN when attaching, but why do you get it
in the detatch function. You are not using "prop" here.

[Sethi Varun-B16395] Just a sanity check.

Quoted 12 lines

[cut]

drivers/iommu/fsl_pamu_domain.c

Quoted 5 lines
drivers/iommu/fsl_pamu_domain.c new file +5 -0
+static  bool check_pci_ctl_endpt_part(struct pci_controller *pci_ctl)
+{
+       u32 version;
+
+       /* Check the PCI controller version number by readding BRR1

register */

drivers/iommu/fsl_pamu_domain.c

Quoted 3 lines
drivers/iommu/fsl_pamu_domain.c new file +3 -0
+       version = in_be32(pci_ctl->cfg_addr + (PCI_FSL_BRR1 >> 2));
+       version &= PCI_FSL_BRR1_VER;
+       /* If PCI controller version is >= 0x204 we can partition

endpoints*/

Quoted 12 lines

drivers/iommu/fsl_pamu_domain.c line 939

Quoted 5 lines
drivers/iommu/fsl_pamu_domain.c new file +5 -0
+       if (version >= 0x204)
+               return 1;
+
+       return 0;
+}

Can we just use the compatible string here to identify the different kinds of PCI
controllers? Reading the actual device registers is ugly right now
because
you are #defining the BRR1 stuff in a generic powerpc header.

[Sethi Varun-B16395] hmmm......, I would have to check for various different compatible strings in that case. May be I can move the defines to a different file. What if I move them to some other header?

Quoted 8 lines
Quoted 8 lines
drivers/iommu/fsl_pamu_domain.c new file +8 -0
+static int fsl_pamu_add_device(struct device *dev) {
+       struct iommu_group *group = NULL;
+       struct pci_dev *pdev;
+       struct pci_dev *bridge, *dma_pdev = NULL;
+       struct pci_controller *pci_ctl;
+       int ret;
+
+       /*
Quoted 8 lines

drivers/iommu/fsl_pamu_domain.c line 954

Quoted 5 lines
drivers/iommu/fsl_pamu_domain.c new file +5 -0
+        * For platform devices we allocate a separate group for
+        * each of the devices.
+        */
+       if (dev->bus == &pci_bus_type) {
+               bool pci_endpt_part;

That variable name is not clear, the abbreviations are not natural. I would just call it pci_endpoint_partitioning.

[Sethi Varun-B16395] ok.

-Varun

#34 lore raw
Quoted 72 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Monday, March 04, 2013 5:31 AM
To: Stuart Yoder
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Joerg Roedel; Yoder Stuart-B08248
Subject: RE: [PATCH 6/6 v8] iommu/fsl: Freescale PAMU driver and IOMMU API implementation.

Quoted 25 lines

-----Original Message-----
From: Stuart Yoder [mailto:[email protected]]
Sent: Saturday, March 02, 2013 4:58 AM
To: Sethi Varun-B16395
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; Joerg Roedel; Yoder Stuart-B08248
Subject: Re: [PATCH 6/6 v8] iommu/fsl: Freescale PAMU driver and IOMMU
API implementation.

On Mon, Feb 18, 2013 at 6:52 AM, Varun Sethi <[email protected]> wrote:
[cut]

drivers/iommu/fsl_pamu_domain.c

Quoted 11 lines
drivers/iommu/fsl_pamu_domain.c new file +11 -0
+static phys_addr_t get_phys_addr(struct fsl_dma_domain *dma_domain,
+unsigned long iova) {
+       u32 win_cnt = dma_domain->win_cnt;
+       struct dma_window *win_ptr =
+                               &dma_domain->win_arr[0];
+       struct iommu_domain_geometry *geom;
+
+       geom = &dma_domain->iommu_domain->geometry;
+
+       if (!win_cnt || !dma_domain->geom_size) {
+               pr_err("Number of windows/geometry not configured for

the domain\n");

Quoted 11 lines

drivers/iommu/fsl_pamu_domain.c line 98

Quoted 9 lines
drivers/iommu/fsl_pamu_domain.c new file +9 -0
+               return 0;
+       }
+
+       if (win_cnt > 1) {
+               u64 subwin_size;
+               unsigned long subwin_iova;
+               u32 wnd;
+
+               subwin_size = dma_domain->geom_size >> ilog2(win_cnt);

Could it be just geom_size / win_cnt ??

[Sethi Varun-B16395] You would run in to linking issues with respect to u64 division on 32 bit kernels.

Quoted 4 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+               subwin_iova = iova & ~(subwin_size - 1);
+               wnd = (subwin_iova - geom->aperture_start) >>

ilog2(subwin_size);

Quoted 16 lines

drivers/iommu/fsl_pamu_domain.c

Quoted 12 lines
drivers/iommu/fsl_pamu_domain.c new file +12 -0
+               win_ptr = &dma_domain->win_arr[wnd];
+       }
+
+       if (win_ptr->valid)
+               return (win_ptr->paddr + (iova & (win_ptr->size -
+ 1)));
+
+       return 0;
+}
+
+static int map_liodn_subwins(int liodn, struct fsl_dma_domain
+*dma_domain)

Just call it map_subwins(). They are just sub windows, not "liodn sub windows".

[Sethi Varun-B16395] This would be called per liodn.

Quoted 7 lines
Quoted 6 lines

[cut]

Review

Quoted 2 lines
(quoted diff) +2 -0
+static int map_liodn_win(int liodn, struct fsl_dma_domain
+*dma_domain)

Call it map_win().

[Sethi Varun-B16395] This would again be called per liodn.

On the function names-- function names are typically named with a noun describing some object and a verb describing the action...and sometimes a subsystem identifier:
kmem_cache + zalloc
spin + lock

I don't think inserting liodn in the function name to indicates that it operates per liodn makes it more clear and reads a little awkward to me:

map + liodn_win

...it's almost like there is a "liodn_win" object.

I think plain map_win() is more clear and the function prototype makes it pretty clear that you are operating on an liodn.

Quoted 23 lines
Quoted 11 lines

[cut]

drivers/iommu/fsl_pamu_domain.c

Quoted 5 lines
drivers/iommu/fsl_pamu_domain.c new file +5 -0
+static  bool check_pci_ctl_endpt_part(struct pci_controller *pci_ctl)
+{
+       u32 version;
+
+       /* Check the PCI controller version number by readding BRR1

register */

drivers/iommu/fsl_pamu_domain.c

Quoted 3 lines
drivers/iommu/fsl_pamu_domain.c new file +3 -0
+       version = in_be32(pci_ctl->cfg_addr + (PCI_FSL_BRR1 >> 2));
+       version &= PCI_FSL_BRR1_VER;
+       /* If PCI controller version is >= 0x204 we can partition

endpoints*/

Quoted 12 lines

drivers/iommu/fsl_pamu_domain.c line 939

Quoted 5 lines
drivers/iommu/fsl_pamu_domain.c new file +5 -0
+       if (version >= 0x204)
+               return 1;
+
+       return 0;
+}

Can we just use the compatible string here to identify the different kinds of PCI
controllers? Reading the actual device registers is ugly right now
because
you are #defining the BRR1 stuff in a generic powerpc header.

Quoted 2 lines

[Sethi Varun-B16395] hmmm......, I would have to check for various different compatible strings in that case. May be I can move the defines to a different file. What if I move them to some other header?

Don't personally feel too strongly about version register or header...but it should be some fsl PCI header that you define those regs.

You'll either need to check for a hardware version number or a compatible, so a compatible check may be just as easy...look for "fsl,qoriq-pcie-v2.4"?

Stuart

#35 lore raw
In reply to Varun Sethi

Hi Joerg,
Do you have any comments on the patch set.

Regards
Varun

Quoted 60 lines

-----Original Message-----
From: Sethi Varun-B16395
Sent: Monday, February 18, 2013 6:22 PM
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; Wood Scott-B07421; [email protected]; Yoder Stuart-B08248
Cc: Sethi Varun-B16395
Subject: [PATCH 0/6 v8] 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. Store PCI controller platform device information in the PCI controller structure.
3. Add defines for FSL PCI controller BRR1 register.
4. Add window permission flags in the iommu_domain_window_enable API.
5. Add domain attributes for FSL PAMU driver.
6. 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 (6):
Store iommu domain information in the device structure. Store the platform device information corresponding to the pci
controller.
Added defines for the FSL PCI controller BRR1 register. Add window permission flags for iommu_domain_window_enable API. Add addtional attributes specific to the PAMU driver. FSL PAMU driver and IOMMU API implementation.

 arch/powerpc/include/asm/device.h     |    4 +
 arch/powerpc/include/asm/pci-bridge.h |    4 +
 arch/powerpc/sysdev/fsl_pci.c         |    9 +-
 arch/powerpc/sysdev/fsl_pci.h         |    2 +-
 drivers/iommu/Kconfig                 |    8 +
 drivers/iommu/Makefile                |    1 +
 drivers/iommu/fsl_pamu.c              | 1260
+++++++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu.h              |  398 +++++++++++
 drivers/iommu/fsl_pamu_domain.c       | 1135
+++++++++++++++++++++++++++++
 drivers/iommu/fsl_pamu_domain.h       |   89 +++
 drivers/iommu/iommu.c                 |    5 +-
 include/linux/iommu.h                 |   40 +-
 12 files changed, 2947 insertions(+), 8 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