Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/vt-d: Don't register bus-notifier under dmar_global_lock

The notifier function will take the dmar_global_lock too, so
lockdep complains about inverse locking order when the
notifier is registered under the dmar_global_lock.

Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
Fixes: 59ce0515cdaf ('iommu/vt-d: Update DRHD/RMRR/ATSR device scope caches when PCI hotplug happens')
Signed-off-by: Joerg Roedel <jroedel@suse.de>

+16 -2
+5 -2
drivers/iommu/dmar.c
··· 801 801 dmar_free_pci_notify_info(info); 802 802 } 803 803 } 804 - 805 - bus_register_notifier(&pci_bus_type, &dmar_pci_bus_nb); 806 804 } 807 805 808 806 return dmar_dev_scope_status; 807 + } 808 + 809 + void dmar_register_bus_notifier(void) 810 + { 811 + bus_register_notifier(&pci_bus_type, &dmar_pci_bus_nb); 809 812 } 810 813 811 814
+10
drivers/iommu/intel-iommu.c
··· 4752 4752 goto out_free_dmar; 4753 4753 } 4754 4754 4755 + up_write(&dmar_global_lock); 4756 + 4757 + /* 4758 + * The bus notifier takes the dmar_global_lock, so lockdep will 4759 + * complain later when we register it under the lock. 4760 + */ 4761 + dmar_register_bus_notifier(); 4762 + 4763 + down_write(&dmar_global_lock); 4764 + 4755 4765 if (no_iommu || dmar_disabled) { 4756 4766 /* 4757 4767 * We exit the function here to ensure IOMMU's remapping and
+1
include/linux/dmar.h
··· 112 112 113 113 extern int dmar_table_init(void); 114 114 extern int dmar_dev_scope_init(void); 115 + extern void dmar_register_bus_notifier(void); 115 116 extern int dmar_parse_dev_scope(void *start, void *end, int *cnt, 116 117 struct dmar_dev_scope **devices, u16 segment); 117 118 extern void *dmar_alloc_dev_scope(void *start, void *end, int *cnt);