Skip to content

Commit e1cbc3b

Browse files
committed
Merge tag 'iommu-updates-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu updates from Joerg Roedel: - Intel VT-d driver updates: - Domain force snooping improvement. - Cleanups, no intentional functional changes. - ARM SMMU driver updates: - Add new Qualcomm device-tree compatible strings - Add new Nvidia device-tree compatible string for Tegra234 - Fix UAF in SMMUv3 shared virtual addressing code - Force identity-mapped domains for users of ye olde SMMU legacy binding - Minor cleanups - Fix a BUG_ON in the vfio_iommu_group_notifier: - Groundwork for upcoming iommufd framework - Introduction of DMA ownership so that an entire IOMMU group is either controlled by the kernel or by user-space - MT8195 and MT8186 support in the Mediatek IOMMU driver - Make forcing of cache-coherent DMA more coherent between IOMMU drivers - Fixes for thunderbolt device DMA protection - Various smaller fixes and cleanups * tag 'iommu-updates-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (88 commits) iommu/amd: Increase timeout waiting for GA log enablement iommu/s390: Tolerate repeat attach_dev calls iommu/vt-d: Remove hard coding PGSNP bit in PASID entries iommu/vt-d: Remove domain_update_iommu_snooping() iommu/vt-d: Check domain force_snooping against attached devices iommu/vt-d: Block force-snoop domain attaching if no SC support iommu/vt-d: Size Page Request Queue to avoid overflow condition iommu/vt-d: Fold dmar_insert_one_dev_info() into its caller iommu/vt-d: Change return type of dmar_insert_one_dev_info() iommu/vt-d: Remove unneeded validity check on dev iommu/dma: Explicitly sort PCI DMA windows iommu/dma: Fix iova map result check bug iommu/mediatek: Fix NULL pointer dereference when printing dev_name iommu: iommu_group_claim_dma_owner() must always assign a domain iommu/arm-smmu: Force identity domains for legacy binding iommu/arm-smmu: Support Tegra234 SMMU dt-bindings: arm-smmu: Add compatible for Tegra234 SOC dt-bindings: arm-smmu: Document nvidia,memory-controller property iommu/arm-smmu-qcom: Add SC8280XP support dt-bindings: arm-smmu: Add compatible for Qualcomm SC8280XP ...
2 parents 3335d55 + b0dacee commit e1cbc3b

Some content is hidden

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

53 files changed

+2317
-1036
lines changed

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ properties:
3737
- qcom,sc7180-smmu-500
3838
- qcom,sc7280-smmu-500
3939
- qcom,sc8180x-smmu-500
40+
- qcom,sc8280xp-smmu-500
4041
- qcom,sdm845-smmu-500
4142
- qcom,sdx55-smmu-500
43+
- qcom,sdx65-smmu-500
4244
- qcom,sm6350-smmu-500
4345
- qcom,sm8150-smmu-500
4446
- qcom,sm8250-smmu-500
@@ -62,8 +64,9 @@ properties:
6264
for improved performance.
6365
items:
6466
- enum:
65-
- nvidia,tegra194-smmu
6667
- nvidia,tegra186-smmu
68+
- nvidia,tegra194-smmu
69+
- nvidia,tegra234-smmu
6770
- const: nvidia,smmu-500
6871
- items:
6972
- const: arm,mmu-500
@@ -157,6 +160,17 @@ properties:
157160
power-domains:
158161
maxItems: 1
159162

163+
nvidia,memory-controller:
164+
description: |
165+
A phandle to the memory controller on NVIDIA Tegra186 and later SoCs.
166+
The memory controller needs to be programmed with a mapping of memory
167+
client IDs to ARM SMMU stream IDs.
168+
169+
If this property is absent, the mapping programmed by early firmware
170+
will be used and it is not guaranteed that IOMMU translations will be
171+
enabled for any given device.
172+
$ref: /schemas/types.yaml#/definitions/phandle
173+
160174
required:
161175
- compatible
162176
- reg
@@ -172,13 +186,20 @@ allOf:
172186
compatible:
173187
contains:
174188
enum:
175-
- nvidia,tegra194-smmu
176189
- nvidia,tegra186-smmu
190+
- nvidia,tegra194-smmu
191+
- nvidia,tegra234-smmu
177192
then:
178193
properties:
179194
reg:
180195
minItems: 1
181196
maxItems: 2
197+
198+
# The reference to the memory controller is required to ensure that the
199+
# memory client to stream ID mapping can be done synchronously with the
200+
# IOMMU attachment.
201+
required:
202+
- nvidia,memory-controller
182203
else:
183204
properties:
184205
reg:

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ properties:
7676
- mediatek,mt8167-m4u # generation two
7777
- mediatek,mt8173-m4u # generation two
7878
- mediatek,mt8183-m4u # generation two
79+
- mediatek,mt8186-iommu-mm # generation two
7980
- mediatek,mt8192-m4u # generation two
81+
- mediatek,mt8195-iommu-vdo # generation two
82+
- mediatek,mt8195-iommu-vpp # generation two
83+
- mediatek,mt8195-iommu-infra # generation two
8084

8185
- description: mt7623 generation one
8286
items:
@@ -119,7 +123,9 @@ properties:
119123
dt-binding/memory/mt8167-larb-port.h for mt8167,
120124
dt-binding/memory/mt8173-larb-port.h for mt8173,
121125
dt-binding/memory/mt8183-larb-port.h for mt8183,
126+
dt-binding/memory/mt8186-memory-port.h for mt8186,
122127
dt-binding/memory/mt8192-larb-port.h for mt8192.
128+
dt-binding/memory/mt8195-memory-port.h for mt8195.
123129
124130
power-domains:
125131
maxItems: 1
@@ -128,7 +134,6 @@ required:
128134
- compatible
129135
- reg
130136
- interrupts
131-
- mediatek,larbs
132137
- '#iommu-cells'
133138

134139
allOf:
@@ -140,7 +145,10 @@ allOf:
140145
- mediatek,mt2701-m4u
141146
- mediatek,mt2712-m4u
142147
- mediatek,mt8173-m4u
148+
- mediatek,mt8186-iommu-mm
143149
- mediatek,mt8192-m4u
150+
- mediatek,mt8195-iommu-vdo
151+
- mediatek,mt8195-iommu-vpp
144152

145153
then:
146154
required:
@@ -150,12 +158,26 @@ allOf:
150158
properties:
151159
compatible:
152160
enum:
161+
- mediatek,mt8186-iommu-mm
153162
- mediatek,mt8192-m4u
163+
- mediatek,mt8195-iommu-vdo
164+
- mediatek,mt8195-iommu-vpp
154165

155166
then:
156167
required:
157168
- power-domains
158169

170+
- if: # The IOMMUs don't have larbs.
171+
not:
172+
properties:
173+
compatible:
174+
contains:
175+
const: mediatek,mt8195-iommu-infra
176+
177+
then:
178+
required:
179+
- mediatek,larbs
180+
159181
additionalProperties: false
160182

161183
examples:
@@ -173,13 +195,3 @@ examples:
173195
<&larb3>, <&larb4>, <&larb5>;
174196
#iommu-cells = <1>;
175197
};
176-
177-
- |
178-
#include <dt-bindings/memory/mt8173-larb-port.h>
179-
180-
/* Example for a client device */
181-
display {
182-
compatible = "mediatek,mt8173-disp";
183-
iommus = <&iommu M4U_PORT_DISP_OVL0>,
184-
<&iommu M4U_PORT_DISP_RDMA0>;
185-
};

Documentation/devicetree/bindings/iommu/samsung,sysmmu.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,6 @@ examples:
8686
- |
8787
#include <dt-bindings/clock/exynos5250.h>
8888
89-
gsc_0: scaler@13e00000 {
90-
compatible = "samsung,exynos5-gsc";
91-
reg = <0x13e00000 0x1000>;
92-
interrupts = <0 85 0>;
93-
power-domains = <&pd_gsc>;
94-
clocks = <&clock CLK_GSCL0>;
95-
clock-names = "gscl";
96-
iommus = <&sysmmu_gsc0>;
97-
};
98-
9989
sysmmu_gsc0: iommu@13e80000 {
10090
compatible = "samsung,exynos-sysmmu";
10191
reg = <0x13E80000 0x1000>;

MAINTAINERS

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,14 +1375,6 @@ L: [email protected]
13751375
S: Odd fixes
13761376
F: drivers/input/mouse/bcm5974.c
13771377

1378-
APPLE DART IOMMU DRIVER
1379-
M: Sven Peter <[email protected]>
1380-
R: Alyssa Rosenzweig <[email protected]>
1381-
1382-
S: Maintained
1383-
F: Documentation/devicetree/bindings/iommu/apple,dart.yaml
1384-
F: drivers/iommu/apple-dart.c
1385-
13861378
APPLE PCIE CONTROLLER DRIVER
13871379
M: Alyssa Rosenzweig <[email protected]>
13881380
M: Marc Zyngier <[email protected]>
@@ -1834,6 +1826,7 @@ F: Documentation/devicetree/bindings/arm/apple/*
18341826
F: Documentation/devicetree/bindings/clock/apple,nco.yaml
18351827
F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml
18361828
F: Documentation/devicetree/bindings/interrupt-controller/apple,*
1829+
F: Documentation/devicetree/bindings/iommu/apple,dart.yaml
18371830
F: Documentation/devicetree/bindings/iommu/apple,sart.yaml
18381831
F: Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml
18391832
F: Documentation/devicetree/bindings/nvme/apple,nvme-ans.yaml
@@ -1845,6 +1838,7 @@ F: arch/arm64/boot/dts/apple/
18451838
F: drivers/clk/clk-apple-nco.c
18461839
F: drivers/i2c/busses/i2c-pasemi-core.c
18471840
F: drivers/i2c/busses/i2c-pasemi-platform.c
1841+
F: drivers/iommu/apple-dart.c
18481842
F: drivers/irqchip/irq-apple-aic.c
18491843
F: drivers/mailbox/apple-mailbox.c
18501844
F: drivers/nvme/host/apple.c

drivers/amba/bus.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#include <linux/platform_device.h>
2121
#include <linux/reset.h>
2222
#include <linux/of_irq.h>
23+
#include <linux/of_device.h>
24+
#include <linux/acpi.h>
25+
#include <linux/iommu.h>
26+
#include <linux/dma-map-ops.h>
2327

2428
#define to_amba_driver(d) container_of(d, struct amba_driver, drv)
2529

@@ -273,6 +277,36 @@ static void amba_shutdown(struct device *dev)
273277
drv->shutdown(to_amba_device(dev));
274278
}
275279

280+
static int amba_dma_configure(struct device *dev)
281+
{
282+
struct amba_driver *drv = to_amba_driver(dev->driver);
283+
enum dev_dma_attr attr;
284+
int ret = 0;
285+
286+
if (dev->of_node) {
287+
ret = of_dma_configure(dev, dev->of_node, true);
288+
} else if (has_acpi_companion(dev)) {
289+
attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
290+
ret = acpi_dma_configure(dev, attr);
291+
}
292+
293+
if (!ret && !drv->driver_managed_dma) {
294+
ret = iommu_device_use_default_domain(dev);
295+
if (ret)
296+
arch_teardown_dma_ops(dev);
297+
}
298+
299+
return ret;
300+
}
301+
302+
static void amba_dma_cleanup(struct device *dev)
303+
{
304+
struct amba_driver *drv = to_amba_driver(dev->driver);
305+
306+
if (!drv->driver_managed_dma)
307+
iommu_device_unuse_default_domain(dev);
308+
}
309+
276310
#ifdef CONFIG_PM
277311
/*
278312
* Hooks to provide runtime PM of the pclk (bus clock). It is safe to
@@ -341,7 +375,8 @@ struct bus_type amba_bustype = {
341375
.probe = amba_probe,
342376
.remove = amba_remove,
343377
.shutdown = amba_shutdown,
344-
.dma_configure = platform_dma_configure,
378+
.dma_configure = amba_dma_configure,
379+
.dma_cleanup = amba_dma_cleanup,
345380
.pm = &amba_pm,
346381
};
347382
EXPORT_SYMBOL_GPL(amba_bustype);

drivers/base/dd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
671671
if (dev->bus)
672672
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
673673
BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
674+
if (dev->bus && dev->bus->dma_cleanup)
675+
dev->bus->dma_cleanup(dev);
674676
pinctrl_bind_failed:
675677
device_links_no_driver(dev);
676678
device_unbind_cleanup(dev);
@@ -1199,6 +1201,9 @@ static void __device_release_driver(struct device *dev, struct device *parent)
11991201

12001202
device_remove(dev);
12011203

1204+
if (dev->bus && dev->bus->dma_cleanup)
1205+
dev->bus->dma_cleanup(dev);
1206+
12021207
device_links_driver_cleanup(dev);
12031208
device_unbind_cleanup(dev);
12041209

drivers/base/platform.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <linux/property.h>
3131
#include <linux/kmemleak.h>
3232
#include <linux/types.h>
33+
#include <linux/iommu.h>
34+
#include <linux/dma-map-ops.h>
3335

3436
#include "base.h"
3537
#include "power/power.h"
@@ -1454,9 +1456,9 @@ static void platform_shutdown(struct device *_dev)
14541456
drv->shutdown(dev);
14551457
}
14561458

1457-
1458-
int platform_dma_configure(struct device *dev)
1459+
static int platform_dma_configure(struct device *dev)
14591460
{
1461+
struct platform_driver *drv = to_platform_driver(dev->driver);
14601462
enum dev_dma_attr attr;
14611463
int ret = 0;
14621464

@@ -1467,9 +1469,23 @@ int platform_dma_configure(struct device *dev)
14671469
ret = acpi_dma_configure(dev, attr);
14681470
}
14691471

1472+
if (!ret && !drv->driver_managed_dma) {
1473+
ret = iommu_device_use_default_domain(dev);
1474+
if (ret)
1475+
arch_teardown_dma_ops(dev);
1476+
}
1477+
14701478
return ret;
14711479
}
14721480

1481+
static void platform_dma_cleanup(struct device *dev)
1482+
{
1483+
struct platform_driver *drv = to_platform_driver(dev->driver);
1484+
1485+
if (!drv->driver_managed_dma)
1486+
iommu_device_unuse_default_domain(dev);
1487+
}
1488+
14731489
static const struct dev_pm_ops platform_dev_pm_ops = {
14741490
SET_RUNTIME_PM_OPS(pm_generic_runtime_suspend, pm_generic_runtime_resume, NULL)
14751491
USE_PLATFORM_PM_SLEEP_OPS
@@ -1484,6 +1500,7 @@ struct bus_type platform_bus_type = {
14841500
.remove = platform_remove,
14851501
.shutdown = platform_shutdown,
14861502
.dma_configure = platform_dma_configure,
1503+
.dma_cleanup = platform_dma_cleanup,
14871504
.pm = &platform_dev_pm_ops,
14881505
};
14891506
EXPORT_SYMBOL_GPL(platform_bus_type);

drivers/bus/fsl-mc/fsl-mc-bus.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/dma-mapping.h>
2222
#include <linux/acpi.h>
2323
#include <linux/iommu.h>
24+
#include <linux/dma-map-ops.h>
2425

2526
#include "fsl-mc-private.h"
2627

@@ -140,15 +141,33 @@ static int fsl_mc_dma_configure(struct device *dev)
140141
{
141142
struct device *dma_dev = dev;
142143
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
144+
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver);
143145
u32 input_id = mc_dev->icid;
146+
int ret;
144147

145148
while (dev_is_fsl_mc(dma_dev))
146149
dma_dev = dma_dev->parent;
147150

148151
if (dev_of_node(dma_dev))
149-
return of_dma_configure_id(dev, dma_dev->of_node, 0, &input_id);
152+
ret = of_dma_configure_id(dev, dma_dev->of_node, 0, &input_id);
153+
else
154+
ret = acpi_dma_configure_id(dev, DEV_DMA_COHERENT, &input_id);
155+
156+
if (!ret && !mc_drv->driver_managed_dma) {
157+
ret = iommu_device_use_default_domain(dev);
158+
if (ret)
159+
arch_teardown_dma_ops(dev);
160+
}
161+
162+
return ret;
163+
}
164+
165+
static void fsl_mc_dma_cleanup(struct device *dev)
166+
{
167+
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver);
150168

151-
return acpi_dma_configure_id(dev, DEV_DMA_COHERENT, &input_id);
169+
if (!mc_drv->driver_managed_dma)
170+
iommu_device_unuse_default_domain(dev);
152171
}
153172

154173
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
@@ -312,6 +331,7 @@ struct bus_type fsl_mc_bus_type = {
312331
.match = fsl_mc_bus_match,
313332
.uevent = fsl_mc_bus_uevent,
314333
.dma_configure = fsl_mc_dma_configure,
334+
.dma_cleanup = fsl_mc_dma_cleanup,
315335
.dev_groups = fsl_mc_dev_groups,
316336
.bus_groups = fsl_mc_bus_groups,
317337
};

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@
407407
/* IOMMU IVINFO */
408408
#define IOMMU_IVINFO_OFFSET 36
409409
#define IOMMU_IVINFO_EFRSUP BIT(0)
410+
#define IOMMU_IVINFO_DMA_REMAP BIT(1)
410411

411412
/* IOMMU Feature Reporting Field (for IVHD type 10h */
412413
#define IOMMU_FEAT_GASUP_SHIFT 6
@@ -449,6 +450,9 @@ extern struct irq_remap_table **irq_lookup_table;
449450
/* Interrupt remapping feature used? */
450451
extern bool amd_iommu_irq_remap;
451452

453+
/* IVRS indicates that pre-boot remapping was enabled */
454+
extern bool amdr_ivrs_remap_support;
455+
452456
/* kmem_cache to get tables with 128 byte alignement */
453457
extern struct kmem_cache *amd_iommu_irq_cache;
454458

0 commit comments

Comments
 (0)