]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
virtio: Fix virtio initialization sequence
authorChristian Pötzsch <christian.poetzsch@kernkonzept.com>
Tue, 10 Mar 2026 14:16:42 +0000 (08:16 -0600)
committerTom Rini <trini@konsulko.com>
Wed, 25 Mar 2026 20:33:00 +0000 (14:33 -0600)
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>
drivers/virtio/virtio-uclass.c
test/dm/virtio_device.c

index ac563991b90f1ecb84b00eb61bf581ce5ee0fac3..c36e9e9b3a77b925194e2f8b662375ac843a24a9 100644 (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);
 
index 53414e4d3a4748f3cb04df5eef338dfaa1296b34..c2cd0630d9738e1101e88e8293c4b8a8bf4a19ab 100644 (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;