@@ -1110,20 +1110,6 @@ void iommu_group_remove_device(struct device *dev)
1110
1110
}
1111
1111
EXPORT_SYMBOL_GPL (iommu_group_remove_device );
1112
1112
1113
- static int __iommu_group_for_each_dev (struct iommu_group * group , void * data ,
1114
- int (* fn )(struct device * , void * ))
1115
- {
1116
- struct group_device * device ;
1117
- int ret = 0 ;
1118
-
1119
- for_each_group_device (group , device ) {
1120
- ret = fn (device -> dev , data );
1121
- if (ret )
1122
- break ;
1123
- }
1124
- return ret ;
1125
- }
1126
-
1127
1113
/**
1128
1114
* iommu_group_for_each_dev - iterate over each device in the group
1129
1115
* @group: the group
@@ -1138,10 +1124,15 @@ static int __iommu_group_for_each_dev(struct iommu_group *group, void *data,
1138
1124
int iommu_group_for_each_dev (struct iommu_group * group , void * data ,
1139
1125
int (* fn )(struct device * , void * ))
1140
1126
{
1141
- int ret ;
1127
+ struct group_device * device ;
1128
+ int ret = 0 ;
1142
1129
1143
1130
mutex_lock (& group -> mutex );
1144
- ret = __iommu_group_for_each_dev (group , data , fn );
1131
+ for_each_group_device (group , device ) {
1132
+ ret = fn (device -> dev , data );
1133
+ if (ret )
1134
+ break ;
1135
+ }
1145
1136
mutex_unlock (& group -> mutex );
1146
1137
1147
1138
return ret ;
@@ -1791,20 +1782,12 @@ static int iommu_get_default_domain_type(struct iommu_group *group,
1791
1782
return best_type ;
1792
1783
}
1793
1784
1794
- static int iommu_group_do_probe_finalize (struct device * dev , void * data )
1785
+ static void iommu_group_do_probe_finalize (struct device * dev )
1795
1786
{
1796
1787
const struct iommu_ops * ops = dev_iommu_ops (dev );
1797
1788
1798
1789
if (ops -> probe_finalize )
1799
1790
ops -> probe_finalize (dev );
1800
-
1801
- return 0 ;
1802
- }
1803
-
1804
- static void __iommu_group_dma_finalize (struct iommu_group * group )
1805
- {
1806
- __iommu_group_for_each_dev (group , group -> default_domain ,
1807
- iommu_group_do_probe_finalize );
1808
1791
}
1809
1792
1810
1793
int bus_iommu_probe (const struct bus_type * bus )
@@ -1823,6 +1806,8 @@ int bus_iommu_probe(const struct bus_type *bus)
1823
1806
return ret ;
1824
1807
1825
1808
list_for_each_entry_safe (group , next , & group_list , entry ) {
1809
+ struct group_device * gdev ;
1810
+
1826
1811
mutex_lock (& group -> mutex );
1827
1812
1828
1813
/* Remove item from the list */
@@ -1834,7 +1819,15 @@ int bus_iommu_probe(const struct bus_type *bus)
1834
1819
return ret ;
1835
1820
}
1836
1821
mutex_unlock (& group -> mutex );
1837
- __iommu_group_dma_finalize (group );
1822
+
1823
+ /*
1824
+ * FIXME: Mis-locked because the ops->probe_finalize() call-back
1825
+ * of some IOMMU drivers calls arm_iommu_attach_device() which
1826
+ * in-turn might call back into IOMMU core code, where it tries
1827
+ * to take group->mutex, resulting in a deadlock.
1828
+ */
1829
+ for_each_group_device (group , gdev )
1830
+ iommu_group_do_probe_finalize (gdev -> dev );
1838
1831
}
1839
1832
1840
1833
return 0 ;
@@ -2995,8 +2988,12 @@ static ssize_t iommu_group_store_type(struct iommu_group *group,
2995
2988
mutex_unlock (& group -> mutex );
2996
2989
2997
2990
/* Make sure dma_ops is appropriatley set */
2998
- if (!ret )
2999
- __iommu_group_dma_finalize (group );
2991
+ if (!ret ) {
2992
+ struct group_device * gdev ;
2993
+
2994
+ for_each_group_device (group , gdev )
2995
+ iommu_group_do_probe_finalize (gdev -> dev );
2996
+ }
3000
2997
3001
2998
return ret ?: count ;
3002
2999
}
0 commit comments