Skip to content

Commit 06f7db9

Browse files
committed
Merge tag 'iommu-fixes-v6.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: "Two fixes for Intel VT-d: - Check the right capability bit for 5-level page table support. - Revert a previous fix which caused a regression with Thunderbolt devices" * tag 'iommu-fixes-v6.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/vt-d: Check correct capability for sagaw determination Revert "iommu/vt-d: Fix possible recursive locking in intel_iommu_init()"
2 parents 5ce9410 + 1548978 commit 06f7db9

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

drivers/iommu/intel/dmar.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,13 +2349,6 @@ static int dmar_device_hotplug(acpi_handle handle, bool insert)
23492349
if (!dmar_in_use())
23502350
return 0;
23512351

2352-
/*
2353-
* It's unlikely that any I/O board is hot added before the IOMMU
2354-
* subsystem is initialized.
2355-
*/
2356-
if (IS_ENABLED(CONFIG_INTEL_IOMMU) && !intel_iommu_enabled)
2357-
return -EOPNOTSUPP;
2358-
23592352
if (dmar_detect_dsm(handle, DMAR_DSM_FUNC_DRHD)) {
23602353
tmp = handle;
23612354
} else {

drivers/iommu/intel/iommu.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static unsigned long __iommu_calculate_sagaw(struct intel_iommu *iommu)
399399
{
400400
unsigned long fl_sagaw, sl_sagaw;
401401

402-
fl_sagaw = BIT(2) | (cap_fl1gp_support(iommu->cap) ? BIT(3) : 0);
402+
fl_sagaw = BIT(2) | (cap_5lp_support(iommu->cap) ? BIT(3) : 0);
403403
sl_sagaw = cap_sagaw(iommu->cap);
404404

405405
/* Second level only. */
@@ -3019,7 +3019,13 @@ static int __init init_dmars(void)
30193019

30203020
#ifdef CONFIG_INTEL_IOMMU_SVM
30213021
if (pasid_supported(iommu) && ecap_prs(iommu->ecap)) {
3022+
/*
3023+
* Call dmar_alloc_hwirq() with dmar_global_lock held,
3024+
* could cause possible lock race condition.
3025+
*/
3026+
up_write(&dmar_global_lock);
30223027
ret = intel_svm_enable_prq(iommu);
3028+
down_write(&dmar_global_lock);
30233029
if (ret)
30243030
goto free_iommu;
30253031
}
@@ -3932,6 +3938,7 @@ int __init intel_iommu_init(void)
39323938
force_on = (!intel_iommu_tboot_noforce && tboot_force_iommu()) ||
39333939
platform_optin_force_iommu();
39343940

3941+
down_write(&dmar_global_lock);
39353942
if (dmar_table_init()) {
39363943
if (force_on)
39373944
panic("tboot: Failed to initialize DMAR table\n");
@@ -3944,6 +3951,16 @@ int __init intel_iommu_init(void)
39443951
goto out_free_dmar;
39453952
}
39463953

3954+
up_write(&dmar_global_lock);
3955+
3956+
/*
3957+
* The bus notifier takes the dmar_global_lock, so lockdep will
3958+
* complain later when we register it under the lock.
3959+
*/
3960+
dmar_register_bus_notifier();
3961+
3962+
down_write(&dmar_global_lock);
3963+
39473964
if (!no_iommu)
39483965
intel_iommu_debugfs_init();
39493966

@@ -3988,9 +4005,11 @@ int __init intel_iommu_init(void)
39884005
pr_err("Initialization failed\n");
39894006
goto out_free_dmar;
39904007
}
4008+
up_write(&dmar_global_lock);
39914009

39924010
init_iommu_pm_ops();
39934011

4012+
down_read(&dmar_global_lock);
39944013
for_each_active_iommu(iommu, drhd) {
39954014
/*
39964015
* The flush queue implementation does not perform
@@ -4008,11 +4027,13 @@ int __init intel_iommu_init(void)
40084027
"%s", iommu->name);
40094028
iommu_device_register(&iommu->iommu, &intel_iommu_ops, NULL);
40104029
}
4030+
up_read(&dmar_global_lock);
40114031

40124032
bus_set_iommu(&pci_bus_type, &intel_iommu_ops);
40134033
if (si_domain && !hw_pass_through)
40144034
register_memory_notifier(&intel_iommu_memory_nb);
40154035

4036+
down_read(&dmar_global_lock);
40164037
if (probe_acpi_namespace_devices())
40174038
pr_warn("ACPI name space devices didn't probe correctly\n");
40184039

@@ -4023,15 +4044,17 @@ int __init intel_iommu_init(void)
40234044

40244045
iommu_disable_protect_mem_regions(iommu);
40254046
}
4047+
up_read(&dmar_global_lock);
40264048

4027-
intel_iommu_enabled = 1;
4028-
dmar_register_bus_notifier();
40294049
pr_info("Intel(R) Virtualization Technology for Directed I/O\n");
40304050

4051+
intel_iommu_enabled = 1;
4052+
40314053
return 0;
40324054

40334055
out_free_dmar:
40344056
intel_iommu_free_dmars();
4057+
up_write(&dmar_global_lock);
40354058
return ret;
40364059
}
40374060

include/linux/dmar.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ struct dmar_pci_notify_info {
6565

6666
extern struct rw_semaphore dmar_global_lock;
6767
extern struct list_head dmar_drhd_units;
68-
extern int intel_iommu_enabled;
6968

7069
#define for_each_drhd_unit(drhd) \
7170
list_for_each_entry_rcu(drhd, &dmar_drhd_units, list, \
@@ -89,8 +88,7 @@ extern int intel_iommu_enabled;
8988
static inline bool dmar_rcu_check(void)
9089
{
9190
return rwsem_is_locked(&dmar_global_lock) ||
92-
system_state == SYSTEM_BOOTING ||
93-
(IS_ENABLED(CONFIG_INTEL_IOMMU) && !intel_iommu_enabled);
91+
system_state == SYSTEM_BOOTING;
9492
}
9593

9694
#define dmar_rcu_dereference(p) rcu_dereference_check((p), dmar_rcu_check())

0 commit comments

Comments
 (0)