Skip to content

Commit 023e62c

Browse files
committed
Merge tag 'iommu-fixes-v6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux
Pull iommu fixes from Joerg Roedel: - Fix two crashes, one in core code and a NULL-ptr dereference in the Mediatek IOMMU driver - Dma_ops cleanup fix for core code - Two fixes for Intel VT-d driver: - Fix posted MSI issue when users change cpu affinity - Remove invalid set_dma_ops() call in the iommu driver - Warning fix for Tegra IOMMU driver - Suspend/Resume fix for Exynos IOMMU driver - Probe failure fix for Renesas IOMMU driver - Cosmetic fix * tag 'iommu-fixes-v6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux: iommu/tegra241-cmdqv: Fix warnings due to dmam_free_coherent() iommu: remove unneeded semicolon iommu/mediatek: Fix NULL pointer deference in mtk_iommu_device_group iommu/exynos: Fix suspend/resume with IDENTITY domain iommu/ipmmu-vmsa: Register in a sensible order iommu: Clear iommu-dma ops on cleanup iommu/vt-d: Remove an unnecessary call set_dma_ops() iommu/vt-d: Wire up irq_ack() to irq_move_irq() for posted MSIs iommu: Fix crash in report_iommu_fault()
2 parents c86e5b5 + 767e220 commit 023e62c

File tree

8 files changed

+52
-77
lines changed

8 files changed

+52
-77
lines changed

drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -487,17 +487,6 @@ static int tegra241_cmdqv_hw_reset(struct arm_smmu_device *smmu)
487487

488488
/* VCMDQ Resource Helpers */
489489

490-
static void tegra241_vcmdq_free_smmu_cmdq(struct tegra241_vcmdq *vcmdq)
491-
{
492-
struct arm_smmu_queue *q = &vcmdq->cmdq.q;
493-
size_t nents = 1 << q->llq.max_n_shift;
494-
size_t qsz = nents << CMDQ_ENT_SZ_SHIFT;
495-
496-
if (!q->base)
497-
return;
498-
dmam_free_coherent(vcmdq->cmdqv->smmu.dev, qsz, q->base, q->base_dma);
499-
}
500-
501490
static int tegra241_vcmdq_alloc_smmu_cmdq(struct tegra241_vcmdq *vcmdq)
502491
{
503492
struct arm_smmu_device *smmu = &vcmdq->cmdqv->smmu;
@@ -560,7 +549,8 @@ static void tegra241_vintf_free_lvcmdq(struct tegra241_vintf *vintf, u16 lidx)
560549
struct tegra241_vcmdq *vcmdq = vintf->lvcmdqs[lidx];
561550
char header[64];
562551

563-
tegra241_vcmdq_free_smmu_cmdq(vcmdq);
552+
/* Note that the lvcmdq queue memory space is managed by devres */
553+
564554
tegra241_vintf_deinit_lvcmdq(vintf, lidx);
565555

566556
dev_dbg(vintf->cmdqv->dev,
@@ -768,13 +758,13 @@ static int tegra241_cmdqv_init_structures(struct arm_smmu_device *smmu)
768758

769759
vintf = kzalloc(sizeof(*vintf), GFP_KERNEL);
770760
if (!vintf)
771-
goto out_fallback;
761+
return -ENOMEM;
772762

773763
/* Init VINTF0 for in-kernel use */
774764
ret = tegra241_cmdqv_init_vintf(cmdqv, 0, vintf);
775765
if (ret) {
776766
dev_err(cmdqv->dev, "failed to init vintf0: %d\n", ret);
777-
goto free_vintf;
767+
return ret;
778768
}
779769

780770
/* Preallocate logical VCMDQs to VINTF0 */
@@ -783,24 +773,12 @@ static int tegra241_cmdqv_init_structures(struct arm_smmu_device *smmu)
783773

784774
vcmdq = tegra241_vintf_alloc_lvcmdq(vintf, lidx);
785775
if (IS_ERR(vcmdq))
786-
goto free_lvcmdq;
776+
return PTR_ERR(vcmdq);
787777
}
788778

789779
/* Now, we are ready to run all the impl ops */
790780
smmu->impl_ops = &tegra241_cmdqv_impl_ops;
791781
return 0;
792-
793-
free_lvcmdq:
794-
for (lidx--; lidx >= 0; lidx--)
795-
tegra241_vintf_free_lvcmdq(vintf, lidx);
796-
tegra241_cmdqv_deinit_vintf(cmdqv, vintf->idx);
797-
free_vintf:
798-
kfree(vintf);
799-
out_fallback:
800-
dev_info(smmu->impl_dev, "Falling back to standard SMMU CMDQ\n");
801-
smmu->options &= ~ARM_SMMU_OPT_TEGRA241_CMDQV;
802-
tegra241_cmdqv_remove(smmu);
803-
return 0;
804782
}
805783

806784
#ifdef CONFIG_IOMMU_DEBUGFS

drivers/iommu/dma-iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ static size_t cookie_msi_granule(const struct iommu_domain *domain)
17541754
return PAGE_SIZE;
17551755
default:
17561756
BUG();
1757-
};
1757+
}
17581758
}
17591759

17601760
static struct list_head *cookie_msi_pages(const struct iommu_domain *domain)
@@ -1766,7 +1766,7 @@ static struct list_head *cookie_msi_pages(const struct iommu_domain *domain)
17661766
return &domain->msi_cookie->msi_page_list;
17671767
default:
17681768
BUG();
1769-
};
1769+
}
17701770
}
17711771

17721772
static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,

drivers/iommu/exynos-iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ static int __maybe_unused exynos_sysmmu_suspend(struct device *dev)
832832
struct exynos_iommu_owner *owner = dev_iommu_priv_get(master);
833833

834834
mutex_lock(&owner->rpm_lock);
835-
if (&data->domain->domain != &exynos_identity_domain) {
835+
if (data->domain) {
836836
dev_dbg(data->sysmmu, "saving state\n");
837837
__sysmmu_disable(data);
838838
}
@@ -850,7 +850,7 @@ static int __maybe_unused exynos_sysmmu_resume(struct device *dev)
850850
struct exynos_iommu_owner *owner = dev_iommu_priv_get(master);
851851

852852
mutex_lock(&owner->rpm_lock);
853-
if (&data->domain->domain != &exynos_identity_domain) {
853+
if (data->domain) {
854854
dev_dbg(data->sysmmu, "restoring state\n");
855855
__sysmmu_enable(data);
856856
}

drivers/iommu/intel/iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3835,7 +3835,6 @@ static void intel_iommu_release_device(struct device *dev)
38353835
intel_pasid_free_table(dev);
38363836
intel_iommu_debugfs_remove_dev(info);
38373837
kfree(info);
3838-
set_dma_ops(dev, NULL);
38393838
}
38403839

38413840
static void intel_iommu_get_resv_regions(struct device *device,

drivers/iommu/intel/irq_remapping.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,43 +1287,44 @@ static struct irq_chip intel_ir_chip = {
12871287
};
12881288

12891289
/*
1290-
* With posted MSIs, all vectors are multiplexed into a single notification
1291-
* vector. Devices MSIs are then dispatched in a demux loop where
1292-
* EOIs can be coalesced as well.
1290+
* With posted MSIs, the MSI vectors are multiplexed into a single notification
1291+
* vector, and only the notification vector is sent to the APIC IRR. Device
1292+
* MSIs are then dispatched in a demux loop that harvests the MSIs from the
1293+
* CPU's Posted Interrupt Request bitmap. I.e. Posted MSIs never get sent to
1294+
* the APIC IRR, and thus do not need an EOI. The notification handler instead
1295+
* performs a single EOI after processing the PIR.
12931296
*
1294-
* "INTEL-IR-POST" IRQ chip does not do EOI on ACK, thus the dummy irq_ack()
1295-
* function. Instead EOI is performed by the posted interrupt notification
1296-
* handler.
1297+
* Note! Pending SMP/CPU affinity changes, which are per MSI, must still be
1298+
* honored, only the APIC EOI is omitted.
12971299
*
12981300
* For the example below, 3 MSIs are coalesced into one CPU notification. Only
1299-
* one apic_eoi() is needed.
1301+
* one apic_eoi() is needed, but each MSI needs to process pending changes to
1302+
* its CPU affinity.
13001303
*
13011304
* __sysvec_posted_msi_notification()
13021305
* irq_enter();
13031306
* handle_edge_irq()
13041307
* irq_chip_ack_parent()
1305-
* dummy(); // No EOI
1308+
* irq_move_irq(); // No EOI
13061309
* handle_irq_event()
13071310
* driver_handler()
13081311
* handle_edge_irq()
13091312
* irq_chip_ack_parent()
1310-
* dummy(); // No EOI
1313+
* irq_move_irq(); // No EOI
13111314
* handle_irq_event()
13121315
* driver_handler()
13131316
* handle_edge_irq()
13141317
* irq_chip_ack_parent()
1315-
* dummy(); // No EOI
1318+
* irq_move_irq(); // No EOI
13161319
* handle_irq_event()
13171320
* driver_handler()
13181321
* apic_eoi()
13191322
* irq_exit()
1323+
*
13201324
*/
1321-
1322-
static void dummy_ack(struct irq_data *d) { }
1323-
13241325
static struct irq_chip intel_ir_chip_post_msi = {
13251326
.name = "INTEL-IR-POST",
1326-
.irq_ack = dummy_ack,
1327+
.irq_ack = irq_move_irq,
13271328
.irq_set_affinity = intel_ir_set_affinity,
13281329
.irq_compose_msi_msg = intel_ir_compose_msi_msg,
13291330
.irq_set_vcpu_affinity = intel_ir_set_vcpu_affinity,

drivers/iommu/iommu.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,9 @@ static void iommu_deinit_device(struct device *dev)
538538
dev->iommu_group = NULL;
539539
module_put(ops->owner);
540540
dev_iommu_free(dev);
541+
#ifdef CONFIG_IOMMU_DMA
542+
dev->dma_iommu = false;
543+
#endif
541544
}
542545

543546
static struct iommu_domain *pasid_array_entry_to_domain(void *entry)
@@ -2717,7 +2720,8 @@ int report_iommu_fault(struct iommu_domain *domain, struct device *dev,
27172720
* if upper layers showed interest and installed a fault handler,
27182721
* invoke it.
27192722
*/
2720-
if (domain->handler)
2723+
if (domain->cookie_type == IOMMU_COOKIE_FAULT_HANDLER &&
2724+
domain->handler)
27212725
ret = domain->handler(domain, dev, iova, flags,
27222726
domain->handler_token);
27232727

drivers/iommu/ipmmu-vmsa.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,31 +1081,24 @@ static int ipmmu_probe(struct platform_device *pdev)
10811081
}
10821082
}
10831083

1084+
platform_set_drvdata(pdev, mmu);
10841085
/*
10851086
* Register the IPMMU to the IOMMU subsystem in the following cases:
10861087
* - R-Car Gen2 IPMMU (all devices registered)
10871088
* - R-Car Gen3 IPMMU (leaf devices only - skip root IPMMU-MM device)
10881089
*/
1089-
if (!mmu->features->has_cache_leaf_nodes || !ipmmu_is_root(mmu)) {
1090-
ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL,
1091-
dev_name(&pdev->dev));
1092-
if (ret)
1093-
return ret;
1094-
1095-
ret = iommu_device_register(&mmu->iommu, &ipmmu_ops, &pdev->dev);
1096-
if (ret)
1097-
return ret;
1098-
}
1090+
if (mmu->features->has_cache_leaf_nodes && ipmmu_is_root(mmu))
1091+
return 0;
10991092

1100-
/*
1101-
* We can't create the ARM mapping here as it requires the bus to have
1102-
* an IOMMU, which only happens when bus_set_iommu() is called in
1103-
* ipmmu_init() after the probe function returns.
1104-
*/
1093+
ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
1094+
if (ret)
1095+
return ret;
11051096

1106-
platform_set_drvdata(pdev, mmu);
1097+
ret = iommu_device_register(&mmu->iommu, &ipmmu_ops, &pdev->dev);
1098+
if (ret)
1099+
iommu_device_sysfs_remove(&mmu->iommu);
11071100

1108-
return 0;
1101+
return ret;
11091102
}
11101103

11111104
static void ipmmu_remove(struct platform_device *pdev)

drivers/iommu/mtk_iommu.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,15 +1372,6 @@ static int mtk_iommu_probe(struct platform_device *pdev)
13721372
platform_set_drvdata(pdev, data);
13731373
mutex_init(&data->mutex);
13741374

1375-
ret = iommu_device_sysfs_add(&data->iommu, dev, NULL,
1376-
"mtk-iommu.%pa", &ioaddr);
1377-
if (ret)
1378-
goto out_link_remove;
1379-
1380-
ret = iommu_device_register(&data->iommu, &mtk_iommu_ops, dev);
1381-
if (ret)
1382-
goto out_sysfs_remove;
1383-
13841375
if (MTK_IOMMU_HAS_FLAG(data->plat_data, SHARE_PGTABLE)) {
13851376
list_add_tail(&data->list, data->plat_data->hw_list);
13861377
data->hw_list = data->plat_data->hw_list;
@@ -1390,19 +1381,28 @@ static int mtk_iommu_probe(struct platform_device *pdev)
13901381
data->hw_list = &data->hw_list_head;
13911382
}
13921383

1384+
ret = iommu_device_sysfs_add(&data->iommu, dev, NULL,
1385+
"mtk-iommu.%pa", &ioaddr);
1386+
if (ret)
1387+
goto out_list_del;
1388+
1389+
ret = iommu_device_register(&data->iommu, &mtk_iommu_ops, dev);
1390+
if (ret)
1391+
goto out_sysfs_remove;
1392+
13931393
if (MTK_IOMMU_IS_TYPE(data->plat_data, MTK_IOMMU_TYPE_MM)) {
13941394
ret = component_master_add_with_match(dev, &mtk_iommu_com_ops, match);
13951395
if (ret)
1396-
goto out_list_del;
1396+
goto out_device_unregister;
13971397
}
13981398
return ret;
13991399

1400-
out_list_del:
1401-
list_del(&data->list);
1400+
out_device_unregister:
14021401
iommu_device_unregister(&data->iommu);
14031402
out_sysfs_remove:
14041403
iommu_device_sysfs_remove(&data->iommu);
1405-
out_link_remove:
1404+
out_list_del:
1405+
list_del(&data->list);
14061406
if (MTK_IOMMU_IS_TYPE(data->plat_data, MTK_IOMMU_TYPE_MM))
14071407
device_link_remove(data->smicomm_dev, dev);
14081408
out_runtime_disable:

0 commit comments

Comments
 (0)