Skip to content

Commit 4dfc278

Browse files
committed
Merge tag 'iommu-updates-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull IOMMU updates from Joerg Roedel: "Slightly more changes than usual this time: - KDump Kernel IOMMU take-over code for AMD IOMMU. The code now tries to preserve the mappings of the kernel so that master aborts for devices are avoided. Master aborts cause some devices to fail in the kdump kernel, so this code makes the dump more likely to succeed when AMD IOMMU is enabled. - common flush queue implementation for IOVA code users. The code is still optional, but AMD and Intel IOMMU drivers had their own implementation which is now unified. - finish support for iommu-groups. All drivers implement this feature now so that IOMMU core code can rely on it. - finish support for 'struct iommu_device' in iommu drivers. All drivers now use the interface. - new functions in the IOMMU-API for explicit IO/TLB flushing. This will help to reduce the number of IO/TLB flushes when IOMMU drivers support this interface. - support for mt2712 in the Mediatek IOMMU driver - new IOMMU driver for QCOM hardware - system PM support for ARM-SMMU - shutdown method for ARM-SMMU-v3 - some constification patches - various other small improvements and fixes" * tag 'iommu-updates-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (87 commits) iommu/vt-d: Don't be too aggressive when clearing one context entry iommu: Introduce Interface for IOMMU TLB Flushing iommu/s390: Constify iommu_ops iommu/vt-d: Avoid calling virt_to_phys() on null pointer iommu/vt-d: IOMMU Page Request needs to check if address is canonical. arm/tegra: Call bus_set_iommu() after iommu_device_register() iommu/exynos: Constify iommu_ops iommu/ipmmu-vmsa: Make ipmmu_gather_ops const iommu/ipmmu-vmsa: Rereserving a free context before setting up a pagetable iommu/amd: Rename a few flush functions iommu/amd: Check if domain is NULL in get_domain() and return -EBUSY iommu/mediatek: Fix a build warning of BIT(32) in ARM iommu/mediatek: Fix a build fail of m4u_type iommu: qcom: annotate PM functions as __maybe_unused iommu/pamu: Fix PAMU boot crash memory: mtk-smi: Degrade SMI init to module_init iommu/mediatek: Enlarge the validate PA range for 4GB mode iommu/mediatek: Disable iommu clock when system suspend iommu/mediatek: Move pgtable allocation into domain_alloc iommu/mediatek: Merge 2 M4U HWs into one iommu domain ...
2 parents a59e57d + 47b59d8 commit 4dfc278

41 files changed

Lines changed: 2881 additions & 1233 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
* QCOM IOMMU v1 Implementation
2+
3+
Qualcomm "B" family devices which are not compatible with arm-smmu have
4+
a similar looking IOMMU but without access to the global register space,
5+
and optionally requiring additional configuration to route context irqs
6+
to non-secure vs secure interrupt line.
7+
8+
** Required properties:
9+
10+
- compatible : Should be one of:
11+
12+
"qcom,msm8916-iommu"
13+
14+
Followed by "qcom,msm-iommu-v1".
15+
16+
- clock-names : Should be a pair of "iface" (required for IOMMUs
17+
register group access) and "bus" (required for
18+
the IOMMUs underlying bus access).
19+
20+
- clocks : Phandles for respective clocks described by
21+
clock-names.
22+
23+
- #address-cells : must be 1.
24+
25+
- #size-cells : must be 1.
26+
27+
- #iommu-cells : Must be 1. Index identifies the context-bank #.
28+
29+
- ranges : Base address and size of the iommu context banks.
30+
31+
- qcom,iommu-secure-id : secure-id.
32+
33+
- List of sub-nodes, one per translation context bank. Each sub-node
34+
has the following required properties:
35+
36+
- compatible : Should be one of:
37+
- "qcom,msm-iommu-v1-ns" : non-secure context bank
38+
- "qcom,msm-iommu-v1-sec" : secure context bank
39+
- reg : Base address and size of context bank within the iommu
40+
- interrupts : The context fault irq.
41+
42+
** Optional properties:
43+
44+
- reg : Base address and size of the SMMU local base, should
45+
be only specified if the iommu requires configuration
46+
for routing of context bank irq's to secure vs non-
47+
secure lines. (Ie. if the iommu contains secure
48+
context banks)
49+
50+
51+
** Examples:
52+
53+
apps_iommu: iommu@1e20000 {
54+
#address-cells = <1>;
55+
#size-cells = <1>;
56+
#iommu-cells = <1>;
57+
compatible = "qcom,msm8916-iommu", "qcom,msm-iommu-v1";
58+
ranges = <0 0x1e20000 0x40000>;
59+
reg = <0x1ef0000 0x3000>;
60+
clocks = <&gcc GCC_SMMU_CFG_CLK>,
61+
<&gcc GCC_APSS_TCU_CLK>;
62+
clock-names = "iface", "bus";
63+
qcom,iommu-secure-id = <17>;
64+
65+
// mdp_0:
66+
iommu-ctx@4000 {
67+
compatible = "qcom,msm-iommu-v1-ns";
68+
reg = <0x4000 0x1000>;
69+
interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
70+
};
71+
72+
// venus_ns:
73+
iommu-ctx@5000 {
74+
compatible = "qcom,msm-iommu-v1-sec";
75+
reg = <0x5000 0x1000>;
76+
interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
77+
};
78+
};
79+
80+
gpu_iommu: iommu@1f08000 {
81+
#address-cells = <1>;
82+
#size-cells = <1>;
83+
#iommu-cells = <1>;
84+
compatible = "qcom,msm8916-iommu", "qcom,msm-iommu-v1";
85+
ranges = <0 0x1f08000 0x10000>;
86+
clocks = <&gcc GCC_SMMU_CFG_CLK>,
87+
<&gcc GCC_GFX_TCU_CLK>;
88+
clock-names = "iface", "bus";
89+
qcom,iommu-secure-id = <18>;
90+
91+
// gfx3d_user:
92+
iommu-ctx@1000 {
93+
compatible = "qcom,msm-iommu-v1-ns";
94+
reg = <0x1000 0x1000>;
95+
interrupts = <GIC_SPI 241 IRQ_TYPE_LEVEL_HIGH>;
96+
};
97+
98+
// gfx3d_priv:
99+
iommu-ctx@2000 {
100+
compatible = "qcom,msm-iommu-v1-ns";
101+
reg = <0x2000 0x1000>;
102+
interrupts = <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>;
103+
};
104+
};
105+
106+
...
107+
108+
venus: video-codec@1d00000 {
109+
...
110+
iommus = <&apps_iommu 5>;
111+
};
112+
113+
mdp: mdp@1a01000 {
114+
...
115+
iommus = <&apps_iommu 4>;
116+
};
117+
118+
gpu@01c00000 {
119+
...
120+
iommus = <&gpu_iommu 1>, <&gpu_iommu 2>;
121+
};

‎Documentation/devicetree/bindings/iommu/rockchip,iommu.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ Required properties:
1515
to associate with its master device. See:
1616
Documentation/devicetree/bindings/iommu/iommu.txt
1717

18+
Optional properties:
19+
- rockchip,disable-mmu-reset : Don't use the mmu reset operation.
20+
Some mmu instances may produce unexpected results
21+
when the reset operation is used.
22+
1823
Example:
1924

2025
vopl_mmu: iommu@ff940300 {

‎Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Required properties:
1515
the register.
1616
- "smi" : It's the clock for transfer data and command.
1717

18+
Required property for mt2701:
19+
- mediatek,larb-id :the hardware id of this larb.
20+
1821
Example:
1922
larb1: larb@16010000 {
2023
compatible = "mediatek,mt8173-smi-larb";
@@ -25,3 +28,15 @@ Example:
2528
<&vdecsys CLK_VDEC_LARB_CKEN>;
2629
clock-names = "apb", "smi";
2730
};
31+
32+
Example for mt2701:
33+
larb0: larb@14010000 {
34+
compatible = "mediatek,mt2701-smi-larb";
35+
reg = <0 0x14010000 0 0x1000>;
36+
mediatek,smi = <&smi_common>;
37+
mediatek,larb-id = <0>;
38+
clocks = <&mmsys CLK_MM_SMI_LARB0>,
39+
<&mmsys CLK_MM_SMI_LARB0>;
40+
clock-names = "apb", "smi";
41+
power-domains = <&scpsys MT2701_POWER_DOMAIN_DISP>;
42+
};

‎MAINTAINERS‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11117,6 +11117,13 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/rkuo/linux-hexagon-kernel.g
1111711117
S: Supported
1111811118
F: arch/hexagon/
1111911119

11120+
QUALCOMM IOMMU
11121+
M: Rob Clark <robdclark@gmail.com>
11122+
L: iommu@lists.linux-foundation.org
11123+
L: linux-arm-msm@vger.kernel.org
11124+
S: Maintained
11125+
F: drivers/iommu/qcom_iommu.c
11126+
1112011127
QUALCOMM VENUS VIDEO ACCELERATOR DRIVER
1112111128
M: Stanimir Varbanov <stanimir.varbanov@linaro.org>
1112211129
L: linux-media@vger.kernel.org

‎arch/s390/include/asm/pci.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/pci.h>
1010
#include <linux/mutex.h>
11+
#include <linux/iommu.h>
1112
#include <asm-generic/pci.h>
1213
#include <asm/pci_clp.h>
1314
#include <asm/pci_debug.h>
@@ -122,6 +123,8 @@ struct zpci_dev {
122123
unsigned long iommu_pages;
123124
unsigned int next_bit;
124125

126+
struct iommu_device iommu_dev; /* IOMMU core handle */
127+
125128
char res_name[16];
126129
struct zpci_bar_struct bars[PCI_BAR_COUNT];
127130

@@ -174,6 +177,10 @@ int clp_enable_fh(struct zpci_dev *, u8);
174177
int clp_disable_fh(struct zpci_dev *);
175178
int clp_get_state(u32 fid, enum zpci_state *state);
176179

180+
/* IOMMU Interface */
181+
int zpci_init_iommu(struct zpci_dev *zdev);
182+
void zpci_destroy_iommu(struct zpci_dev *zdev);
183+
177184
#ifdef CONFIG_PCI
178185
/* Error handling and recovery */
179186
void zpci_event_error(void *);

‎arch/s390/pci/pci.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ void pcibios_remove_bus(struct pci_bus *bus)
772772

773773
zpci_exit_slot(zdev);
774774
zpci_cleanup_bus_resources(zdev);
775+
zpci_destroy_iommu(zdev);
775776
zpci_free_domain(zdev);
776777

777778
spin_lock(&zpci_list_lock);
@@ -844,11 +845,15 @@ int zpci_create_device(struct zpci_dev *zdev)
844845
if (rc)
845846
goto out;
846847

848+
rc = zpci_init_iommu(zdev);
849+
if (rc)
850+
goto out_free;
851+
847852
mutex_init(&zdev->lock);
848853
if (zdev->state == ZPCI_FN_STATE_CONFIGURED) {
849854
rc = zpci_enable_device(zdev);
850855
if (rc)
851-
goto out_free;
856+
goto out_destroy_iommu;
852857
}
853858
rc = zpci_scan_bus(zdev);
854859
if (rc)
@@ -865,6 +870,8 @@ int zpci_create_device(struct zpci_dev *zdev)
865870
out_disable:
866871
if (zdev->state == ZPCI_FN_STATE_ONLINE)
867872
zpci_disable_device(zdev);
873+
out_destroy_iommu:
874+
zpci_destroy_iommu(zdev);
868875
out_free:
869876
zpci_free_domain(zdev);
870877
out:

‎drivers/iommu/Kconfig‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ config IOMMU_DMA
7676

7777
config FSL_PAMU
7878
bool "Freescale IOMMU support"
79+
depends on PCI
80+
depends on PHYS_64BIT
7981
depends on PPC_E500MC || (COMPILE_TEST && PPC)
8082
select IOMMU_API
8183
select GENERIC_ALLOCATOR
@@ -253,6 +255,7 @@ config TEGRA_IOMMU_SMMU
253255
config EXYNOS_IOMMU
254256
bool "Exynos IOMMU Support"
255257
depends on ARCH_EXYNOS && MMU
258+
depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes
256259
select IOMMU_API
257260
select ARM_DMA_USE_IOMMU
258261
help
@@ -367,4 +370,14 @@ config MTK_IOMMU_V1
367370

368371
if unsure, say N here.
369372

373+
config QCOM_IOMMU
374+
# Note: iommu drivers cannot (yet?) be built as modules
375+
bool "Qualcomm IOMMU Support"
376+
depends on ARCH_QCOM || COMPILE_TEST
377+
select IOMMU_API
378+
select IOMMU_IO_PGTABLE_LPAE
379+
select ARM_DMA_USE_IOMMU
380+
help
381+
Support for IOMMU on certain Qualcomm SoCs.
382+
370383
endif # IOMMU_SUPPORT

‎drivers/iommu/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ obj-$(CONFIG_TEGRA_IOMMU_SMMU) += tegra-smmu.o
2727
obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iommu.o
2828
obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o
2929
obj-$(CONFIG_S390_IOMMU) += s390-iommu.o
30+
obj-$(CONFIG_QCOM_IOMMU) += qcom_iommu.o

0 commit comments

Comments
 (0)