Skip to content

Commit d1f2b17

Browse files
committed
Merge tag 'iommu-updates-v4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull IOMMU updates from Joerg Roedel: - Debugfs support for the Intel VT-d driver. When enabled, it now also exposes some of its internal data structures to user-space for debugging purposes. - ARM-SMMU driver now uses the generic deferred flushing and fast-path iova allocation code. This is expected to be a major performance improvement, as this allocation path scales a lot better. - Support for r8a7744 in the Renesas iommu driver - Couple of minor fixes and improvements all over the place * tag 'iommu-updates-v4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (39 commits) iommu/arm-smmu-v3: Remove unnecessary wrapper function iommu/arm-smmu-v3: Add SPDX header iommu/amd: Add default branch in amd_iommu_capable() dt-bindings: iommu: ipmmu-vmsa: Add r8a7744 support iommu/amd: Move iommu_init_pci() to .init section iommu/arm-smmu: Support non-strict mode iommu/io-pgtable-arm-v7s: Add support for non-strict mode iommu/arm-smmu-v3: Add support for non-strict mode iommu/io-pgtable-arm: Add support for non-strict mode iommu: Add "iommu.strict" command line option iommu/dma: Add support for non-strict mode iommu/arm-smmu: Ensure that page-table updates are visible before TLBI iommu/arm-smmu-v3: Implement flush_iotlb_all hook iommu/arm-smmu-v3: Avoid back-to-back CMD_SYNC operations iommu/arm-smmu-v3: Fix unexpected CMD_SYNC timeout iommu/io-pgtable-arm: Fix race handling in split_blk_unmap() iommu/arm-smmu-v3: Fix a couple of minor comment typos iommu: Fix a typo iommu: Remove .domain_{get,set}_windows iommu: Tidy up window attributes ...
2 parents 18d0eae + 2f2fbfb commit d1f2b17

34 files changed

Lines changed: 986 additions & 356 deletions

‎Documentation/admin-guide/kernel-parameters.txt‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,6 +1759,18 @@
17591759
nobypass [PPC/POWERNV]
17601760
Disable IOMMU bypass, using IOMMU for PCI devices.
17611761

1762+
iommu.strict= [ARM64] Configure TLB invalidation behaviour
1763+
Format: { "0" | "1" }
1764+
0 - Lazy mode.
1765+
Request that DMA unmap operations use deferred
1766+
invalidation of hardware TLBs, for increased
1767+
throughput at the cost of reduced device isolation.
1768+
Will fall back to strict mode if not supported by
1769+
the relevant IOMMU driver.
1770+
1 - Strict mode (default).
1771+
DMA unmap operations invalidate IOMMU hardware TLBs
1772+
synchronously.
1773+
17621774
iommu.passthrough=
17631775
[ARM64] Configure DMA to bypass the IOMMU by default.
17641776
Format: { "0" | "1" }

‎Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Required Properties:
1212

1313
- "renesas,ipmmu-r8a73a4" for the R8A73A4 (R-Mobile APE6) IPMMU.
1414
- "renesas,ipmmu-r8a7743" for the R8A7743 (RZ/G1M) IPMMU.
15+
- "renesas,ipmmu-r8a7744" for the R8A7744 (RZ/G1N) IPMMU.
1516
- "renesas,ipmmu-r8a7745" for the R8A7745 (RZ/G1E) IPMMU.
1617
- "renesas,ipmmu-r8a7790" for the R8A7790 (R-Car H2) IPMMU.
1718
- "renesas,ipmmu-r8a7791" for the R8A7791 (R-Car M2-W) IPMMU.

‎Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ blocks that can be used to create functional hardware objects/devices
99
such as network interfaces, crypto accelerator instances, L2 switches,
1010
etc.
1111

12+
For an overview of the DPAA2 architecture and fsl-mc bus see:
13+
Documentation/networking/dpaa2/overview.rst
14+
15+
As described in the above overview, all DPAA2 objects in a DPRC share the
16+
same hardware "isolation context" and a 10-bit value called an ICID
17+
(isolation context id) is expressed by the hardware to identify
18+
the requester.
19+
20+
The generic 'iommus' property is insufficient to describe the relationship
21+
between ICIDs and IOMMUs, so an iommu-map property is used to define
22+
the set of possible ICIDs under a root DPRC and how they map to
23+
an IOMMU.
24+
25+
For generic IOMMU bindings, see
26+
Documentation/devicetree/bindings/iommu/iommu.txt.
27+
28+
For arm-smmu binding, see:
29+
Documentation/devicetree/bindings/iommu/arm,smmu.txt.
30+
1231
Required properties:
1332

1433
- compatible
@@ -88,14 +107,34 @@ Sub-nodes:
88107
Value type: <phandle>
89108
Definition: Specifies the phandle to the PHY device node associated
90109
with the this dpmac.
110+
Optional properties:
111+
112+
- iommu-map: Maps an ICID to an IOMMU and associated iommu-specifier
113+
data.
114+
115+
The property is an arbitrary number of tuples of
116+
(icid-base,iommu,iommu-base,length).
117+
118+
Any ICID i in the interval [icid-base, icid-base + length) is
119+
associated with the listed IOMMU, with the iommu-specifier
120+
(i - icid-base + iommu-base).
91121

92122
Example:
93123

124+
smmu: iommu@5000000 {
125+
compatible = "arm,mmu-500";
126+
#iommu-cells = <1>;
127+
stream-match-mask = <0x7C00>;
128+
...
129+
};
130+
94131
fsl_mc: fsl-mc@80c000000 {
95132
compatible = "fsl,qoriq-mc";
96133
reg = <0x00000008 0x0c000000 0 0x40>, /* MC portal base */
97134
<0x00000000 0x08340000 0 0x40000>; /* MC control reg */
98135
msi-parent = <&its>;
136+
/* define map for ICIDs 23-64 */
137+
iommu-map = <23 &smmu 23 41>;
99138
#address-cells = <3>;
100139
#size-cells = <1>;
101140

‎arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
#address-cells = <2>;
149149
#size-cells = <2>;
150150
ranges;
151+
dma-ranges = <0x0 0x0 0x0 0x0 0x10000 0x00000000>;
151152

152153
clockgen: clocking@1300000 {
153154
compatible = "fsl,ls2080a-clockgen";
@@ -321,6 +322,8 @@
321322
reg = <0x00000008 0x0c000000 0 0x40>, /* MC portal base */
322323
<0x00000000 0x08340000 0 0x40000>; /* MC control reg */
323324
msi-parent = <&its>;
325+
iommu-map = <0 &smmu 0 0>; /* This is fixed-up by u-boot */
326+
dma-coherent;
324327
#address-cells = <3>;
325328
#size-cells = <1>;
326329

@@ -424,6 +427,9 @@
424427
compatible = "arm,mmu-500";
425428
reg = <0 0x5000000 0 0x800000>;
426429
#global-interrupts = <12>;
430+
#iommu-cells = <1>;
431+
stream-match-mask = <0x7C00>;
432+
dma-coherent;
427433
interrupts = <0 13 4>, /* global secure fault */
428434
<0 14 4>, /* combined secure interrupt */
429435
<0 15 4>, /* global non-secure fault */
@@ -466,7 +472,6 @@
466472
<0 204 4>, <0 205 4>,
467473
<0 206 4>, <0 207 4>,
468474
<0 208 4>, <0 209 4>;
469-
mmu-masters = <&fsl_mc 0x300 0>;
470475
};
471476

472477
dspi: dspi@2100000 {

‎arch/arm64/mm/dma-mapping.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ static void __iommu_sync_single_for_cpu(struct device *dev,
712712
if (is_device_dma_coherent(dev))
713713
return;
714714

715-
phys = iommu_iova_to_phys(iommu_get_domain_for_dev(dev), dev_addr);
715+
phys = iommu_iova_to_phys(iommu_get_dma_domain(dev), dev_addr);
716716
__dma_unmap_area(phys_to_virt(phys), size, dir);
717717
}
718718

@@ -725,7 +725,7 @@ static void __iommu_sync_single_for_device(struct device *dev,
725725
if (is_device_dma_coherent(dev))
726726
return;
727727

728-
phys = iommu_iova_to_phys(iommu_get_domain_for_dev(dev), dev_addr);
728+
phys = iommu_iova_to_phys(iommu_get_dma_domain(dev), dev_addr);
729729
__dma_map_area(phys_to_virt(phys), size, dir);
730730
}
731731

@@ -738,9 +738,9 @@ static dma_addr_t __iommu_map_page(struct device *dev, struct page *page,
738738
int prot = dma_info_to_prot(dir, coherent, attrs);
739739
dma_addr_t dev_addr = iommu_dma_map_page(dev, page, offset, size, prot);
740740

741-
if (!iommu_dma_mapping_error(dev, dev_addr) &&
742-
(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
743-
__iommu_sync_single_for_device(dev, dev_addr, size, dir);
741+
if (!coherent && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
742+
!iommu_dma_mapping_error(dev, dev_addr))
743+
__dma_map_area(page_address(page) + offset, size, dir);
744744

745745
return dev_addr;
746746
}

‎arch/x86/include/asm/irq_remapping.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct vcpu_data {
4545

4646
#ifdef CONFIG_IRQ_REMAP
4747

48+
extern raw_spinlock_t irq_2_ir_lock;
49+
4850
extern bool irq_remapping_cap(enum irq_remap_cap cap);
4951
extern void set_irq_remapping_broken(void);
5052
extern int irq_remapping_prepare(void);

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ static int fsl_mc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
127127
return 0;
128128
}
129129

130+
static int fsl_mc_dma_configure(struct device *dev)
131+
{
132+
struct device *dma_dev = dev;
133+
134+
while (dev_is_fsl_mc(dma_dev))
135+
dma_dev = dma_dev->parent;
136+
137+
return of_dma_configure(dev, dma_dev->of_node, 0);
138+
}
139+
130140
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
131141
char *buf)
132142
{
@@ -148,6 +158,7 @@ struct bus_type fsl_mc_bus_type = {
148158
.name = "fsl-mc",
149159
.match = fsl_mc_bus_match,
150160
.uevent = fsl_mc_bus_uevent,
161+
.dma_configure = fsl_mc_dma_configure,
151162
.dev_groups = fsl_mc_dev_groups,
152163
};
153164
EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
@@ -621,6 +632,7 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
621632
mc_dev->icid = parent_mc_dev->icid;
622633
mc_dev->dma_mask = FSL_MC_DEFAULT_DMA_MASK;
623634
mc_dev->dev.dma_mask = &mc_dev->dma_mask;
635+
mc_dev->dev.coherent_dma_mask = mc_dev->dma_mask;
624636
dev_set_msi_domain(&mc_dev->dev,
625637
dev_get_msi_domain(&parent_mc_dev->dev));
626638
}
@@ -638,10 +650,6 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
638650
goto error_cleanup_dev;
639651
}
640652

641-
/* Objects are coherent, unless 'no shareability' flag set. */
642-
if (!(obj_desc->flags & FSL_MC_OBJ_FLAG_NO_MEM_SHAREABILITY))
643-
arch_setup_dma_ops(&mc_dev->dev, 0, 0, NULL, true);
644-
645653
/*
646654
* The device-specific probe callback will get invoked by device_add()
647655
*/

‎drivers/iommu/Kconfig‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,19 @@ config INTEL_IOMMU
186186
and include PCI device scope covered by these DMA
187187
remapping devices.
188188

189+
config INTEL_IOMMU_DEBUGFS
190+
bool "Export Intel IOMMU internals in Debugfs"
191+
depends on INTEL_IOMMU && IOMMU_DEBUGFS
192+
help
193+
!!!WARNING!!!
194+
195+
DO NOT ENABLE THIS OPTION UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!!!
196+
197+
Expose Intel IOMMU internals in Debugfs.
198+
199+
This option is -NOT- intended for production environments, and should
200+
only be enabled for debugging Intel IOMMU.
201+
189202
config INTEL_IOMMU_SVM
190203
bool "Support for Shared Virtual Memory with Intel IOMMU"
191204
depends on INTEL_IOMMU && X86

‎drivers/iommu/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ obj-$(CONFIG_ARM_SMMU) += arm-smmu.o
1717
obj-$(CONFIG_ARM_SMMU_V3) += arm-smmu-v3.o
1818
obj-$(CONFIG_DMAR_TABLE) += dmar.o
1919
obj-$(CONFIG_INTEL_IOMMU) += intel-iommu.o intel-pasid.o
20+
obj-$(CONFIG_INTEL_IOMMU_DEBUGFS) += intel-iommu-debugfs.o
2021
obj-$(CONFIG_INTEL_IOMMU_SVM) += intel-svm.o
2122
obj-$(CONFIG_IPMMU_VMSA) += ipmmu-vmsa.o
2223
obj-$(CONFIG_IRQ_REMAP) += intel_irq_remapping.o irq_remapping.o

‎drivers/iommu/amd_iommu.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,6 +3083,8 @@ static bool amd_iommu_capable(enum iommu_cap cap)
30833083
return (irq_remapping_enabled == 1);
30843084
case IOMMU_CAP_NOEXEC:
30853085
return false;
3086+
default:
3087+
break;
30863088
}
30873089

30883090
return false;

0 commit comments

Comments
 (0)