iommu/fsl: Freescale PAMU driver and IOMMU API implementation.
Subsystems (8)
v10 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. Make iova u64 in the iommu_iova_to_phys API.
2. Addition of new field in the device (powerpc) archdata structure for storing iommu domain information pointer.
3. Add window permission flags in the iommu_domain_window_enable API.
4. Add domain attributes for FSL PAMU driver.
5. PAMU driver and IOMMU API implementation.
This patch set is based on the master branch (3.9-rc2) of Linus Torvald's git tree.
Varun Sethi (5):
Make iova u64 in the iommu_iova_to_phys API.
Add iommu domain pointer to device archdata
Add the window permission flag as a parameter to iommu_window_enable API.
Add addition iommu attributes required by the PAMU driver. FSL PAMU driver.
arch/powerpc/include/asm/device.h | 6 + arch/powerpc/sysdev/fsl_pci.h | 5 + drivers/iommu/Kconfig | 8 + drivers/iommu/Makefile | 1 + drivers/iommu/amd_iommu.c | 2 +- drivers/iommu/exynos-iommu.c | 2 +- drivers/iommu/fsl_pamu.c | 1250 +++++++++++++++++++++++++++++++++++++ drivers/iommu/fsl_pamu.h | 405 ++++++++++++ drivers/iommu/fsl_pamu_domain.c | 1134 +++++++++++++++++++++++++++++++++ drivers/iommu/fsl_pamu_domain.h | 85 +++ drivers/iommu/intel-iommu.c | 2 +- drivers/iommu/iommu.c | 8 +- drivers/iommu/msm_iommu.c | 2 +- drivers/iommu/omap-iommu.c | 2 +- drivers/iommu/shmobile-iommu.c | 2 +- drivers/iommu/tegra-gart.c | 2 +- drivers/iommu/tegra-smmu.c | 2 +- include/linux/iommu.h | 51 ++- 18 files changed, 2948 insertions(+), 21 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
PATCH v10 1/5 iommu/fsl: Make iova u64 in the iommu_iova_to_phys API.
This is required in case of PAMU, as it can support a window size of up to 64G (even on 32bit).
---
- no change in v10.
drivers/iommu/amd_iommu.c | 2 +- drivers/iommu/exynos-iommu.c | 2 +- drivers/iommu/intel-iommu.c | 2 +- drivers/iommu/iommu.c | 3 +-- drivers/iommu/msm_iommu.c | 2 +- drivers/iommu/omap-iommu.c | 2 +- drivers/iommu/shmobile-iommu.c | 2 +- drivers/iommu/tegra-gart.c | 2 +- drivers/iommu/tegra-smmu.c | 2 +- include/linux/iommu.h | 9 +++------ 10 files changed, 12 insertions(+), 16 deletions(-)
drivers/iommu/amd_iommu.c +1 -1
@@ -3412,7 +3412,7 @@ static size_t amd_iommu_unmap(struct iommu_domain *dom, unsigned long iova, }static phys_addr_t amd_iommu_iova_to_phys (struct iommu_domain *dom, -unsigned long iova) +u64 iova) {struct protection_domain *domain = dom->priv;unsigned long offset_mask;
drivers/iommu/exynos-iommu.c +1 -1
@@ -1027,7 +1027,7 @@ done: }static phys_addr_t exynos_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct exynos_iommu_domain *priv = domain->priv;unsigned long *entry;
drivers/iommu/intel-iommu.c +1 -1
@@ -4111,7 +4111,7 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain, }static phys_addr_t intel_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct dmar_domain *dmar_domain = domain->priv;struct dma_pte *pte;
drivers/iommu/iommu.c +1 -2
@@ -706,8 +706,7 @@ void iommu_detach_group(struct iommu_domain *domain, struct iommu_group *group) }EXPORT_SYMBOL_GPL (iommu_detach_group); -phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain,u64 iova) {if (unlikely (domain->ops->iova_to_phys ==NULL ))return 0 ;
drivers/iommu/msm_iommu.c +1 -1
@@ -554,7 +554,7 @@ fail: }static phys_addr_t msm_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long va) +u64 va) {struct msm_priv *priv;struct msm_iommu_drvdata *iommu_drvdata;
drivers/iommu/omap-iommu.c +1 -1
@@ -1219,7 +1219,7 @@ static void omap_iommu_domain_destroy(struct iommu_domain *domain) }static phys_addr_t omap_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long da) +u64 da) {struct omap_iommu_domain *omap_domain = domain->priv;struct omap_iommu *oiommu = omap_domain->iommu_dev;
drivers/iommu/shmobile-iommu.c +1 -1
@@ -296,7 +296,7 @@ done: }static phys_addr_t shmobile_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct shmobile_iommu_domain *sh_domain = domain->priv;uint32_t l1entry =0 , l2entry =0 ;
drivers/iommu/tegra-gart.c +1 -1
@@ -279,7 +279,7 @@ static size_t gart_iommu_unmap(struct iommu_domain *domain, unsigned long iova, }static phys_addr_t gart_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct gart_device *gart = domain->priv;unsigned long pte;
drivers/iommu/tegra-smmu.c +1 -1
@@ -757,7 +757,7 @@ static size_t smmu_iommu_unmap(struct iommu_domain *domain, unsigned long iova, }static phys_addr_t smmu_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct smmu_as *as = domain->priv;unsigned long *pte;
include/linux/iommu.h +3 -6
@@ -91,8 +91,7 @@ struct iommu_ops { phys_addr_t paddr, size_t size, int prot);size_t (*unmap)(struct iommu_domain *domain,unsigned long iova,size_t size); -phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, -unsigned long iova); +phys_addr_t (*iova_to_phys)(struct iommu_domain *domain,u64 iova);int (*domain_has_cap)(struct iommu_domain *domain,unsigned long cap);int (*add_device)(struct device *dev);
@@ -134,8 +133,7 @@ extern int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot);extern size_t iommu_unmap (struct iommu_domain *domain,unsigned long iova,size_t size); -extern phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova); +extern phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain,u64 iova);extern int iommu_domain_has_cap (struct iommu_domain *domain,unsigned long cap); extern void iommu_set_fault_handler(struct iommu_domain *domain,
@@ -267,8 +265,7 @@ static inline void iommu_domain_window_disable(struct iommu_domain *domain, { } -static inline phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +static inline phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain,u64 iova) {return 0 ; }
Signature · 1 line
1.7.4.1
A message that is not in the archive (sent off-list or not yet received): 1363991700-21454-3-git-send-email-Varun.Sethi-KZfg59tc24xl57MIdRCFDg@public.gmane.org
Re: [PATCH 1/5 v10] iommu/fsl: Make iova u64 in the iommu_iova_to_phys API.
I agree that unsigned long was an improper choice for iova's, but why aren't they dma_addr_t ? ... an iova is a dma-addr, just a 'virtual' one wrt phys-addr.
Quoted 171 lines · Varun Sethi
This is required in case of PAMU, as it can support a window size of up to 64G (even on 32bit).
Signed-off-by Varun Sethi<[email protected]>---
- no change in v10.drivers/iommu/amd_iommu.c | 2 +- drivers/iommu/exynos-iommu.c | 2 +- drivers/iommu/intel-iommu.c | 2 +- drivers/iommu/iommu.c | 3 +-- drivers/iommu/msm_iommu.c | 2 +- drivers/iommu/omap-iommu.c | 2 +- drivers/iommu/shmobile-iommu.c | 2 +- drivers/iommu/tegra-gart.c | 2 +- drivers/iommu/tegra-smmu.c | 2 +- include/linux/iommu.h | 9 +++------ 10 files changed, 12 insertions(+), 16 deletions(-)drivers/iommu/amd_iommu.c +1
-1@@ -3412,7 +3412,7 @@ static size_t amd_iommu_unmap(struct iommu_domain *dom, unsigned long iova, }static phys_addr_t amd_iommu_iova_to_phys (struct iommu_domain *dom, -unsigned long iova) +u64 iova) {struct protection_domain *domain = dom->priv;unsigned long offset_mask;drivers/iommu/exynos-iommu.c +1
-1@@ -1027,7 +1027,7 @@ done: }static phys_addr_t exynos_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct exynos_iommu_domain *priv = domain->priv;unsigned long *entry;drivers/iommu/intel-iommu.c +1
-1@@ -4111,7 +4111,7 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain, }static phys_addr_t intel_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct dmar_domain *dmar_domain = domain->priv;struct dma_pte *pte;drivers/iommu/iommu.c +1
-2@@ -706,8 +706,7 @@ void iommu_detach_group(struct iommu_domain *domain, struct iommu_group *group) }EXPORT_SYMBOL_GPL (iommu_detach_group); -phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain,u64 iova) {if (unlikely (domain->ops->iova_to_phys ==NULL ))return 0 ;drivers/iommu/msm_iommu.c +1
-1@@ -554,7 +554,7 @@ fail: }static phys_addr_t msm_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long va) +u64 va) {struct msm_priv *priv;struct msm_iommu_drvdata *iommu_drvdata;drivers/iommu/omap-iommu.c +1
-1@@ -1219,7 +1219,7 @@ static void omap_iommu_domain_destroy(struct iommu_domain *domain) }static phys_addr_t omap_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long da) +u64 da) {struct omap_iommu_domain *omap_domain = domain->priv;struct omap_iommu *oiommu = omap_domain->iommu_dev;drivers/iommu/shmobile-iommu.c +1
-1@@ -296,7 +296,7 @@ done: }static phys_addr_t shmobile_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct shmobile_iommu_domain *sh_domain = domain->priv;uint32_t l1entry =0 , l2entry =0 ;drivers/iommu/tegra-gart.c +1
-1@@ -279,7 +279,7 @@ static size_t gart_iommu_unmap(struct iommu_domain *domain, unsigned long iova, }static phys_addr_t gart_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct gart_device *gart = domain->priv;unsigned long pte;drivers/iommu/tegra-smmu.c +1
-1@@ -757,7 +757,7 @@ static size_t smmu_iommu_unmap(struct iommu_domain *domain, unsigned long iova, }static phys_addr_t smmu_iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +u64 iova) {struct smmu_as *as = domain->priv;unsigned long *pte;include/linux/iommu.h +3
-6@@ -91,8 +91,7 @@ struct iommu_ops { phys_addr_t paddr, size_t size, int prot);size_t (*unmap)(struct iommu_domain *domain,unsigned long iova,size_t size); -phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, -unsigned long iova); +phys_addr_t (*iova_to_phys)(struct iommu_domain *domain,u64 iova);int (*domain_has_cap)(struct iommu_domain *domain,unsigned long cap);int (*add_device)(struct device *dev);@@ -134,8 +133,7 @@ extern int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot);extern size_t iommu_unmap (struct iommu_domain *domain,unsigned long iova,size_t size); -extern phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova); +extern phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain,u64 iova);extern int iommu_domain_has_cap (struct iommu_domain *domain,unsigned long cap); extern void iommu_set_fault_handler(struct iommu_domain *domain,@@ -267,8 +265,7 @@ static inline void iommu_domain_window_disable(struct iommu_domain *domain, { } -static inline phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +static inline phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain,u64 iova) {return 0 ; }
A message that is not in the archive (sent off-list or not yet received): [email protected]
RE: [PATCH 1/5 v10] iommu/fsl: Make iova u64 in the iommu_iova_to_phys API.
Because of the PAMU supported window sizes the iova can be > 32bit value even on 32 bit architectures. I see that we have the "CONFIG_ARCH_DMA_ADDR_T_64BIT" config option enabled in our case, so dma_addr_t would be u64 in our case.
-Varun
Quoted 203 lines
-----Original Message-----
From: Don Dutile [mailto:[email protected]]
Sent: Monday, March 25, 2013 8:38 PM
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: Sethi Varun-B16395
Subject: Re: [PATCH 1/5 v10] iommu/fsl: Make iova u64 in theiommu_iova_to_physAPI.I agree that unsigned long was an improper choice for iova's, but why aren't they
dma_addr_t? ... an iova is a dma-addr, just a 'virtual' one wrt phys-addr.drivers/iommu/amd_iommu.c static size_t amd_iommu_unmap(struct iommu_domain
Quoted 24 lines · Varun Sethi
This is required in case of PAMU, as it can support a window size of up to 64G (even on 32bit).
Signed-off-by Varun Sethi<[email protected]>---
- no change in v10.drivers/iommu/amd_iommu.c | 2 +- drivers/iommu/exynos-iommu.c | 2 +- drivers/iommu/intel-iommu.c | 2 +- drivers/iommu/iommu.c | 3 +-- drivers/iommu/msm_iommu.c | 2 +- drivers/iommu/omap-iommu.c | 2 +- drivers/iommu/shmobile-iommu.c | 2 +- drivers/iommu/tegra-gart.c | 2 +- drivers/iommu/tegra-smmu.c | 2 +- include/linux/iommu.h | 9 +++------ 10 files changed, 12 insertions(+), 16 deletions(-)drivers/iommu/amd_iommu.c +0
-0@@ -3412,7 +3412,7 @@ static size_t amd_iommu_unmap(struct iommu_domain*dom, unsigned long iova,
Quoted 13 lines
drivers/iommu/amd_iommu.c +1
-1}static phys_addr_t amd_iommu_iova_to_phys (struct iommu_domain *dom, -unsigned long iova) +u64 iova) {struct protection_domain *domain = dom->priv;unsigned long offset_mask;(quoted diff) +0
-0
b/drivers/iommu/exynos-iommu.cindex 238a3ca..541e81b 100644drivers/iommu/exynos-iommu.c done: · line 1029
Quoted 3 lines
drivers/iommu/exynos-iommu.c +0
-0@@ -1027,7 +1027,7 @@ done: } static phys_addr_t exynos_iommu_iova_to_phys(struct iommu_domain*domain,
drivers/iommu/intel-iommu.c static size_t intel_iommu_unmap(struct
Quoted 10 lines
drivers/iommu/exynos-iommu.c +1
-1- unsigned long iova) + u64 iova) {struct exynos_iommu_domain *priv = domain->priv;unsigned long *entry;drivers/iommu/intel-iommu.c +0
-0@@ -4111,7 +4111,7 @@ static size_t intel_iommu_unmap(struct
iommu_domain*domain,drivers/iommu/intel-iommu.c static size_t intel_iommu_unmap(struct · line 4113
Quoted 3 lines
drivers/iommu/intel-iommu.c +0
-0} static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain*domain,
drivers/iommu/iommu.c void iommu_detach_group(struct iommu_domain
Quoted 10 lines
drivers/iommu/intel-iommu.c +1
-1- unsigned long iova) + u64 iova) {struct dmar_domain *dmar_domain = domain->priv;struct dma_pte *pte;drivers/iommu/iommu.c index renamed from drivers/iommu/iommu.c +0
-0b972d43..39106ec 100644
drivers/iommu/iommu.c +0
-0@@ -706,8 +706,7 @@ void iommu_detach_group(struct iommu_domain*domain, struct
iommu_group*group)Quoted 14 lines
drivers/iommu/iommu.c +1
-2}EXPORT_SYMBOL_GPL (iommu_detach_group); -phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova) +phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain,u64 iova) {if (unlikely (domain->ops->iova_to_phys ==NULL ))return 0 ;drivers/iommu/msm_iommu.c +0
-0drivers/iommu/msm_iommu.c fail: · line 556
Quoted 3 lines
drivers/iommu/msm_iommu.c +0
-0@@ -554,7 +554,7 @@ fail: } static phys_addr_t msm_iommu_iova_to_phys(struct iommu_domain*domain,
drivers/iommu/omap-iommu.c static void omap_iommu_domain_destroy(struct
Quoted 10 lines
drivers/iommu/msm_iommu.c +1
-1- unsigned long va) + u64 va) {struct msm_priv *priv; struct msm_iommu_drvdata *iommu_drvdata; diff --git
a/drivers/iommu/omap-iommu.cb/drivers/iommu/omap-iommu.cindex 6ac02fa..102ae56 100644drivers/iommu/omap-iommu.c +0
-0@@ -1219,7 +1219,7 @@ static void omap_iommu_domain_destroy(struct
iommu_domain*domain)drivers/iommu/omap-iommu.c static void omap_iommu_domain_destroy(struct · line 1221
Quoted 3 lines
drivers/iommu/omap-iommu.c +0
-0} static phys_addr_t omap_iommu_iova_to_phys(struct iommu_domain*domain,
drivers/iommu/shmobile-iommu.c done: · line 298
Quoted 13 lines
drivers/iommu/omap-iommu.c +1
-1- unsigned long da) + u64 da) {struct omap_iommu_domain *omap_domain = domain->priv; struct omap_iommu *oiommu = omap_domain->iommu_dev; diff --git
a/drivers/iommu/shmobile-iommu.cb/drivers/iommu/shmobile-iommu.cindex b6e8b57..9216802 100644drivers/iommu/shmobile-iommu.c +0
-0@@ -296,7 +296,7 @@ done: } static phys_addr_t shmobile_iommu_iova_to_phys(struct iommu_domain*domain,
drivers/iommu/tegra-gart.c static size_t gart_iommu_unmap(struct iommu_domain
Quoted 10 lines
drivers/iommu/shmobile-iommu.c +1
-1- unsigned long iova) + u64 iova) {struct shmobile_iommu_domain *sh_domain = domain->priv;uint32_t l1entry =0 , l2entry =0 ;drivers/iommu/tegra-gart.c +0
-0@@ -279,7 +279,7 @@ static size_t gart_iommu_unmap(struct iommu_domain*domain, unsigned long iova,
drivers/iommu/tegra-gart.c static size_t gart_iommu_unmap(struct iommu_domain · line 281
Quoted 3 lines
drivers/iommu/tegra-gart.c +0
-0} static phys_addr_t gart_iommu_iova_to_phys(struct iommu_domain*domain,
drivers/iommu/tegra-smmu.c static size_t smmu_iommu_unmap(struct iommu_domain
Quoted 10 lines
drivers/iommu/tegra-gart.c +1
-1- unsigned long iova) + u64 iova) {struct gart_device *gart = domain->priv;unsigned long pte;drivers/iommu/tegra-smmu.c +0
-0@@ -757,7 +757,7 @@ static size_t smmu_iommu_unmap(struct iommu_domain*domain, unsigned long iova,
drivers/iommu/tegra-smmu.c static size_t smmu_iommu_unmap(struct iommu_domain · line 759
Quoted 3 lines
drivers/iommu/tegra-smmu.c +0
-0} static phys_addr_t smmu_iommu_iova_to_phys(struct iommu_domain*domain,
Quoted 19 lines
drivers/iommu/tegra-smmu.c +1
-1- unsigned long iova) + u64 iova) {struct smmu_as *as = domain->priv;unsigned long *pte;include/linux/iommu.h index renamed from include/linux/iommu.h +0
-0ba3b8a9..576cc19 100644
include/linux/iommu.h +1
-2@@ -91,8 +91,7 @@ struct iommu_ops { phys_addr_t paddr, size_t size, int prot);size_t (*unmap)(struct iommu_domain *domain,unsigned long iova,size_t size); -phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, -unsigned long iova); +phys_addr_t (*iova_to_phys)(struct iommu_domain *domain,u64 iova);int (*domain_has_cap)(struct iommu_domain *domain,unsigned long cap); int (*add_device)(struct device *dev); @@ -134,8 +133,7 @@ externQuoted 3 lines
int iommu_map(struct
iommu_domain*domain, unsigned long iova,
phys_addr_tpaddr,size_tsize, int prot);
externsize_tiommu_unmap(structiommu_domain*domain, unsigned longiova,
include/linux/iommu.h extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
Quoted 9 lines
size_tsize);include/linux/iommu.h +2
-3-extern phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, -unsigned long iova); +extern phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, +u64 iova);extern int iommu_domain_has_cap (struct iommu_domain *domain,unsigned long cap); extern void iommu_set_fault_handler(struct iommu_domain *domain, @@ -267,8 +265,7 @@ static inline void iommu_domain_window_disable(struct
iommu_domain*domain,Quoted 4 lines
{ }-static inline
phys_addr_tiommu_iova_to_phys(structiommu_domain*domain,
Quoted 6 lines
include/linux/iommu.h +2
-1- unsigned long iova) +static inline phys_addr_t iommu_iova_to_phys (struct iommu_domain +*domain,u64 iova) {return 0 ; }
PATCH v10 2/5 powerpc: Add iommu domain pointer to device archdata
In reply to Varun SethiAdd an iommu domain pointer to device (powerpc) archdata. Devices are attached to iommu domains and this pointer provides a mechanism to correlate between a device and the associated iommu domain. This field is set when a device is attached to a domain.
---
- no change in v10.
- Added CONFIG_IOMMU_API in v9.
arch/powerpc/include/asm/device.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/device.h +6 -0
@@ -28,6 +28,12 @@ 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. +*/ +#ifdef CONFIG_IOMMU_API +void *iommu_domain; +#endif #ifdef CONFIG_SWIOTLB dma_addr_t max_direct_dma_addr;#endif
Signature · 1 line
1.7.4.1
PATCH v10 3/5 iommu/fsl: Add the window permission flag as a parameter to iommu_window_enable API.
In reply to Varun SethiEach iommu window can have access permissions associated with it. Extended the window_enable API to incorporate window access permissions.
In case of PAMU each window can have its specific set of permissions.
---
- no change in v10.
drivers/iommu/iommu.c | 5 +++-- include/linux/iommu.h | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/iommu/iommu.c +3 -2
@@ -853,12 +853,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 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, + prot); }EXPORT_SYMBOL_GPL (iommu_domain_window_enable);
include/linux/iommu.h +4 -3
@@ -104,7 +104,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 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);
@@ -169,7 +169,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 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
@@ -255,7 +256,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 prot) {return -ENODEV ; }
Signature · 1 line
1.7.4.1
PATCH v10 4/5 iommu/fsl: Add additional iommu attributes required by the PAMU driver.
In reply to Varun SethiAdded 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.
---
- no change in v10.
include/linux/iommu.h | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-)
include/linux/iommu.h +35 -0
@@ -40,6 +40,25 @@ struct notifier_block;typedef int (*iommu_fault_handler_t )(struct iommu_domain *,struct device *,unsigned long ,int ,void *); +/* cache stash targets */ +enum stash_target { +IOMMU_ATTR_CACHE_L1 =1 , +IOMMU_ATTR_CACHE_L2 , +IOMMU_ATTR_CACHE_L3 , +}; + +/* 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 +76,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
PATCH v10 5/5 iommu/fsl: Freescale PAMU driver and iommu implementation.
In reply to Varun SethiFollowing 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.
---
changes in v10:
- Support for new guts compatibe string for T4 & B4 devices.
- Modified comment about port ID and mentioned the errata number.
- Fixed the issue where data pointer was not freed in case of a an error.
- Pass data pointer while freeing irq.
- Whle initializing the SPAACE entry clear the valid bit. changes in v9:
- Merged and createad a single function to delete
a device from domain list.
- Refactored the add_device API code.
- Renamed the paace and spaace init fucntions.
- Renamed functions for mapping windows and subwindows.
- Changed the MAX LIODN value to MAX value u-boot can program.
- Hard coded maximum number of subwindows.
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
arch/powerpc/sysdev/fsl_pci.h | 5 + drivers/iommu/Kconfig | 8 + drivers/iommu/Makefile | 1 + drivers/iommu/fsl_pamu.c | 1269 +++++++++++++++++++++++++++++++++++++++ drivers/iommu/fsl_pamu.h | 405 +++++++++++++ drivers/iommu/fsl_pamu_domain.c | 1137 +++++++++++++++++++++++++++++++++++ drivers/iommu/fsl_pamu_domain.h | 85 +++ 7 files changed, 2910 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
arch/powerpc/sysdev/fsl_pci.h +5 -0
@@ -14,6 +14,11 @@#ifndef __POWERPC_FSL_PCI_H#define __POWERPC_FSL_PCI_H + +/* FSL PCI controller BRR1 register */ +#define PCI_FSL_BRR1 0xbf8 +#define PCI_FSL_BRR1_VER 0xffff +#define PCIE_LTSSM 0x0404/* PCIE Link Training and Status */ #define PCIE_LTSSM_L0 0x16/* L0 state */ #define PCIE_IP_REV_2_2 0x02080202/* PCIE IP block version Rev2.2 */
drivers/iommu/Kconfig +8 -0
@@ -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
@@ -15,3 +15,4 @@ obj-$(CONFIG_TEGRA_IOMMU_SMMU) += tegra-smmu.o obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iommu.o obj-$(CONFIG_SHMOBILE_IOMMU) += shmobile-iommu.o obj-$(CONFIG_SHMOBILE_IPMMU) += shmobile-ipmmu.o +obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o
drivers/iommu/fsl_pamu.c new file +1269 -0
1,269 lines not on this page · raw message
drivers/iommu/fsl_pamu.h new file +405 -0
405 lines not on this page · raw message
drivers/iommu/fsl_pamu_domain.c new file +1137 -0
1,137 lines not on this page · raw message
drivers/iommu/fsl_pamu_domain.h new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
1.7.4.1