Skip to content

Commit c7c4e13

Browse files
committed
Merge tag 'iommu-fixes-v6.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: - Intel VT-d Fixes: - Allocate local memory for PRQ page - Fix WARN_ON in iommu probe path - Fix wrong use of pasid config - AMD IOMMU Fixes: - Lock inversion fix - Log message severity fix - Disable SNP when v2 page-tables are used - Mediatek driver: - Fix module autoloading * tag 'iommu-fixes-v6.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/amd: Change log message severity iommu/vt-d: Fix WARN_ON in iommu probe path iommu/vt-d: Allocate local memory for page request queue iommu/vt-d: Fix wrong use of pasid config iommu: mtk: fix module autoloading iommu/amd: Do not enable SNP when V2 page table is enabled iommu/amd: Fix possible irq lock inversion dependency issue
2 parents b3812ff + b8246a2 commit c7c4e13

File tree

7 files changed

+31
-22
lines changed

7 files changed

+31
-22
lines changed

drivers/iommu/amd/init.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,28 +3232,29 @@ static void iommu_snp_enable(void)
32323232
return;
32333233
/*
32343234
* The SNP support requires that IOMMU must be enabled, and is
3235-
* not configured in the passthrough mode.
3235+
* configured with V1 page table (DTE[Mode] = 0 is not supported).
32363236
*/
32373237
if (no_iommu || iommu_default_passthrough()) {
3238-
pr_err("SNP: IOMMU disabled or configured in passthrough mode, SNP cannot be supported.\n");
3239-
cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
3240-
return;
3238+
pr_warn("SNP: IOMMU disabled or configured in passthrough mode, SNP cannot be supported.\n");
3239+
goto disable_snp;
3240+
}
3241+
3242+
if (amd_iommu_pgtable != AMD_IOMMU_V1) {
3243+
pr_warn("SNP: IOMMU is configured with V2 page table mode, SNP cannot be supported.\n");
3244+
goto disable_snp;
32413245
}
32423246

32433247
amd_iommu_snp_en = check_feature(FEATURE_SNP);
32443248
if (!amd_iommu_snp_en) {
3245-
pr_err("SNP: IOMMU SNP feature not enabled, SNP cannot be supported.\n");
3246-
cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
3247-
return;
3249+
pr_warn("SNP: IOMMU SNP feature not enabled, SNP cannot be supported.\n");
3250+
goto disable_snp;
32483251
}
32493252

32503253
pr_info("IOMMU SNP support enabled.\n");
3254+
return;
32513255

3252-
/* Enforce IOMMU v1 pagetable when SNP is enabled. */
3253-
if (amd_iommu_pgtable != AMD_IOMMU_V1) {
3254-
pr_warn("Forcing use of AMD IOMMU v1 page table due to SNP.\n");
3255-
amd_iommu_pgtable = AMD_IOMMU_V1;
3256-
}
3256+
disable_snp:
3257+
cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
32573258
#endif
32583259
}
32593260

drivers/iommu/amd/iommu.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,26 +1692,29 @@ int amd_iommu_complete_ppr(struct pci_dev *pdev, u32 pasid,
16921692

16931693
static u16 domain_id_alloc(void)
16941694
{
1695+
unsigned long flags;
16951696
int id;
16961697

1697-
spin_lock(&pd_bitmap_lock);
1698+
spin_lock_irqsave(&pd_bitmap_lock, flags);
16981699
id = find_first_zero_bit(amd_iommu_pd_alloc_bitmap, MAX_DOMAIN_ID);
16991700
BUG_ON(id == 0);
17001701
if (id > 0 && id < MAX_DOMAIN_ID)
17011702
__set_bit(id, amd_iommu_pd_alloc_bitmap);
17021703
else
17031704
id = 0;
1704-
spin_unlock(&pd_bitmap_lock);
1705+
spin_unlock_irqrestore(&pd_bitmap_lock, flags);
17051706

17061707
return id;
17071708
}
17081709

17091710
static void domain_id_free(int id)
17101711
{
1711-
spin_lock(&pd_bitmap_lock);
1712+
unsigned long flags;
1713+
1714+
spin_lock_irqsave(&pd_bitmap_lock, flags);
17121715
if (id > 0 && id < MAX_DOMAIN_ID)
17131716
__clear_bit(id, amd_iommu_pd_alloc_bitmap);
1714-
spin_unlock(&pd_bitmap_lock);
1717+
spin_unlock_irqrestore(&pd_bitmap_lock, flags);
17151718
}
17161719

17171720
static void free_gcr3_tbl_level1(u64 *tbl)

drivers/iommu/intel/iommu.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,9 +4299,11 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
42994299
}
43004300

43014301
dev_iommu_priv_set(dev, info);
4302-
ret = device_rbtree_insert(iommu, info);
4303-
if (ret)
4304-
goto free;
4302+
if (pdev && pci_ats_supported(pdev)) {
4303+
ret = device_rbtree_insert(iommu, info);
4304+
if (ret)
4305+
goto free;
4306+
}
43054307

43064308
if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) {
43074309
ret = intel_pasid_alloc_table(dev);
@@ -4336,7 +4338,8 @@ static void intel_iommu_release_device(struct device *dev)
43364338
struct intel_iommu *iommu = info->iommu;
43374339

43384340
mutex_lock(&iommu->iopf_lock);
4339-
device_rbtree_remove(info);
4341+
if (dev_is_pci(dev) && pci_ats_supported(to_pci_dev(dev)))
4342+
device_rbtree_remove(info);
43404343
mutex_unlock(&iommu->iopf_lock);
43414344

43424345
if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev) &&

drivers/iommu/intel/perfmon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static int iommu_pmu_assign_event(struct iommu_pmu *iommu_pmu,
438438
iommu_pmu_set_filter(domain, event->attr.config1,
439439
IOMMU_PMU_FILTER_DOMAIN, idx,
440440
event->attr.config1);
441-
iommu_pmu_set_filter(pasid, event->attr.config1,
441+
iommu_pmu_set_filter(pasid, event->attr.config2,
442442
IOMMU_PMU_FILTER_PASID, idx,
443443
event->attr.config1);
444444
iommu_pmu_set_filter(ats, event->attr.config2,

drivers/iommu/intel/svm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int intel_svm_enable_prq(struct intel_iommu *iommu)
6666
struct page *pages;
6767
int irq, ret;
6868

69-
pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, PRQ_ORDER);
69+
pages = alloc_pages_node(iommu->node, GFP_KERNEL | __GFP_ZERO, PRQ_ORDER);
7070
if (!pages) {
7171
pr_warn("IOMMU: %s: Failed to allocate page request queue\n",
7272
iommu->name);

drivers/iommu/mtk_iommu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,7 @@ static const struct of_device_id mtk_iommu_of_ids[] = {
17901790
{ .compatible = "mediatek,mt8365-m4u", .data = &mt8365_data},
17911791
{}
17921792
};
1793+
MODULE_DEVICE_TABLE(of, mtk_iommu_of_ids);
17931794

17941795
static struct platform_driver mtk_iommu_driver = {
17951796
.probe = mtk_iommu_probe,

drivers/iommu/mtk_iommu_v1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ static const struct of_device_id mtk_iommu_v1_of_ids[] = {
600600
{ .compatible = "mediatek,mt2701-m4u", },
601601
{}
602602
};
603+
MODULE_DEVICE_TABLE(of, mtk_iommu_v1_of_ids);
603604

604605
static const struct component_master_ops mtk_iommu_v1_com_ops = {
605606
.bind = mtk_iommu_v1_bind,

0 commit comments

Comments
 (0)