aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm64/mm/dma-mapping.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 46a4157adc17..f6c55afab3e2 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -861,15 +861,16 @@ static int __iommu_attach_notifier(struct notifier_block *nb,
861{ 861{
862 struct iommu_dma_notifier_data *master, *tmp; 862 struct iommu_dma_notifier_data *master, *tmp;
863 863
864 if (action != BUS_NOTIFY_ADD_DEVICE) 864 if (action != BUS_NOTIFY_BIND_DRIVER)
865 return 0; 865 return 0;
866 866
867 mutex_lock(&iommu_dma_notifier_lock); 867 mutex_lock(&iommu_dma_notifier_lock);
868 list_for_each_entry_safe(master, tmp, &iommu_dma_masters, list) { 868 list_for_each_entry_safe(master, tmp, &iommu_dma_masters, list) {
869 if (do_iommu_attach(master->dev, master->ops, 869 if (data == master->dev && do_iommu_attach(master->dev,
870 master->dma_base, master->size)) { 870 master->ops, master->dma_base, master->size)) {
871 list_del(&master->list); 871 list_del(&master->list);
872 kfree(master); 872 kfree(master);
873 break;
873 } 874 }
874 } 875 }
875 mutex_unlock(&iommu_dma_notifier_lock); 876 mutex_unlock(&iommu_dma_notifier_lock);
@@ -883,17 +884,8 @@ static int __init register_iommu_dma_ops_notifier(struct bus_type *bus)
883 884
884 if (!nb) 885 if (!nb)
885 return -ENOMEM; 886 return -ENOMEM;
886 /* 887
887 * The device must be attached to a domain before the driver probe
888 * routine gets a chance to start allocating DMA buffers. However,
889 * the IOMMU driver also needs a chance to configure the iommu_group
890 * via its add_device callback first, so we need to make the attach
891 * happen between those two points. Since the IOMMU core uses a bus
892 * notifier with default priority for add_device, do the same but
893 * with a lower priority to ensure the appropriate ordering.
894 */
895 nb->notifier_call = __iommu_attach_notifier; 888 nb->notifier_call = __iommu_attach_notifier;
896 nb->priority = -100;
897 889
898 ret = bus_register_notifier(bus, nb); 890 ret = bus_register_notifier(bus, nb);
899 if (ret) { 891 if (ret) {
@@ -917,10 +909,6 @@ static int __init __iommu_dma_init(void)
917 if (!ret) 909 if (!ret)
918 ret = register_iommu_dma_ops_notifier(&pci_bus_type); 910 ret = register_iommu_dma_ops_notifier(&pci_bus_type);
919#endif 911#endif
920
921 /* handle devices queued before this arch_initcall */
922 if (!ret)
923 __iommu_attach_notifier(NULL, BUS_NOTIFY_ADD_DEVICE, NULL);
924 return ret; 912 return ret;
925} 913}
926arch_initcall(__iommu_dma_init); 914arch_initcall(__iommu_dma_init);