Skip to contentSkip to conversation

iommu: Check for iommu_ops == NULL in iommu_probe_device()

PATCH In review Joerg Roedel 3 participants 5 messages Dec 20, 2018 – Jan 16, 2019 4 messages not in the archive IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: Check for iommu_ops == NULL in iommu_probe_device()

From: Joerg Roedel <[email protected]>

This check needs to be there and got lost at some point during development. Add it again.

Fixes 641fb0efbff0 ('iommu/of: Don't call iommu_ops->add_device directly')
---
 drivers/iommu/iommu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/iommu.c +5 -1
index a2131751dcff..3ed4db334341 100644
@@ -114,10 +114,14 @@ void iommu_device_unregister(struct iommu_device *iommu)
 int iommu_probe_device(struct device *dev)
 {
 	const struct iommu_ops *ops = dev->bus->iommu_ops;
+	int ret = -EINVAL;
 
 	WARN_ON(dev->iommu_group);
 
-	return ops->add_device(dev);
+	if (ops)
+		ret = ops->add_device(dev);
+
+	return ret;
 }
 
 void iommu_release_device(struct device *dev)
Signature · 1 line
2.13.7

A message that is not in the archive (sent off-list or not yet received): 20181220090833.6643-1-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org

#2 lore raw

Hi Joerg,

Quoted 6 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

This check needs to be there and got lost at some point during development. Add it again.

Fixes 641fb0efbff0 ('iommu/of: Don't call iommu_ops->add_device directly')

I experience a regression with those 2 patches. I have virtio-pci device protected by virtual smmuv3 and in that case I get err = -EPROBE_DEFER after pci_for_each_dma_alias() in of_iommu_configure(). When iommu_probe_device is called, ops = NULL so it returns -EINVAL and err is overwritten. So there is no deferred probing while it happened before.

Thanks

Eric

Quoted 28 lines
---
 drivers/iommu/iommu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/iommu.c +5 -1
index a2131751dcff..3ed4db334341 100644
@@ -114,10 +114,14 @@ void iommu_device_unregister(struct iommu_device *iommu)
 int iommu_probe_device(struct device *dev)
 {
 	const struct iommu_ops *ops = dev->bus->iommu_ops;
+	int ret = -EINVAL;
 
 	WARN_ON(dev->iommu_group);
 
-	return ops->add_device(dev);
+	if (ops)
+		ret = ops->add_device(dev);
+
+	return ret;
 }
 
 void iommu_release_device(struct device *dev)

A message that is not in the archive (sent off-list or not yet received): e1a87036-d2df-c59b-a23d-9093ba02bacd-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#4 lore raw
Quoted 8 lines · Auger Eric

Hi Joerg,

Quoted 5 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

This check needs to be there and got lost at some point during development. Add it again.

Quoted 6 lines
Quoted 1 line
Fixes 641fb0efbff0 ('iommu/of: Don't call iommu_ops->add_device directly')

I experience a regression with those 2 patches. I have virtio-pci device protected by virtual smmuv3 and in that case I get err = -EPROBE_DEFER after pci_for_each_dma_alias() in of_iommu_configure(). When iommu_probe_device is called, ops = NULL so it returns -EINVAL and err is overwritten. So there is no deferred probing while it happened before.

There is a fix on the list:
https://www.spinics.net/lists/arm-kernel/msg698371.html

Thanks,
Jean

A message that is not in the archive (sent off-list or not yet received): 270d1c47-0752-68c7-e5ca-d19dcd170bbc-5wv7dgnIgG8@public.gmane.org

A message that is not in the archive (sent off-list or not yet received): [email protected]