Skip to contentSkip to conversation

viommu: return error code for unknown probe type

PATCH In review [email protected] 2 participants 2 messages Apr 15, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 viommu: return error code for unknown probe type

From: Peng Hao <[email protected]>

If the probe types processed by the loop are all unknown, no error will be returned.

---
 drivers/iommu/virtio-iommu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/virtio-iommu.c +1 -0
index 04048f64a2c0..80352505b762 100644
@@ -555,6 +555,7 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev)
 			break;
 		default:
 			dev_err(dev, "unknown viommu prop 0x%x\n", type);
+			ret = -EINVAL;
 		}
 
 		if (ret)
Signature · 1 line
2.31.1
#1 lore raw

Hello,

Quoted 15 lines · On Mon, Apr 15, 2024 at 04:18:23PM +0800, [email protected] wrote:

From: Peng Hao <[email protected]>

If the probe types processed by the loop are all unknown, no error will be returned.

---
 drivers/iommu/virtio-iommu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/virtio-iommu.c +0 -0
index 04048f64a2c0..80352505b762 100644

drivers/iommu/virtio-iommu.c static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) · line 558

Quoted 4 lines
drivers/iommu/virtio-iommu.c +1 -0
@@ -555,6 +555,7 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev)
 			break;
 		default:
 			dev_err(dev, "unknown viommu prop 0x%x\n", type);
+			ret = -EINVAL;

The intent here is only to warn (and it should probably be replaced with dev_warn()). I don't think unrecognized properties should cause the endpoint probe to fail, they just indicate that the device supports newer features.

The virtio-iommu specification states this in 5.13.6.7.1 Driver
Requirements: PROBE request:
"If the driver doesn’t recognize the type of a property, it SHOULD ignore
the property."

Ideally, new PROBE properties are introduced alongside a virtio feature bit, and the device doesn't present them in the PROBE buffer if that feature isn't negotiated during device initialization. However we don't yet have an example of such extension. Did you encounter this problem on existing systems?

Thanks,
Jean

Quoted 6 lines
drivers/iommu/virtio-iommu.c +0 -0
 		}
 
 		if (ret)
Signature · 1 line
2.31.1