Commit 5012c396 authored by Joerg Roedel's avatar Joerg Roedel

iommu: Export bus_iommu_probe() and make is safe for re-probing

Add a check to the bus_iommu_probe() call-path to make sure it ignores
devices which have already been successfully probed. Then export the
bus_iommu_probe() function so it can be used by IOMMU drivers.
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20200429133712.31431-14-joro@8bytes.orgSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent ce574c27
...@@ -1610,11 +1610,19 @@ static int probe_iommu_group(struct device *dev, void *data) ...@@ -1610,11 +1610,19 @@ static int probe_iommu_group(struct device *dev, void *data)
{ {
const struct iommu_ops *ops = dev->bus->iommu_ops; const struct iommu_ops *ops = dev->bus->iommu_ops;
struct list_head *group_list = data; struct list_head *group_list = data;
struct iommu_group *group;
int ret; int ret;
if (!dev_iommu_get(dev)) if (!dev_iommu_get(dev))
return -ENOMEM; return -ENOMEM;
/* Device is probed already if in a group */
group = iommu_group_get(dev);
if (group) {
iommu_group_put(group);
return 0;
}
if (!try_module_get(ops->owner)) { if (!try_module_get(ops->owner)) {
ret = -EINVAL; ret = -EINVAL;
goto err_free_dev_iommu; goto err_free_dev_iommu;
...@@ -1783,7 +1791,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group) ...@@ -1783,7 +1791,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group)
iommu_do_create_direct_mappings); iommu_do_create_direct_mappings);
} }
static int bus_iommu_probe(struct bus_type *bus) int bus_iommu_probe(struct bus_type *bus)
{ {
const struct iommu_ops *ops = bus->iommu_ops; const struct iommu_ops *ops = bus->iommu_ops;
int ret; int ret;
......
...@@ -445,6 +445,7 @@ static inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather) ...@@ -445,6 +445,7 @@ static inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather)
#define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER 6 /* Post Driver unbind */ #define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER 6 /* Post Driver unbind */
extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops); extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
extern int bus_iommu_probe(struct bus_type *bus);
extern bool iommu_present(struct bus_type *bus); extern bool iommu_present(struct bus_type *bus);
extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap); extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus); extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
......
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