Commit e996c12d authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Joerg Roedel

iommu: Remove __iommu_group_for_each_dev()

The last two users of it are quite trivial, just open code the one line
loop.
Reviewed-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Tested-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/16-v5-1b99ae392328+44574-iommu_err_unwind_jgg@nvidia.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 1000dccd
...@@ -1110,20 +1110,6 @@ void iommu_group_remove_device(struct device *dev) ...@@ -1110,20 +1110,6 @@ void iommu_group_remove_device(struct device *dev)
} }
EXPORT_SYMBOL_GPL(iommu_group_remove_device); EXPORT_SYMBOL_GPL(iommu_group_remove_device);
static int __iommu_group_for_each_dev(struct iommu_group *group, void *data,
int (*fn)(struct device *, void *))
{
struct group_device *device;
int ret = 0;
for_each_group_device(group, device) {
ret = fn(device->dev, data);
if (ret)
break;
}
return ret;
}
/** /**
* iommu_group_for_each_dev - iterate over each device in the group * iommu_group_for_each_dev - iterate over each device in the group
* @group: the group * @group: the group
...@@ -1138,10 +1124,15 @@ static int __iommu_group_for_each_dev(struct iommu_group *group, void *data, ...@@ -1138,10 +1124,15 @@ static int __iommu_group_for_each_dev(struct iommu_group *group, void *data,
int iommu_group_for_each_dev(struct iommu_group *group, void *data, int iommu_group_for_each_dev(struct iommu_group *group, void *data,
int (*fn)(struct device *, void *)) int (*fn)(struct device *, void *))
{ {
int ret; struct group_device *device;
int ret = 0;
mutex_lock(&group->mutex); mutex_lock(&group->mutex);
ret = __iommu_group_for_each_dev(group, data, fn); for_each_group_device(group, device) {
ret = fn(device->dev, data);
if (ret)
break;
}
mutex_unlock(&group->mutex); mutex_unlock(&group->mutex);
return ret; return ret;
...@@ -1791,20 +1782,12 @@ static int iommu_get_default_domain_type(struct iommu_group *group, ...@@ -1791,20 +1782,12 @@ static int iommu_get_default_domain_type(struct iommu_group *group,
return best_type; return best_type;
} }
static int iommu_group_do_probe_finalize(struct device *dev, void *data) static void iommu_group_do_probe_finalize(struct device *dev)
{ {
const struct iommu_ops *ops = dev_iommu_ops(dev); const struct iommu_ops *ops = dev_iommu_ops(dev);
if (ops->probe_finalize) if (ops->probe_finalize)
ops->probe_finalize(dev); ops->probe_finalize(dev);
return 0;
}
static void __iommu_group_dma_finalize(struct iommu_group *group)
{
__iommu_group_for_each_dev(group, group->default_domain,
iommu_group_do_probe_finalize);
} }
int bus_iommu_probe(const struct bus_type *bus) int bus_iommu_probe(const struct bus_type *bus)
...@@ -1823,6 +1806,8 @@ int bus_iommu_probe(const struct bus_type *bus) ...@@ -1823,6 +1806,8 @@ int bus_iommu_probe(const struct bus_type *bus)
return ret; return ret;
list_for_each_entry_safe(group, next, &group_list, entry) { list_for_each_entry_safe(group, next, &group_list, entry) {
struct group_device *gdev;
mutex_lock(&group->mutex); mutex_lock(&group->mutex);
/* Remove item from the list */ /* Remove item from the list */
...@@ -1834,7 +1819,15 @@ int bus_iommu_probe(const struct bus_type *bus) ...@@ -1834,7 +1819,15 @@ int bus_iommu_probe(const struct bus_type *bus)
return ret; return ret;
} }
mutex_unlock(&group->mutex); mutex_unlock(&group->mutex);
__iommu_group_dma_finalize(group);
/*
* FIXME: Mis-locked because the ops->probe_finalize() call-back
* of some IOMMU drivers calls arm_iommu_attach_device() which
* in-turn might call back into IOMMU core code, where it tries
* to take group->mutex, resulting in a deadlock.
*/
for_each_group_device(group, gdev)
iommu_group_do_probe_finalize(gdev->dev);
} }
return 0; return 0;
...@@ -2995,8 +2988,12 @@ static ssize_t iommu_group_store_type(struct iommu_group *group, ...@@ -2995,8 +2988,12 @@ static ssize_t iommu_group_store_type(struct iommu_group *group,
mutex_unlock(&group->mutex); mutex_unlock(&group->mutex);
/* Make sure dma_ops is appropriatley set */ /* Make sure dma_ops is appropriatley set */
if (!ret) if (!ret) {
__iommu_group_dma_finalize(group); struct group_device *gdev;
for_each_group_device(group, gdev)
iommu_group_do_probe_finalize(gdev->dev);
}
return ret ?: count; return ret ?: count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment