Skip to content

Commit f23cdfc

Browse files
committed
Merge tag 'iommu-updates-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu updates from Joerg Roedel: - remove the bus_set_iommu() interface which became unnecesary because of IOMMU per-device probing - make the dma-iommu.h header private - Intel VT-d changes from Lu Baolu: - Decouple PASID and PRI from SVA - Add ESRTPS & ESIRTPS capability check - Cleanups - Apple DART support for the M1 Pro/MAX SOCs - support for AMD IOMMUv2 page-tables for the DMA-API layer. The v2 page-tables are compatible with the x86 CPU page-tables. Using them for DMA-API prepares support for hardware-assisted IOMMU virtualization - support for MT6795 Helio X10 M4Us in the Mediatek IOMMU driver - some smaller fixes and cleanups * tag 'iommu-updates-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (59 commits) iommu/vt-d: Avoid unnecessary global DMA cache invalidation iommu/vt-d: Avoid unnecessary global IRTE cache invalidation iommu/vt-d: Rename cap_5lp_support to cap_fl5lp_support iommu/vt-d: Remove pasid_set_eafe() iommu/vt-d: Decouple PASID & PRI enabling from SVA iommu/vt-d: Remove unnecessary SVA data accesses in page fault path dt-bindings: iommu: arm,smmu-v3: Relax order of interrupt names iommu: dart: Support t6000 variant iommu/io-pgtable-dart: Add DART PTE support for t6000 iommu/io-pgtable: Add DART subpage protection support iommu/io-pgtable: Move Apple DART support to its own file iommu/mediatek: Add support for MT6795 Helio X10 M4Us iommu/mediatek: Introduce new flag TF_PORT_TO_ADDR_MT8173 dt-bindings: mediatek: Add bindings for MT6795 M4U iommu/iova: Fix module config properly iommu/amd: Fix sparse warning iommu/amd: Remove outdated comment iommu/amd: Free domain ID after domain_flush_pages iommu/amd: Free domain id in error path iommu/virtio: Fix compile error with viommu_capable() ...
2 parents 706eaca + 38713c6 commit f23cdfc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1501
-902
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@
321321
force_enable - Force enable the IOMMU on platforms known
322322
to be buggy with IOMMU enabled. Use this
323323
option with care.
324+
pgtbl_v1 - Use v1 page table for DMA-API (Default).
325+
pgtbl_v2 - Use v2 page table for DMA-API.
324326

325327
amd_iommu_dump= [HW,X86-64]
326328
Enable AMD IOMMU driver option to dump the ACPI table

Documentation/devicetree/bindings/iommu/arm,smmu-v3.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,11 @@ properties:
3939
any others.
4040
- minItems: 1
4141
items:
42-
- enum:
43-
- eventq # Event Queue not empty
44-
- gerror # Global Error activated
45-
- const: gerror
46-
- enum:
47-
- cmdq-sync # CMD_SYNC complete
48-
- priq # PRI Queue not empty
49-
- enum:
50-
- cmdq-sync
51-
- priq
42+
enum:
43+
- eventq # Event Queue not empty
44+
- gerror # Global Error activated
45+
- cmdq-sync # CMD_SYNC complete
46+
- priq # PRI Queue not empty
5247

5348
'#iommu-cells':
5449
const: 1

Documentation/devicetree/bindings/iommu/mediatek,iommu.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ properties:
7373
- mediatek,mt2701-m4u # generation one
7474
- mediatek,mt2712-m4u # generation two
7575
- mediatek,mt6779-m4u # generation two
76+
- mediatek,mt6795-m4u # generation two
7677
- mediatek,mt8167-m4u # generation two
7778
- mediatek,mt8173-m4u # generation two
7879
- mediatek,mt8183-m4u # generation two
@@ -124,6 +125,7 @@ properties:
124125
dt-binding/memory/mt2701-larb-port.h for mt2701 and mt7623,
125126
dt-binding/memory/mt2712-larb-port.h for mt2712,
126127
dt-binding/memory/mt6779-larb-port.h for mt6779,
128+
dt-binding/memory/mt6795-larb-port.h for mt6795,
127129
dt-binding/memory/mt8167-larb-port.h for mt8167,
128130
dt-binding/memory/mt8173-larb-port.h for mt8173,
129131
dt-binding/memory/mt8183-larb-port.h for mt8183,
@@ -148,6 +150,7 @@ allOf:
148150
enum:
149151
- mediatek,mt2701-m4u
150152
- mediatek,mt2712-m4u
153+
- mediatek,mt6795-m4u
151154
- mediatek,mt8173-m4u
152155
- mediatek,mt8186-iommu-mm
153156
- mediatek,mt8192-m4u
@@ -177,6 +180,7 @@ allOf:
177180
contains:
178181
enum:
179182
- mediatek,mt2712-m4u
183+
- mediatek,mt6795-m4u
180184
- mediatek,mt8173-m4u
181185

182186
then:

MAINTAINERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,7 @@ F: drivers/dma/apple-admac.c
19151915
F: drivers/i2c/busses/i2c-pasemi-core.c
19161916
F: drivers/i2c/busses/i2c-pasemi-platform.c
19171917
F: drivers/iommu/apple-dart.c
1918+
F: drivers/iommu/io-pgtable-dart.c
19181919
F: drivers/irqchip/irq-apple-aic.c
19191920
F: drivers/mailbox/apple-mailbox.c
19201921
F: drivers/nvme/host/apple.c
@@ -10689,8 +10690,8 @@ L: [email protected]
1068910690
S: Maintained
1069010691
T: git git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git
1069110692
F: drivers/iommu/dma-iommu.c
10693+
F: drivers/iommu/dma-iommu.h
1069210694
F: drivers/iommu/iova.c
10693-
F: include/linux/dma-iommu.h
1069410695
F: include/linux/iova.h
1069510696

1069610697
IOMMU SUBSYSTEM

arch/arm64/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ config ARM64
209209
select HAVE_KPROBES
210210
select HAVE_KRETPROBES
211211
select HAVE_GENERIC_VDSO
212-
select IOMMU_DMA if IOMMU_SUPPORT
213212
select IRQ_DOMAIN
214213
select IRQ_FORCED_THREADING
215214
select KASAN_VMALLOC if KASAN

arch/arm64/mm/dma-mapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <linux/gfp.h>
88
#include <linux/cache.h>
99
#include <linux/dma-map-ops.h>
10-
#include <linux/dma-iommu.h>
10+
#include <linux/iommu.h>
1111
#include <xen/xen.h>
1212

1313
#include <asm/cacheflush.h>

drivers/acpi/viot.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#define pr_fmt(fmt) "ACPI: VIOT: " fmt
2020

2121
#include <linux/acpi_viot.h>
22-
#include <linux/dma-iommu.h>
2322
#include <linux/fwnode.h>
2423
#include <linux/iommu.h>
2524
#include <linux/list.h>

drivers/gpu/drm/exynos/exynos_drm_dma.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Author: Inki Dae <[email protected]>
55
// Author: Andrzej Hajda <[email protected]>
66

7-
#include <linux/dma-iommu.h>
87
#include <linux/dma-map-ops.h>
98
#include <linux/iommu.h>
109
#include <linux/platform_device.h>

drivers/iommu/Kconfig

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ config IOMMU_IO_PGTABLE_ARMV7S_SELFTEST
6767

6868
If unsure, say N here.
6969

70+
config IOMMU_IO_PGTABLE_DART
71+
bool "Apple DART Formats"
72+
select IOMMU_IO_PGTABLE
73+
depends on ARM64 || (COMPILE_TEST && !GENERIC_ATOMIC64)
74+
help
75+
Enable support for the Apple DART pagetable formats. These include
76+
the t8020 and t6000/t8110 DART formats used in Apple M1/M2 family
77+
SoCs.
78+
79+
If unsure, say N here.
80+
7081
endmenu
7182

7283
config IOMMU_DEBUGFS
@@ -137,7 +148,7 @@ config OF_IOMMU
137148

138149
# IOMMU-agnostic DMA-mapping layer
139150
config IOMMU_DMA
140-
bool
151+
def_bool ARM64 || IA64 || X86
141152
select DMA_OPS
142153
select IOMMU_API
143154
select IOMMU_IOVA
@@ -294,7 +305,7 @@ config APPLE_DART
294305
tristate "Apple DART IOMMU Support"
295306
depends on ARCH_APPLE || (COMPILE_TEST && !GENERIC_ATOMIC64)
296307
select IOMMU_API
297-
select IOMMU_IO_PGTABLE_LPAE
308+
select IOMMU_IO_PGTABLE_DART
298309
default ARCH_APPLE
299310
help
300311
Support for Apple DART (Device Address Resolution Table) IOMMUs
@@ -476,7 +487,6 @@ config VIRTIO_IOMMU
476487
depends on VIRTIO
477488
depends on (ARM64 || X86)
478489
select IOMMU_API
479-
select IOMMU_DMA
480490
select INTERVAL_TREE
481491
select ACPI_VIOT if ACPI
482492
help

drivers/iommu/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ obj-$(CONFIG_IOMMU_DMA) += dma-iommu.o
88
obj-$(CONFIG_IOMMU_IO_PGTABLE) += io-pgtable.o
99
obj-$(CONFIG_IOMMU_IO_PGTABLE_ARMV7S) += io-pgtable-arm-v7s.o
1010
obj-$(CONFIG_IOMMU_IO_PGTABLE_LPAE) += io-pgtable-arm.o
11+
obj-$(CONFIG_IOMMU_IO_PGTABLE_DART) += io-pgtable-dart.o
1112
obj-$(CONFIG_IOASID) += ioasid.o
1213
obj-$(CONFIG_IOMMU_IOVA) += iova.o
1314
obj-$(CONFIG_OF_IOMMU) += of_iommu.o

drivers/iommu/amd/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ config AMD_IOMMU
99
select PCI_PASID
1010
select IOMMU_API
1111
select IOMMU_IOVA
12-
select IOMMU_DMA
1312
select IOMMU_IO_PGTABLE
1413
depends on X86_64 && PCI && ACPI && HAVE_CMPXCHG_DOUBLE
1514
help

drivers/iommu/amd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
obj-$(CONFIG_AMD_IOMMU) += iommu.o init.o quirks.o io_pgtable.o
2+
obj-$(CONFIG_AMD_IOMMU) += iommu.o init.o quirks.o io_pgtable.o io_pgtable_v2.o
33
obj-$(CONFIG_AMD_IOMMU_DEBUGFS) += debugfs.o
44
obj-$(CONFIG_AMD_IOMMU_V2) += iommu_v2.o

drivers/iommu/amd/amd_iommu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ extern void amd_iommu_restart_event_logging(struct amd_iommu *iommu);
1818
extern int amd_iommu_init_devices(void);
1919
extern void amd_iommu_uninit_devices(void);
2020
extern void amd_iommu_init_notifier(void);
21-
extern int amd_iommu_init_api(void);
2221
extern void amd_iommu_set_rlookup_table(struct amd_iommu *iommu, u16 devid);
2322

2423
#ifdef CONFIG_AMD_IOMMU_DEBUGFS

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
#define FEATURE_HE (1ULL<<8)
9595
#define FEATURE_PC (1ULL<<9)
9696
#define FEATURE_GAM_VAPIC (1ULL<<21)
97+
#define FEATURE_GIOSUP (1ULL<<48)
9798
#define FEATURE_EPHSUP (1ULL<<50)
9899
#define FEATURE_SNP (1ULL<<63)
99100

@@ -276,6 +277,8 @@
276277
* 512GB Pages are not supported due to a hardware bug
277278
*/
278279
#define AMD_IOMMU_PGSIZES ((~0xFFFUL) & ~(2ULL << 38))
280+
/* 4K, 2MB, 1G page sizes are supported */
281+
#define AMD_IOMMU_PGSIZES_V2 (PAGE_SIZE | (1ULL << 21) | (1ULL << 30))
279282

280283
/* Bit value definition for dte irq remapping fields*/
281284
#define DTE_IRQ_PHYS_ADDR_MASK (((1ULL << 45)-1) << 6)
@@ -376,6 +379,7 @@
376379
#define DTE_FLAG_IW (1ULL << 62)
377380

378381
#define DTE_FLAG_IOTLB (1ULL << 32)
382+
#define DTE_FLAG_GIOV (1ULL << 54)
379383
#define DTE_FLAG_GV (1ULL << 55)
380384
#define DTE_FLAG_MASK (0x3ffULL << 32)
381385
#define DTE_GLX_SHIFT (56)
@@ -434,6 +438,7 @@
434438
#define PD_PASSTHROUGH_MASK (1UL << 2) /* domain has no page
435439
translation */
436440
#define PD_IOMMUV2_MASK (1UL << 3) /* domain has gcr3 table */
441+
#define PD_GIOV_MASK (1UL << 4) /* domain enable GIOV support */
437442

438443
extern bool amd_iommu_dump;
439444
#define DUMP_printk(format, arg...) \
@@ -456,6 +461,8 @@ struct irq_remap_table {
456461
/* Interrupt remapping feature used? */
457462
extern bool amd_iommu_irq_remap;
458463

464+
extern const struct iommu_ops amd_iommu_ops;
465+
459466
/* IVRS indicates that pre-boot remapping was enabled */
460467
extern bool amdr_ivrs_remap_support;
461468

@@ -526,7 +533,8 @@ struct amd_io_pgtable {
526533
struct io_pgtable iop;
527534
int mode;
528535
u64 *root;
529-
atomic64_t pt_root; /* pgtable root and pgtable mode */
536+
atomic64_t pt_root; /* pgtable root and pgtable mode */
537+
u64 *pgd; /* v2 pgtable pgd pointer */
530538
};
531539

532540
/*

drivers/iommu/amd/init.c

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@
9595
* out of it.
9696
*/
9797

98-
extern const struct iommu_ops amd_iommu_ops;
99-
10098
/*
10199
* structure describing one IOMMU in the ACPI table. Typically followed by one
102100
* or more ivhd_entrys.
@@ -2068,6 +2066,17 @@ static int __init iommu_init_pci(struct amd_iommu *iommu)
20682066

20692067
init_iommu_perf_ctr(iommu);
20702068

2069+
if (amd_iommu_pgtable == AMD_IOMMU_V2) {
2070+
if (!iommu_feature(iommu, FEATURE_GIOSUP) ||
2071+
!iommu_feature(iommu, FEATURE_GT)) {
2072+
pr_warn("Cannot enable v2 page table for DMA-API. Fallback to v1.\n");
2073+
amd_iommu_pgtable = AMD_IOMMU_V1;
2074+
} else if (iommu_default_passthrough()) {
2075+
pr_warn("V2 page table doesn't support passthrough mode. Fallback to v1.\n");
2076+
amd_iommu_pgtable = AMD_IOMMU_V1;
2077+
}
2078+
}
2079+
20712080
if (is_rd890_iommu(iommu->dev)) {
20722081
int i, j;
20732082

@@ -2146,6 +2155,8 @@ static void print_iommu_info(void)
21462155
if (amd_iommu_xt_mode == IRQ_REMAP_X2APIC_MODE)
21472156
pr_info("X2APIC enabled\n");
21482157
}
2158+
if (amd_iommu_pgtable == AMD_IOMMU_V2)
2159+
pr_info("V2 page table enabled\n");
21492160
}
21502161

21512162
static int __init amd_iommu_init_pci(void)
@@ -2168,20 +2179,13 @@ static int __init amd_iommu_init_pci(void)
21682179
/*
21692180
* Order is important here to make sure any unity map requirements are
21702181
* fulfilled. The unity mappings are created and written to the device
2171-
* table during the amd_iommu_init_api() call.
2182+
* table during the iommu_init_pci() call.
21722183
*
21732184
* After that we call init_device_table_dma() to make sure any
21742185
* uninitialized DTE will block DMA, and in the end we flush the caches
21752186
* of all IOMMUs to make sure the changes to the device table are
21762187
* active.
21772188
*/
2178-
ret = amd_iommu_init_api();
2179-
if (ret) {
2180-
pr_err("IOMMU: Failed to initialize IOMMU-API interface (error=%d)!\n",
2181-
ret);
2182-
goto out;
2183-
}
2184-
21852189
for_each_pci_segment(pci_seg)
21862190
init_device_table_dma(pci_seg);
21872191

@@ -3366,17 +3370,30 @@ static int __init parse_amd_iommu_intr(char *str)
33663370

33673371
static int __init parse_amd_iommu_options(char *str)
33683372
{
3369-
for (; *str; ++str) {
3373+
if (!str)
3374+
return -EINVAL;
3375+
3376+
while (*str) {
33703377
if (strncmp(str, "fullflush", 9) == 0) {
33713378
pr_warn("amd_iommu=fullflush deprecated; use iommu.strict=1 instead\n");
33723379
iommu_set_dma_strict();
3373-
}
3374-
if (strncmp(str, "force_enable", 12) == 0)
3380+
} else if (strncmp(str, "force_enable", 12) == 0) {
33753381
amd_iommu_force_enable = true;
3376-
if (strncmp(str, "off", 3) == 0)
3382+
} else if (strncmp(str, "off", 3) == 0) {
33773383
amd_iommu_disabled = true;
3378-
if (strncmp(str, "force_isolation", 15) == 0)
3384+
} else if (strncmp(str, "force_isolation", 15) == 0) {
33793385
amd_iommu_force_isolation = true;
3386+
} else if (strncmp(str, "pgtbl_v1", 8) == 0) {
3387+
amd_iommu_pgtable = AMD_IOMMU_V1;
3388+
} else if (strncmp(str, "pgtbl_v2", 8) == 0) {
3389+
amd_iommu_pgtable = AMD_IOMMU_V2;
3390+
} else {
3391+
pr_notice("Unknown option - '%s'\n", str);
3392+
}
3393+
3394+
str += strcspn(str, ",");
3395+
while (*str == ',')
3396+
str++;
33803397
}
33813398

33823399
return 1;

0 commit comments

Comments
 (0)