iommu/arm=smmu: Add driver for ARM SMMUv3 devices
Subsystems (4)
v2 cover iommu/arm=smmu: Add driver for ARM SMMUv3 devices
Hi all,
This is version two of the patches I originally posted here:
http://www.spinics.net/lists/arm-kernel/msg416881.html
Changes since version one include:
- Lazy allocation of the level-2 stream table on device-add
- Limit stream table size based on SIDSIZE (maximum 21-bit atm)
- Fixed detection of linear stream table
- Fixed typo in RECINVSID CR2 field
- Added cmdline option for changing default bypass behaviour to fault
- Check IDR0.HYP before EL2 TLBI
- Reworked stream table so that each level-2 entry resolves 256 SIDs (i.e. a PCI bus)
All feedback welcome,
Will
--->8
Will Deacon (3):
Documentation: dt-bindings: Add device-tree binding for ARM SMMUv3
IOMMU
iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices drivers/vfio: Allow type-1 IOMMU instantiation on top of an ARM SMMUv3
.../devicetree/bindings/iommu/arm,smmu-v3.txt | 37 + MAINTAINERS | 3 +- drivers/iommu/Kconfig | 13 + drivers/iommu/Makefile | 1 + drivers/iommu/arm-smmu-v3.c | 2670 ++++++++++++++++++++ drivers/vfio/Kconfig | 2 +- 6 files changed, 2724 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt create mode 100644 drivers/iommu/arm-smmu-v3.c
Signature · 1 line
2.1.4
PATCH v2 1/3 Documentation: dt-bindings: Add device-tree binding for ARM SMMUv3 IOMMU
This patch adds device-tree bindings for ARM SMMUv3 IOMMU devices.
--- .../devicetree/bindings/iommu/arm,smmu-v3.txt | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt
Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt new file +37 -0
@@ -0,0 +1,37 @@ +* ARM SMMUv3 Architecture Implementation + +The SMMUv3 architecture is a significant deparature from previous +revisions, replacing the MMIO register interface with in-memory command +and event queues and adding support for the ATS and PRI components of +the PCIe specification. + +** SMMUv3 required properties: + +- compatible : Should include: + + * "arm,smmu-v3" for any SMMUv3 compliant + implementation. This entry should be last in the + compatible list. + +- reg : Base address and size of the SMMU. + +- interrupts : Non-secure interrupt list describing the wired + interrupt sources corresponding to entries in + interrupt-names. If no wired interrupts are + present then this property may be omitted. + +- interrupt-names : When the interrupts property is present, should + include the following: + * "eventq" - Event Queue not empty + * "priq" - PRI Queue not empty + * "cmdq-sync" - CMD_SYNC complete + * "gerror" - Global Error activated + +** SMMUv3 optional properties: + +- dma-coherent : Present if DMA operations made by the SMMU (page + table walks, stream table accesses etc) are cache + coherent with the CPU. + + NOTE: this only applies to the SMMU itself, not + masters connected upstream of the SMMU.
Signature · 1 line
2.1.4
PATCH v2 2/3 iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices
In reply to Will DeaconVersion three of the ARM SMMU architecture introduces significant changes and improvements over previous versions of the specification, necessitating a new driver in the Linux kernel.
The main change to the programming interface is that the majority of the configuration data has been moved from MMIO registers to in-memory data structures, with communication between the CPU and the SMMU being mediated via in-memory circular queues.
This patch adds an initial driver for SMMUv3 to Linux. We currently support pinned stage-1 (DMA) and stage-2 (KVM VFIO) mappings using the generic IO-pgtable code.
--- MAINTAINERS | 3 +- drivers/iommu/Kconfig | 13 + drivers/iommu/Makefile | 1 + drivers/iommu/arm-smmu-v3.c | 2670 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2686 insertions(+), 1 deletion(-) create mode 100644 drivers/iommu/arm-smmu-v3.c
MAINTAINERS +2 -1
@@ -1634,11 +1634,12 @@ F: drivers/i2c/busses/i2c-cadence.c F: drivers/mmc/host/sdhci-of-arasan.c F: drivers/edac/synopsys_edac.c -ARM SMMU DRIVER +ARM SMMU DRIVERS M: Will Deacon <[email protected]> L: linux-arm-kernel at lists.infradead.org (moderated for non-subscribers) S: Maintained F: drivers/iommu/arm-smmu.c +F: drivers/iommu/arm-smmu-v3.c F: drivers/iommu/io-pgtable-arm.c ARM64 PORT (AARCH64 ARCHITECTURE)
drivers/iommu/Kconfig +13 -0
@@ -339,6 +339,7 @@ config SPAPR_TCE_IOMMU Enables bits of IOMMU API required by VFIO. The iommu_ops is not implemented as it is not necessary for VFIO. +# ARM IOMMU support config ARM_SMMU bool "ARM Ltd. System MMU (SMMU) Support" depends on (ARM64 || ARM) && MMU
@@ -352,4 +353,16 @@ config ARM_SMMU Say Y here if your SoC includes an IOMMU device implementing the ARM SMMU architecture. +config ARM_SMMU_V3 + bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support" + depends on ARM64 && PCI + select IOMMU_API + select IOMMU_IO_PGTABLE_LPAE + help + Support for implementations of the ARM System MMU architecture + version 3 providing translation support to a PCIe root complex. + + Say Y here if your system includes an IOMMU device implementing + the ARM SMMUv3 architecture. + endif # IOMMU_SUPPORT
drivers/iommu/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o msm_iommu_dev.o obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o obj-$(CONFIG_AMD_IOMMU_V2) += amd_iommu_v2.o obj-$(CONFIG_ARM_SMMU) += arm-smmu.o +obj-$(CONFIG_ARM_SMMU_V3) += arm-smmu-v3.o obj-$(CONFIG_DMAR_TABLE) += dmar.o obj-$(CONFIG_INTEL_IOMMU) += intel-iommu.o obj-$(CONFIG_IPMMU_VMSA) += ipmmu-vmsa.o
drivers/iommu/arm-smmu-v3.c new file +2670 -0
2,670 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 3/3 drivers/vfio: Allow type-1 IOMMU instantiation on top of an ARM SMMUv3
In reply to Will DeaconThe ARM SMMUv3 driver is compatible with the notion of a type-1 IOMMU in VFIO.
This patch allows VFIO_IOMMU_TYPE1 to be selected if ARM_SMMU_V3=y.
--- drivers/vfio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/Kconfig +1 -1
@@ -21,7 +21,7 @@ config VFIO_VIRQFD menuconfig VFIO tristate "VFIO Non-Privileged userspace driver framework" depends on IOMMU_API - select VFIO_IOMMU_TYPE1 if (X86 || S390 || ARM_SMMU) + select VFIO_IOMMU_TYPE1 if (X86 || S390 || ARM_SMMU || ARM_SMMU_V3) select VFIO_IOMMU_SPAPR_TCE if (PPC_POWERNV || PPC_PSERIES) select VFIO_SPAPR_EEH if (PPC_POWERNV || PPC_PSERIES) select ANON_INODES
Signature · 1 line
2.1.4
PATCH v2 3/3 drivers/vfio: Allow type-1 IOMMU instantiation on top of an ARM SMMUv3
Quoted 6 lines · Will Deacon
The ARM SMMUv3 driver is compatible with the notion of a type-1 IOMMU in VFIO.
This patch allows
VFIO_IOMMU_TYPE1to be selected if ARM_SMMU_V3=y.Signed-off-by Will Deacon <[email protected]>
Quoted 17 lines
--- drivers/vfio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/vfio/Kconfig +1
-1@@ -21,7 +21,7 @@ config VFIO_VIRQFD menuconfig VFIO tristate "VFIO Non-Privileged userspace driver framework" depends on IOMMU_API - select VFIO_IOMMU_TYPE1 if (X86 || S390 || ARM_SMMU) + select VFIO_IOMMU_TYPE1 if (X86 || S390 || ARM_SMMU || ARM_SMMU_V3) select VFIO_IOMMU_SPAPR_TCE if (PPC_POWERNV || PPC_PSERIES) select VFIO_SPAPR_EEH if (PPC_POWERNV || PPC_PSERIES) select ANON_INODES
v2 cover iommu/arm=smmu: Add driver for ARM SMMUv3 devices
In reply to Will DeaconQuoted 6 lines · Will Deacon
Will Deacon (3):
Documentation: dt-bindings: Add device-tree binding for ARM SMMUv3
IOMMU
iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devicesdrivers/vfio: Allow type-1 IOMMU instantiation on top of an ARM SMMUv3
Quoted 9 lines
.../devicetree/bindings/iommu/arm,smmu-v3.txt | 37 + MAINTAINERS | 3 +- drivers/iommu/Kconfig | 13 + drivers/iommu/Makefile | 1 + drivers/iommu/arm-smmu-v3.c | 2670 ++++++++++++++++++++ drivers/vfio/Kconfig | 2 +- 6 files changed, 2724 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt create mode 100644 drivers/iommu/arm-smmu-v3.c
Applied, thanks.