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.

Signed-off-by: Christian Pötzsch <christian.poetzsch@kernkonzept.com>
Signed-off-by: Adam Lackorzynski <adam@l4re.org>
[trini: Add VIRTIO_CONFIG_S_ACKNOWLEDGE flag check to the test]
Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Christian Pötzsch
2026-03-10 08:16:42 -06:00
committed by Tom Rini
parent b8e6c5d0dd
commit 30e1733297
2 changed files with 4 additions and 0 deletions

View File

@@ -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);

View File

@@ -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;