diff options
| -rw-r--r-- | arch/powerpc/include/asm/iommu.h | 6 | ||||
| -rw-r--r-- | arch/powerpc/kernel/iommu.c | 26 | ||||
| -rw-r--r-- | arch/powerpc/platforms/powernv/pci.c | 26 | ||||
| -rw-r--r-- | arch/powerpc/platforms/pseries/iommu.c | 2 |
4 files changed, 34 insertions, 26 deletions
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h index 9cfa3706a1b8..f1ea5972f6ec 100644 --- a/arch/powerpc/include/asm/iommu.h +++ b/arch/powerpc/include/asm/iommu.h | |||
| @@ -113,6 +113,7 @@ extern void iommu_register_group(struct iommu_table *tbl, | |||
| 113 | int pci_domain_number, unsigned long pe_num); | 113 | int pci_domain_number, unsigned long pe_num); |
| 114 | extern int iommu_add_device(struct device *dev); | 114 | extern int iommu_add_device(struct device *dev); |
| 115 | extern void iommu_del_device(struct device *dev); | 115 | extern void iommu_del_device(struct device *dev); |
| 116 | extern int __init tce_iommu_bus_notifier_init(void); | ||
| 116 | #else | 117 | #else |
| 117 | static inline void iommu_register_group(struct iommu_table *tbl, | 118 | static inline void iommu_register_group(struct iommu_table *tbl, |
| 118 | int pci_domain_number, | 119 | int pci_domain_number, |
| @@ -128,6 +129,11 @@ static inline int iommu_add_device(struct device *dev) | |||
| 128 | static inline void iommu_del_device(struct device *dev) | 129 | static inline void iommu_del_device(struct device *dev) |
| 129 | { | 130 | { |
| 130 | } | 131 | } |
| 132 | |||
| 133 | static inline int __init tce_iommu_bus_notifier_init(void) | ||
| 134 | { | ||
| 135 | return 0; | ||
| 136 | } | ||
| 131 | #endif /* !CONFIG_IOMMU_API */ | 137 | #endif /* !CONFIG_IOMMU_API */ |
| 132 | 138 | ||
| 133 | static inline void set_iommu_table_base_and_group(struct device *dev, | 139 | static inline void set_iommu_table_base_and_group(struct device *dev, |
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index 5d3968c4d799..b054f33ab1fb 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c | |||
| @@ -1175,4 +1175,30 @@ void iommu_del_device(struct device *dev) | |||
| 1175 | } | 1175 | } |
| 1176 | EXPORT_SYMBOL_GPL(iommu_del_device); | 1176 | EXPORT_SYMBOL_GPL(iommu_del_device); |
| 1177 | 1177 | ||
| 1178 | static int tce_iommu_bus_notifier(struct notifier_block *nb, | ||
| 1179 | unsigned long action, void *data) | ||
| 1180 | { | ||
| 1181 | struct device *dev = data; | ||
| 1182 | |||
| 1183 | switch (action) { | ||
| 1184 | case BUS_NOTIFY_ADD_DEVICE: | ||
| 1185 | return iommu_add_device(dev); | ||
| 1186 | case BUS_NOTIFY_DEL_DEVICE: | ||
| 1187 | if (dev->iommu_group) | ||
| 1188 | iommu_del_device(dev); | ||
| 1189 | return 0; | ||
| 1190 | default: | ||
| 1191 | return 0; | ||
| 1192 | } | ||
| 1193 | } | ||
| 1194 | |||
| 1195 | static struct notifier_block tce_iommu_bus_nb = { | ||
| 1196 | .notifier_call = tce_iommu_bus_notifier, | ||
| 1197 | }; | ||
| 1198 | |||
| 1199 | int __init tce_iommu_bus_notifier_init(void) | ||
| 1200 | { | ||
| 1201 | bus_register_notifier(&pci_bus_type, &tce_iommu_bus_nb); | ||
| 1202 | return 0; | ||
| 1203 | } | ||
| 1178 | #endif /* CONFIG_IOMMU_API */ | 1204 | #endif /* CONFIG_IOMMU_API */ |
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index e69142f4af08..54323d6b5166 100644 --- a/arch/powerpc/platforms/powernv/pci.c +++ b/arch/powerpc/platforms/powernv/pci.c | |||
| @@ -836,30 +836,4 @@ void __init pnv_pci_init(void) | |||
| 836 | #endif | 836 | #endif |
| 837 | } | 837 | } |
| 838 | 838 | ||
| 839 | static int tce_iommu_bus_notifier(struct notifier_block *nb, | ||
| 840 | unsigned long action, void *data) | ||
| 841 | { | ||
| 842 | struct device *dev = data; | ||
| 843 | |||
| 844 | switch (action) { | ||
| 845 | case BUS_NOTIFY_ADD_DEVICE: | ||
| 846 | return iommu_add_device(dev); | ||
| 847 | case BUS_NOTIFY_DEL_DEVICE: | ||
| 848 | if (dev->iommu_group) | ||
| 849 | iommu_del_device(dev); | ||
| 850 | return 0; | ||
| 851 | default: | ||
| 852 | return 0; | ||
| 853 | } | ||
| 854 | } | ||
| 855 | |||
| 856 | static struct notifier_block tce_iommu_bus_nb = { | ||
| 857 | .notifier_call = tce_iommu_bus_notifier, | ||
| 858 | }; | ||
| 859 | |||
| 860 | static int __init tce_iommu_bus_notifier_init(void) | ||
| 861 | { | ||
| 862 | bus_register_notifier(&pci_bus_type, &tce_iommu_bus_nb); | ||
| 863 | return 0; | ||
| 864 | } | ||
| 865 | machine_subsys_initcall_sync(powernv, tce_iommu_bus_notifier_init); | 839 | machine_subsys_initcall_sync(powernv, tce_iommu_bus_notifier_init); |
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 1d3d52dc3ff3..7803a19adb31 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c | |||
| @@ -1340,3 +1340,5 @@ static int __init disable_multitce(char *str) | |||
| 1340 | } | 1340 | } |
| 1341 | 1341 | ||
| 1342 | __setup("multitce=", disable_multitce); | 1342 | __setup("multitce=", disable_multitce); |
| 1343 | |||
| 1344 | machine_subsys_initcall_sync(pseries, tce_iommu_bus_notifier_init); | ||
