diff options
author | Gavin Shan <shangw@linux.vnet.ibm.com> | 2014-01-12 22:36:22 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-01-14 21:58:33 -0500 |
commit | 0c4b9e27b09eeb4da84451c038a587b92ce93ff5 (patch) | |
tree | 89c8b8458ddc399f0e8faf0306227a1caa69cbe6 /arch | |
parent | f26c7a035b7f2f1a7505ce42e4ba946b12f7df91 (diff) |
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>
Diffstat (limited to 'arch')
-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 f58d8135aab2..d773dd440a45 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c | |||
@@ -1144,6 +1144,17 @@ EXPORT_SYMBOL_GPL(iommu_add_device); | |||
1144 | 1144 | ||
1145 | void iommu_del_device(struct device *dev) | 1145 | void iommu_del_device(struct device *dev) |
1146 | { | 1146 | { |
1147 | /* | ||
1148 | * Some devices might not have IOMMU table and group | ||
1149 | * and we needn't detach them from the associated | ||
1150 | * IOMMU groups | ||
1151 | */ | ||
1152 | if (!dev->iommu_group) { | ||
1153 | pr_debug("iommu_tce: skipping device %s with no tbl\n", | ||
1154 | dev_name(dev)); | ||
1155 | return; | ||
1156 | } | ||
1157 | |||
1147 | iommu_group_remove_device(dev); | 1158 | iommu_group_remove_device(dev); |
1148 | } | 1159 | } |
1149 | EXPORT_SYMBOL_GPL(iommu_del_device); | 1160 | EXPORT_SYMBOL_GPL(iommu_del_device); |