Skip to contentSkip to conversation

virtio: Fix virtio initialization sequence

PATCH New Christian Pötzsch 2 participants 3 messages Feb 17 – Mar 25 virtio core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio: Fix virtio initialization sequence

The virtio spec clearly states in "3.1.1 Driver Requirements: Device Initialization" the sequence a client has to follow after device reset. Because u-boot resets here again, it also needs to set the "acknowledge" bit again even if this was done in virtio_uclass_child_post_bind already once before.

---
 drivers/virtio/virtio-uclass.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/virtio/virtio-uclass.c +3 -0
index ac563991b90..c36e9e9b3a7 100644
@@ -292,6 +292,9 @@ static int virtio_uclass_child_pre_probe(struct udevice *vdev)
 	if (ret)
 		goto err;
 
+	/* After a reset we always need to start the init sequence again */
+	virtio_add_status(vdev, VIRTIO_CONFIG_S_ACKNOWLEDGE);
+
 	/* We have a driver! */
 	virtio_add_status(vdev, VIRTIO_CONFIG_S_DRIVER);
 
Signature · 1 line
2.51.0
#1 lore raw

PATCH v2 1/1 virtio: Fix virtio initialization sequence

From: Christian Pötzsch <[email protected]>

The virtio spec clearly states in "3.1.1 Driver Requirements: Device Initialization" the sequence a client has to follow after device reset. Because u-boot resets here again, it also needs to set the "acknowledge" bit again even if this was done in virtio_uclass_child_post_bind already once before.

[trini: Add VIRTIO_CONFIG_S_ACKNOWLEDGE flag check to the test]

---
Changes in v2:
- Update the test to expect VIRTIO_CONFIG_S_ACKNOWLEDGE being set as well.

---
 drivers/virtio/virtio-uclass.c | 3 +++
 test/dm/virtio_device.c        | 1 +
 2 files changed, 4 insertions(+)
drivers/virtio/virtio-uclass.c +3 -0
index ac563991b90f..c36e9e9b3a77 100644
@@ -292,6 +292,9 @@ static int virtio_uclass_child_pre_probe(struct udevice *vdev)
 	if (ret)
 		goto err;
 
+	/* After a reset we always need to start the init sequence again */
+	virtio_add_status(vdev, VIRTIO_CONFIG_S_ACKNOWLEDGE);
+
 	/* We have a driver! */
 	virtio_add_status(vdev, VIRTIO_CONFIG_S_DRIVER);
 
test/dm/virtio_device.c +1 -0
index 53414e4d3a47..c2cd0630d973 100644
@@ -40,6 +40,7 @@ static int dm_test_virtio_base(struct unit_test_state *uts)
 	ut_assertok(virtio_get_status(dev, &status));
 	ut_asserteq(VIRTIO_CONFIG_S_DRIVER |
 		    VIRTIO_CONFIG_S_DRIVER_OK |
+		    VIRTIO_CONFIG_S_ACKNOWLEDGE |
 		    VIRTIO_CONFIG_S_FEATURES_OK, status);
 
 	return 0;
Signature · 1 line
2.43.0
#2 lore raw
Quoted 8 lines · Tom Rini

The virtio spec clearly states in "3.1.1 Driver Requirements: Device Initialization" the sequence a client has to follow after device reset. Because u-boot resets here again, it also needs to set the "acknowledge" bit again even if this was done in virtio_uclass_child_post_bind already once before.

[...]

Applied to u-boot/next, thanks!

[1/1] virtio: Fix virtio initialization sequence

      commit: 30e1733297ac7d9703bd0950bd237648dcb41850
Signature · 1 line
Tom