@@ -264,6 +264,7 @@ int iommu_device_register(struct iommu_device *iommu,
return -EBUSY;
iommu->ops = ops;
+ iommu->hwdev = hwdev;
if (hwdev)
iommu->fwnode = dev_fwnode(hwdev);
@@ -1802,9 +1803,18 @@ static int probe_iommu_group(struct device *dev, void *data)
struct probe_iommu_args *args = data;
int ret;
+ /*
+ * The iommu device itself is not probed, in part because no sane iommu
+ * should self-attach to its own HW, but specifically because we already
+ * hold the device_lock for the hwdev when calling here.
+ */
+ if (args->iommu->hwdev == dev)
+ return 0;
+
device_lock(dev);
ret = __iommu_probe_device(dev, args->group_list);
device_unlock(dev);
+
if (ret == -ENODEV)
ret = 0;
@@ -1241,6 +1241,7 @@ static int omap_iommu_probe(struct platform_device *pdev)
* an iommu without registering it, so re-run probe again to try
* to match any devices that are waiting for this iommu.
*/
+ obj->iommu.hwdev = &pdev->dev;
bus_iommu_probe(&platform_bus_type, &obj->iommu);
}
@@ -361,6 +361,7 @@ struct iommu_domain_ops {
* @list: Used by the iommu-core to keep a list of registered iommus
* @ops: iommu-ops for talking to this iommu
* @dev: struct device for sysfs handling
+ * @hwdev: The device HW that controls the iommu
* @singleton_group: Used internally for drivers that have only one group
* @max_pasids: number of supported PASIDs
*/
@@ -369,6 +370,7 @@ struct iommu_device {
const struct iommu_ops *ops;
struct fwnode_handle *fwnode;
struct device *dev;
+ struct device *hwdev;
struct iommu_group *singleton_group;
u32 max_pasids;
};