Skip to content

Commit 336b4da

Browse files
committed
Merge tag 'iommu-updates-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux
Pull iommu updates from Joerg Roedel: "Core iommufd dependencies from Jason: - Change the iommufd fault handle into an always present hwpt handle in the domain - Give iommufd its own SW_MSI implementation along with some IRQ layer rework - Improvements to the handle attach API Core fixes for probe-issues from Robin Intel VT-d changes: - Checking for SVA support in domain allocation and attach paths - Move PCI ATS and PRI configuration into probe paths - Fix a pentential hang on reboot -f - Miscellaneous cleanups AMD-Vi changes: - Support for up to 2k IRQs per PCI device function - Set of smaller fixes ARM-SMMU changes: - SMMUv2 devicetree binding updates for Qualcomm implementations (QCS8300 GPU and MSM8937) - Clean up SMMUv2 runtime PM implementation to help with wider rework of pm_runtime_put_autosuspend() Rockchip driver changes: - Driver adjustments for recent DT probing changes S390 IOMMU changes: - Support for IOMMU passthrough Apple Dart changes: - Driver adjustments to meet ISP device requirements - Null-ptr deref fix - Disable subpage protection for DART 1" * tag 'iommu-updates-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux: (54 commits) iommu/vt-d: Fix possible circular locking dependency iommu/vt-d: Don't clobber posted vCPU IRTE when host IRQ affinity changes iommu/vt-d: Put IRTE back into posted MSI mode if vCPU posting is disabled iommu: apple-dart: fix potential null pointer deref iommu/rockchip: Retire global dma_dev workaround iommu/rockchip: Register in a sensible order iommu/rockchip: Allocate per-device data sensibly iommu/mediatek-v1: Support COMPILE_TEST iommu/amd: Enable support for up to 2K interrupts per function iommu/amd: Rename DTE_INTTABLEN* and MAX_IRQS_PER_TABLE macro iommu/amd: Replace slab cache allocator with page allocator iommu/amd: Introduce generic function to set multibit feature value iommu: Don't warn prematurely about dodgy probes iommu/arm-smmu: Set rpm auto_suspend once during probe dt-bindings: arm-smmu: Document QCS8300 GPU SMMU iommu: Get DT/ACPI parsing into the proper probe path iommu: Keep dev->iommu state consistent iommu: Resolve ops in iommu_init_device() iommu: Handle race with default domain setup iommu: Unexport iommu_fwspec_free() ...
2 parents 2e3fcbc + 22df63a commit 336b4da

Some content is hidden

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

55 files changed

+1091
-860
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ properties:
9090
- enum:
9191
- qcom,qcm2290-smmu-500
9292
- qcom,qcs615-smmu-500
93+
- qcom,qcs8300-smmu-500
9394
- qcom,sa8255p-smmu-500
9495
- qcom,sa8775p-smmu-500
9596
- qcom,sar2130p-smmu-500
@@ -397,6 +398,7 @@ allOf:
397398
compatible:
398399
contains:
399400
enum:
401+
- qcom,qcs8300-smmu-500
400402
- qcom,sa8775p-smmu-500
401403
- qcom,sc7280-smmu-500
402404
- qcom,sc8280xp-smmu-500
@@ -581,7 +583,6 @@ allOf:
581583
- cavium,smmu-v2
582584
- marvell,ap806-smmu-500
583585
- nvidia,smmu-500
584-
- qcom,qcs8300-smmu-500
585586
- qcom,qdu1000-smmu-500
586587
- qcom,sa8255p-smmu-500
587588
- qcom,sc7180-smmu-500

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ properties:
2222
- enum:
2323
- qcom,msm8916-iommu
2424
- qcom,msm8917-iommu
25+
- qcom,msm8937-iommu
2526
- qcom,msm8953-iommu
2627
- const: qcom,msm-iommu-v1
2728
- items:

arch/s390/include/asm/pci.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ struct zpci_dev {
144144
u8 util_str_avail : 1;
145145
u8 irqs_registered : 1;
146146
u8 tid_avail : 1;
147-
u8 reserved : 1;
147+
u8 rtr_avail : 1; /* Relaxed translation allowed */
148148
unsigned int devfn; /* DEVFN part of the RID*/
149149

150150
u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */
@@ -217,6 +217,7 @@ extern struct airq_iv *zpci_aif_sbv;
217217
struct zpci_dev *zpci_create_device(u32 fid, u32 fh, enum zpci_state state);
218218
int zpci_add_device(struct zpci_dev *zdev);
219219
int zpci_enable_device(struct zpci_dev *);
220+
int zpci_reenable_device(struct zpci_dev *zdev);
220221
int zpci_disable_device(struct zpci_dev *);
221222
int zpci_scan_configured_device(struct zpci_dev *zdev, u32 fh);
222223
int zpci_deconfigure_device(struct zpci_dev *zdev);
@@ -245,6 +246,7 @@ void update_uid_checking(bool new);
245246
/* IOMMU Interface */
246247
int zpci_init_iommu(struct zpci_dev *zdev);
247248
void zpci_destroy_iommu(struct zpci_dev *zdev);
249+
int zpci_iommu_register_ioat(struct zpci_dev *zdev, u8 *status);
248250

249251
#ifdef CONFIG_PCI
250252
static inline bool zpci_use_mio(struct zpci_dev *zdev)

arch/s390/include/asm/pci_clp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ struct clp_rsp_query_pci_grp {
156156
u16 : 4;
157157
u16 noi : 12; /* number of interrupts */
158158
u8 version;
159-
u8 : 6;
159+
u8 : 2;
160+
u8 rtr : 1; /* Relaxed translation requirement */
161+
u8 : 3;
160162
u8 frame : 1;
161163
u8 refresh : 1; /* TLB refresh mode */
162164
u16 : 3;

arch/s390/kvm/pci.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ static void kvm_s390_pci_dev_release(struct zpci_dev *zdev)
433433
static int kvm_s390_pci_register_kvm(void *opaque, struct kvm *kvm)
434434
{
435435
struct zpci_dev *zdev = opaque;
436-
u8 status;
437436
int rc;
438437

439438
if (!zdev)
@@ -480,13 +479,7 @@ static int kvm_s390_pci_register_kvm(void *opaque, struct kvm *kvm)
480479
*/
481480
zdev->gisa = (u32)virt_to_phys(&kvm->arch.sie_page2->gisa);
482481

483-
rc = zpci_enable_device(zdev);
484-
if (rc)
485-
goto clear_gisa;
486-
487-
/* Re-register the IOMMU that was already created */
488-
rc = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma,
489-
virt_to_phys(zdev->dma_table), &status);
482+
rc = zpci_reenable_device(zdev);
490483
if (rc)
491484
goto clear_gisa;
492485

@@ -516,7 +509,6 @@ static void kvm_s390_pci_unregister_kvm(void *opaque)
516509
{
517510
struct zpci_dev *zdev = opaque;
518511
struct kvm *kvm;
519-
u8 status;
520512

521513
if (!zdev)
522514
return;
@@ -550,12 +542,7 @@ static void kvm_s390_pci_unregister_kvm(void *opaque)
550542
goto out;
551543
}
552544

553-
if (zpci_enable_device(zdev))
554-
goto out;
555-
556-
/* Re-register the IOMMU that was already created */
557-
zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma,
558-
virt_to_phys(zdev->dma_table), &status);
545+
zpci_reenable_device(zdev);
559546

560547
out:
561548
spin_lock(&kvm->arch.kzdev_list_lock);

arch/s390/pci/pci.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,13 @@ int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas,
124124
struct zpci_fib fib = {0};
125125
u8 cc;
126126

127-
WARN_ON_ONCE(iota & 0x3fff);
128127
fib.pba = base;
129128
/* Work around off by one in ISM virt device */
130129
if (zdev->pft == PCI_FUNC_TYPE_ISM && limit > base)
131130
fib.pal = limit + (1 << 12);
132131
else
133132
fib.pal = limit;
134-
fib.iota = iota | ZPCI_IOTA_RTTO_FLAG;
133+
fib.iota = iota;
135134
fib.gd = zdev->gisa;
136135
cc = zpci_mod_fc(req, &fib, status);
137136
if (cc)
@@ -690,6 +689,23 @@ int zpci_enable_device(struct zpci_dev *zdev)
690689
}
691690
EXPORT_SYMBOL_GPL(zpci_enable_device);
692691

692+
int zpci_reenable_device(struct zpci_dev *zdev)
693+
{
694+
u8 status;
695+
int rc;
696+
697+
rc = zpci_enable_device(zdev);
698+
if (rc)
699+
return rc;
700+
701+
rc = zpci_iommu_register_ioat(zdev, &status);
702+
if (rc)
703+
zpci_disable_device(zdev);
704+
705+
return rc;
706+
}
707+
EXPORT_SYMBOL_GPL(zpci_reenable_device);
708+
693709
int zpci_disable_device(struct zpci_dev *zdev)
694710
{
695711
u32 fh = zdev->fh;
@@ -739,7 +755,6 @@ EXPORT_SYMBOL_GPL(zpci_disable_device);
739755
*/
740756
int zpci_hot_reset_device(struct zpci_dev *zdev)
741757
{
742-
u8 status;
743758
int rc;
744759

745760
lockdep_assert_held(&zdev->state_lock);
@@ -758,19 +773,9 @@ int zpci_hot_reset_device(struct zpci_dev *zdev)
758773
return rc;
759774
}
760775

761-
rc = zpci_enable_device(zdev);
762-
if (rc)
763-
return rc;
764-
765-
if (zdev->dma_table)
766-
rc = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma,
767-
virt_to_phys(zdev->dma_table), &status);
768-
if (rc) {
769-
zpci_disable_device(zdev);
770-
return rc;
771-
}
776+
rc = zpci_reenable_device(zdev);
772777

773-
return 0;
778+
return rc;
774779
}
775780

776781
/**

arch/s390/pci/pci_bus.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/jump_label.h>
2020
#include <linux/pci.h>
2121
#include <linux/printk.h>
22+
#include <linux/dma-direct.h>
2223

2324
#include <asm/pci_clp.h>
2425
#include <asm/pci_dma.h>
@@ -283,10 +284,34 @@ static struct zpci_bus *zpci_bus_alloc(int topo, bool topo_is_tid)
283284
return zbus;
284285
}
285286

287+
static void pci_dma_range_setup(struct pci_dev *pdev)
288+
{
289+
struct zpci_dev *zdev = to_zpci(pdev);
290+
struct bus_dma_region *map;
291+
u64 aligned_end;
292+
293+
map = kzalloc(sizeof(*map), GFP_KERNEL);
294+
if (!map)
295+
return;
296+
297+
map->cpu_start = 0;
298+
map->dma_start = PAGE_ALIGN(zdev->start_dma);
299+
aligned_end = PAGE_ALIGN_DOWN(zdev->end_dma + 1);
300+
if (aligned_end >= map->dma_start)
301+
map->size = aligned_end - map->dma_start;
302+
else
303+
map->size = 0;
304+
WARN_ON_ONCE(map->size == 0);
305+
306+
pdev->dev.dma_range_map = map;
307+
}
308+
286309
void pcibios_bus_add_device(struct pci_dev *pdev)
287310
{
288311
struct zpci_dev *zdev = to_zpci(pdev);
289312

313+
pci_dma_range_setup(pdev);
314+
290315
/*
291316
* With pdev->no_vf_scan the common PCI probing code does not
292317
* perform PF/VF linking.

arch/s390/pci/pci_clp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static void clp_store_query_pci_fngrp(struct zpci_dev *zdev,
112112
zdev->version = response->version;
113113
zdev->maxstbl = response->maxstbl;
114114
zdev->dtsm = response->dtsm;
115+
zdev->rtr_avail = response->rtr;
115116

116117
switch (response->version) {
117118
case 1:

arch/s390/pci/pci_sysfs.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ static DEVICE_ATTR_RO(mio_enabled);
5252

5353
static int _do_recover(struct pci_dev *pdev, struct zpci_dev *zdev)
5454
{
55-
u8 status;
5655
int ret;
5756

5857
pci_stop_and_remove_bus_device(pdev);
@@ -70,16 +69,8 @@ static int _do_recover(struct pci_dev *pdev, struct zpci_dev *zdev)
7069
return ret;
7170
}
7271

73-
ret = zpci_enable_device(zdev);
74-
if (ret)
75-
return ret;
72+
ret = zpci_reenable_device(zdev);
7673

77-
if (zdev->dma_table) {
78-
ret = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma,
79-
virt_to_phys(zdev->dma_table), &status);
80-
if (ret)
81-
zpci_disable_device(zdev);
82-
}
8374
return ret;
8475
}
8576

drivers/acpi/arm64/dma.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ void acpi_arch_dma_setup(struct device *dev)
2626
else
2727
end = (1ULL << 32) - 1;
2828

29+
if (dev->dma_range_map) {
30+
dev_dbg(dev, "dma_range_map already set\n");
31+
return;
32+
}
33+
2934
ret = acpi_dma_get_range(dev, &map);
3035
if (!ret && map) {
3136
end = dma_range_map_max(map);

drivers/acpi/scan.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,13 +1632,6 @@ static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
16321632
err = viot_iommu_configure(dev);
16331633
mutex_unlock(&iommu_probe_device_lock);
16341634

1635-
/*
1636-
* If we have reason to believe the IOMMU driver missed the initial
1637-
* iommu_probe_device() call for dev, replay it to get things in order.
1638-
*/
1639-
if (!err && dev->bus)
1640-
err = iommu_probe_device(dev);
1641-
16421635
return err;
16431636
}
16441637

drivers/amba/bus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ static int amba_dma_configure(struct device *dev)
364364
ret = acpi_dma_configure(dev, attr);
365365
}
366366

367-
if (!ret && !drv->driver_managed_dma) {
367+
/* @drv may not be valid when we're called from the IOMMU layer */
368+
if (!ret && dev->driver && !drv->driver_managed_dma) {
368369
ret = iommu_device_use_default_domain(dev);
369370
if (ret)
370371
arch_teardown_dma_ops(dev);

drivers/base/platform.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,8 @@ static int platform_dma_configure(struct device *dev)
14511451
attr = acpi_get_dma_attr(to_acpi_device_node(fwnode));
14521452
ret = acpi_dma_configure(dev, attr);
14531453
}
1454-
if (ret || drv->driver_managed_dma)
1454+
/* @drv may not be valid when we're called from the IOMMU layer */
1455+
if (ret || !dev->driver || drv->driver_managed_dma)
14551456
return ret;
14561457

14571458
ret = iommu_device_use_default_domain(dev);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ static int fsl_mc_dma_configure(struct device *dev)
153153
else
154154
ret = acpi_dma_configure_id(dev, DEV_DMA_COHERENT, &input_id);
155155

156-
if (!ret && !mc_drv->driver_managed_dma) {
156+
/* @mc_drv may not be valid when we're called from the IOMMU layer */
157+
if (!ret && dev->driver && !mc_drv->driver_managed_dma) {
157158
ret = iommu_device_use_default_domain(dev);
158159
if (ret)
159160
arch_teardown_dma_ops(dev);

drivers/cdx/cdx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ static int cdx_dma_configure(struct device *dev)
360360
return ret;
361361
}
362362

363-
if (!ret && !cdx_drv->driver_managed_dma) {
363+
/* @cdx_drv may not be valid when we're called from the IOMMU layer */
364+
if (!ret && dev->driver && !cdx_drv->driver_managed_dma) {
364365
ret = iommu_device_use_default_domain(dev);
365366
if (ret)
366367
arch_teardown_dma_ops(dev);

drivers/iommu/Kconfig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ config IOMMU_DMA
154154
select DMA_OPS_HELPERS
155155
select IOMMU_API
156156
select IOMMU_IOVA
157-
select IRQ_MSI_IOMMU
158157
select NEED_SG_DMA_LENGTH
159158
select NEED_SG_DMA_FLAGS if SWIOTLB
160159

@@ -483,8 +482,7 @@ config MTK_IOMMU
483482

484483
config MTK_IOMMU_V1
485484
tristate "MediaTek IOMMU Version 1 (M4U gen1) Support"
486-
depends on ARM
487-
depends on ARCH_MEDIATEK || COMPILE_TEST
485+
depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST
488486
select ARM_DMA_USE_IOMMU
489487
select IOMMU_API
490488
select MEMORY

drivers/iommu/amd/amd_iommu.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ extern unsigned long amd_iommu_pgsize_bitmap;
4747
/* Protection domain ops */
4848
void amd_iommu_init_identity_domain(void);
4949
struct protection_domain *protection_domain_alloc(void);
50-
void protection_domain_free(struct protection_domain *domain);
5150
struct iommu_domain *amd_iommu_domain_alloc_sva(struct device *dev,
5251
struct mm_struct *mm);
5352
void amd_iommu_domain_free(struct iommu_domain *dom);
@@ -176,12 +175,11 @@ void amd_iommu_apply_ivrs_quirks(void);
176175
#else
177176
static inline void amd_iommu_apply_ivrs_quirks(void) { }
178177
#endif
178+
struct dev_table_entry *amd_iommu_get_ivhd_dte_flags(u16 segid, u16 devid);
179179

180180
void amd_iommu_domain_set_pgtable(struct protection_domain *domain,
181181
u64 *root, int mode);
182182
struct dev_table_entry *get_dev_table(struct amd_iommu *iommu);
183-
184-
#endif
185-
186-
struct dev_table_entry *amd_iommu_get_ivhd_dte_flags(u16 segid, u16 devid);
187183
struct iommu_dev_data *search_dev_data(struct amd_iommu *iommu, u16 devid);
184+
185+
#endif /* AMD_IOMMU_H */

0 commit comments

Comments
 (0)