diff options
author | Gavin Shan <shangw@linux.vnet.ibm.com> | 2014-01-21 09:52:23 +1100 |
---|---|---|
committer | Eli Qiao <taget@linux.vnet.ibm.com> | 2014-01-22 10:26:22 +0800 |
commit | 3ffcb71ddba64a127b92b58d3088634d2efbe4e8 (patch) | |
tree | 8894c8a2edcd0145b81b405f9bf7e61181513b12 | |
parent | 98c51e5e90bb9734228190cf1472d9e3467f0a87 (diff) | |
download | powerkvm-3ffcb71ddba64a127b92b58d3088634d2efbe4e8.tar.gz |
powerpc/iommu: Don't detach device without IOMMU group
Some devices, for example PCI root port, don't have IOMMU table and
group. We needn't detach them from their IOMMU group. Otherwise, it
potentially incurs kernel crash because of referring NULL IOMMU group
as following backtrace indicates:
.iommu_group_remove_device+0x74/0x1b0
.iommu_bus_notifier+0x94/0xb4
.notifier_call_chain+0x78/0xe8
.__blocking_notifier_call_chain+0x7c/0xbc
.blocking_notifier_call_chain+0x38/0x48
.device_del+0x50/0x234
.pci_remove_bus_device+0x88/0x138
.pci_stop_and_remove_bus_device+0x2c/0x40
.pcibios_remove_pci_devices+0xcc/0xfc
.pcibios_remove_pci_devices+0x3c/0xfc
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/kernel/iommu.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index 55d48de0273499..02aaae61d999e6 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c @@ -1214,6 +1214,17 @@ EXPORT_SYMBOL_GPL(iommu_add_device); void iommu_del_device(struct device *dev) { + /* + * Some devices might not have IOMMU table and group + * and we needn't detach them from the associated + * IOMMU groups + */ + if (!dev->iommu_group) { + pr_debug("iommu_tce: skipping device %s with no tbl\n", + dev_name(dev)); + return; + } + iommu_group_remove_device(dev); } EXPORT_SYMBOL_GPL(iommu_del_device); |