iommu/fsl: Add additional iommu attributes required by the PAMU driver.
PATCH v15 1/2 iommu/fsl: Add additional iommu attributes required by the PAMU driver.
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.
---
v15 changes:
- Moved fsl_pamu_stash.h under arch/powerpc/include/asm. v14 changes:
- Add FSL prefix to PAMU attributes.
v13 changes:
- created a new file include/linux/fsl_pamu_stash.h for stash attributes.
v12 changes:
- Moved PAMU specifc stash ids and structures to PAMU header file.
- no change in v11.
- no change in v10.
arch/powerpc/include/asm/fsl_pamu_stash.h | 39 +++++++++++++++++++++++++++++ include/linux/iommu.h | 16 ++++++++++++ 2 files changed, 55 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/include/asm/fsl_pamu_stash.h
arch/powerpc/include/asm/fsl_pamu_stash.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License, version 2, as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* Copyright (C) 2013 Freescale Semiconductor, Inc. +* +*/ + +#ifndef __FSL_PAMU_STASH_H +#define __FSL_PAMU_STASH_H + +/* cache stash targets */ +enum pamu_stash_target { +PAMU_ATTR_CACHE_L1 =1 , +PAMU_ATTR_CACHE_L2 , +PAMU_ATTR_CACHE_L3 , +}; + +/* +* This attribute allows configuring stashig specific parameters +* in the PAMU hardware. +*/ + +struct pamu_stash_attribute { +u32 cpu;/* cpu number */ +u32 cache;/* cache to stash to: L1,L2,L3 */ +}; + +#endif /* __FSL_PAMU_STASH_H */
include/linux/iommu.h +16 -0
@@ -57,10 +57,26 @@ struct iommu_domain {#define IOMMU_CAP_CACHE_COHERENCY 0x1#define IOMMU_CAP_INTR_REMAP 0x2/* isolates device intrs */ +/* +* Following constraints are specifc to FSL_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_FSL_PAMU_STASH , +DOMAIN_ATTR_FSL_PAMU_ENABLE , +DOMAIN_ATTR_FSL_PAMUV1 ,DOMAIN_ATTR_MAX , };
Signature · 1 line
1.7.4.1
PATCH v15 2/2 iommu/fsl: Freescale PAMU driver and iommu implementation.
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.
---
changes in v15:
- Updated path for fsl_pamu_stash.h.
changes in v14:
- Use updated PAMU specific attributes.
changes in v13:
- Use the new header drivers/iommu/pci.h
- fix geometry configured check.
changes in v12:
- Use is_power_of_2 for checking alignement.
- Check for multifucntion PCI device ACS flags for determining device groups.
- Fix get_stash_id function.
- Don't crash in case of access violations, disable the LIODN.
- Don't use list_empty while traversing list using list for each entry.
- Move stash structure and ids to PAMU header files.
- Fix geometry size calculation.
changes in v11:
- changed iova to dma_addr_t in iova_to_phys API.
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 | 10 + drivers/iommu/Makefile | 1 + drivers/iommu/fsl_pamu.c | 1309 +++++++++++++++++++++++++++++++++++++++ drivers/iommu/fsl_pamu.h | 410 ++++++++++++ drivers/iommu/fsl_pamu_domain.c | 1142 ++++++++++++++++++++++++++++++++++ drivers/iommu/fsl_pamu_domain.h | 85 +++ 7 files changed, 2962 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 +10 -0
@@ -17,6 +17,16 @@ 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. PAMU is the IOMMU present on Freescale QorIQ platforms. + PAMU can authorize memory access, remap the memory address, and remap I/O + transaction types. + # 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 +1309 -0
1,309 lines not on this page · raw message
drivers/iommu/fsl_pamu.h new file +410 -0
410 lines not on this page · raw message
drivers/iommu/fsl_pamu_domain.c new file +1142 -0
1,142 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
Hi Joerg,
Would you take this patchset for 3.10 merge?
Regards
Varun
Quoted 117 lines
-----Original Message-----
From: Sethi Varun-B16395
Sent: Wednesday, April 24, 2013 5:06 PM
To: [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc- dev-uLR06cmDAlY/[email protected]; [email protected]; [email protected]; [email protected]; Yoder Stuart-B08248; Wood Scott-B07421
Cc: Sethi Varun-B16395
Subject: [PATCH 1/2 v15] iommu/fsl: Add additional iommu attributes
required by the PAMU driver.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.Signed-off-by Varun Sethi <[email protected]>---
v15 changes:
- Movedfsl_pamu_stash.hunderarch/powerpc/include/asm.
v14 changes:
- Add FSL prefix to PAMU attributes.
v13 changes:
- created a new fileinclude/linux/fsl_pamu_stash.hfor stash attributes. v12 changes:
- Moved PAMU specifc stash ids and structures to PAMU header file.
- no change in v11.
- no change in v10.arch/powerpc/include/asm/fsl_pamu_stash.h | 39 +++++++++++++++++++++++++++++ include/linux/iommu.h | 16 ++++++++++++ 2 files changed, 55 insertions(+), 0 deletions(-) create mode 100644
arch/powerpc/include/asm/fsl_pamu_stash.harch/powerpc/include/asm/fsl_pamu_stash.h new file +13
-0@@ -0,0 +1,39 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License, version 2, as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright (C) 2013 Freescale Semiconductor, Inc.
+ *
+ */arch/powerpc/include/asm/fsl_pamu_stash.h new file +22
-0+ +#ifndef __FSL_PAMU_STASH_H +#define __FSL_PAMU_STASH_H + +/* cache stash targets */ +enum pamu_stash_target { +PAMU_ATTR_CACHE_L1 =1 , +PAMU_ATTR_CACHE_L2 , +PAMU_ATTR_CACHE_L3 , +}; + +/* +* This attribute allows configuring stashig specific parameters +* in the PAMU hardware. +*/ + +struct pamu_stash_attribute { +u32 cpu;/* cpu number */ +u32 cache;/* cache to stash to: L1,L2,L3 */ +}; + +#endif /* __FSL_PAMU_STASH_H */ include/linux/iommu.h index renamed from include/linux/iommu.h +0
-02727810..313d17a 100644
include/linux/iommu.h +17
-1@@ -57,10 +57,26 @@ struct iommu_domain {#define IOMMU_CAP_CACHE_COHERENCY 0x1#define IOMMU_CAP_INTR_REMAP 0x2/* isolates device intrs */ +/* +* Following constraints are specifc to FSL_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_FSL_PAMU_STASH , +DOMAIN_ATTR_FSL_PAMU_ENABLE , +DOMAIN_ATTR_FSL_PAMUV1 ,DOMAIN_ATTR_MAX , }; --1.7.4.1
[email protected]
maintainerQuoted 1 line · On Tue, Apr 30, 2013 at 05:09:32PM +0000, Sethi Varun-B16395 wrote:
Would you take this patchset for 3.10 merge?
Not this time. The final patch came in very late and is pretty big too. For code of that size I would like to have a few weeks more testing in next and probably also a non-Freescale Reviewed-by.
Joerg
Quoted 12 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Thursday, May 02, 2013 3:46 PM
To: Sethi Varun-B16395
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linuxppc-dev-uLR06cmDAlY/[email protected]; [email protected]; [email protected]; [email protected]; Yoder Stuart-B08248; Wood Scott-B07421
Subject: Re: [PATCH 1/2 v15] iommu/fsl: Add additional iommu attributes
required by the PAMU driver.
Quoted 6 lines
Quoted 1 line · On Tue, Apr 30, 2013 at 05:09:32PM +0000, Sethi Varun-B16395 wrote:
Would you take this patchset for 3.10 merge?
Not this time. The final patch came in very late and is pretty big too. For code of that size I would like to have a few weeks more testing in next and probably also a non-Freescale Reviewed-by.
[Sethi Varun-B16395] I would request you and Alex Williamson to review the patch and provide a Reviewed-by.
-Varun
Joerg Roedel
maintainerVarun,
Quoted 8 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.Signed-off-by Varun Sethi <[email protected]>
Can you please rebase the driver tp v3.10-rc6 and resend asap? I will give it another review then and request AlexW to look over the iommu-group stuff. So we can probably get this merged for v3.11.
Thank,
Joerg