History

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.

Joerg Roedel committed 6 years ago

Commit 5012c391 parent ce574c22 files · +10 −1Browse files

Unified · Split

2 files
  1. drivers/iommu/iommu.c +9 −1
  2. include/linux/iommu.h +1 −0
drivers/iommu/iommu.c+9−1
@@ -1610,11 +1610,19 @@ static int probe_iommu_group(struct device *dev, void *data) · 1609 unmodified lines
16101610 {
16111611 const struct iommu_ops *ops = dev->bus->iommu_ops;
16121612 struct list_head *group_list = data;
1613+ struct iommu_group *group;
16131614 int ret;
16141615
16151616 if (!dev_iommu_get(dev))
16161617 return -ENOMEM;
16171618
1619+ /* Device is probed already if in a group */
1620+ group = iommu_group_get(dev);
1621+ if (group) {
1622+ iommu_group_put(group);
1623+ return 0;
1624+ }
1625+
16181626 if (!try_module_get(ops->owner)) {
16191627 ret = -EINVAL;
16201628 goto err_free_dev_iommu;
@@ -1783,7 +1791,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group) · 162 unmodified lines
17831791 iommu_do_create_direct_mappings);
17841792 }
17851793
1786−static int bus_iommu_probe(struct bus_type *bus)
1794+int bus_iommu_probe(struct bus_type *bus)
17871795 {
17881796 const struct iommu_ops *ops = bus->iommu_ops;
17891797 int ret;
include/linux/iommu.h+1−0
@@ -445,6 +445,7 @@ static inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather) · 444 unmodified lines
445445 #define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER 6 /* Post Driver unbind */
446446
447447 extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
448+extern int bus_iommu_probe(struct bus_type *bus);
448449 extern bool iommu_present(struct bus_type *bus);
449450 extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
450451 extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);