Skip to content

Commit

Permalink
iommu/vt-d: Don't register bus-notifier under dmar_global_lock
Browse files Browse the repository at this point in the history
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: 59ce051 ('iommu/vt-d: Update DRHD/RMRR/ATSR device scope caches when PCI hotplug happens')
Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Joerg Roedel committed Oct 6, 2017
1 parent 9e66317 commit ec154bf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/iommu/dmar.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,13 +801,16 @@ int __init dmar_dev_scope_init(void)
dmar_free_pci_notify_info(info);
}
}

bus_register_notifier(&pci_bus_type, &dmar_pci_bus_nb);
}

return dmar_dev_scope_status;
}

void dmar_register_bus_notifier(void)
{
bus_register_notifier(&pci_bus_type, &dmar_pci_bus_nb);
}


int __init dmar_table_init(void)
{
Expand Down
10 changes: 10 additions & 0 deletions drivers/iommu/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4752,6 +4752,16 @@ int __init intel_iommu_init(void)
goto out_free_dmar;
}

up_write(&dmar_global_lock);

/*
* The bus notifier takes the dmar_global_lock, so lockdep will
* complain later when we register it under the lock.
*/
dmar_register_bus_notifier();

down_write(&dmar_global_lock);

if (no_iommu || dmar_disabled) {
/*
* We exit the function here to ensure IOMMU's remapping and
Expand Down
1 change: 1 addition & 0 deletions include/linux/dmar.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ static inline bool dmar_rcu_check(void)

extern int dmar_table_init(void);
extern int dmar_dev_scope_init(void);
extern void dmar_register_bus_notifier(void);
extern int dmar_parse_dev_scope(void *start, void *end, int *cnt,
struct dmar_dev_scope **devices, u16 segment);
extern void *dmar_alloc_dev_scope(void *start, void *end, int *cnt);
Expand Down

0 comments on commit ec154bf

Please sign in to comment.