]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i2c: virtio: mark device ready before registering the adapter
authorAlexis Bouzigues <BouziguesAlexis@JohnDeere.com>
Fri, 29 May 2026 14:28:14 +0000 (09:28 -0500)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 30 May 2026 13:56:07 +0000 (15:56 +0200)
virtio_i2c_probe() synchronously probes child i2c drivers on the bus,
but peripherals may use the bus at probe for tasks like reading a chip
id. The vhost-user-i2c backend stalls at such probes unless DRIVER_OK
is already set before the virtqueue is first kicked.

Set DRIVER_OK explicitly before i2c_add_adapter(), as done for the
same reason in commit f5866db64f34 ("virtio_console: enable VQs
early") and commit 71e4b8bf0482 ("virtio_rpmsg: set DRIVER_OK before
using device").

Signed-off-by: Alexis Bouzigues <BouziguesAlexis@JohnDeere.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
drivers/i2c/busses/i2c-virtio.c

index 7b0b0bff80005df4f75a59c127de774335577083..5da6fef92bec36f6d6996001da22e0183f5e6972 100644 (file)
@@ -222,6 +222,8 @@ static int virtio_i2c_probe(struct virtio_device *vdev)
         */
        ACPI_COMPANION_SET(&vi->adap.dev, ACPI_COMPANION(vdev->dev.parent));
 
+       virtio_device_ready(vdev);
+
        ret = i2c_add_adapter(&vi->adap);
        if (ret)
                virtio_i2c_del_vqs(vdev);