
From: Simon Glass <sjg@chromium.org> At present virtio devices are acknowleged when bound. This results in a call to virtio_set_status() which uses device-private data in several cases, e.g. in virtio_pci_get_status() This data is only allocated when the device is probed, so the access is either ignored (on QEMU) or results in a crash (on sandbox). Acknowledging the device so early does not seem to be necessary. Move it to the pre-probe function instead. If we later find it necessary to acknowledge the device while binding, we can update the uclass and drivers to use plat data instead of priv. Signed-off-by: Simon Glass <sjg@chromium.org> --- drivers/virtio/virtio-uclass.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c index 17ef47df030..19728fdbe89 100644 --- a/drivers/virtio/virtio-uclass.c +++ b/drivers/virtio/virtio-uclass.c @@ -257,14 +257,6 @@ static int virtio_uclass_post_probe(struct udevice *udev) return 0; } -static int virtio_uclass_child_post_bind(struct udevice *vdev) -{ - /* Acknowledge that we've seen the device */ - virtio_add_status(vdev, VIRTIO_CONFIG_S_ACKNOWLEDGE); - - return 0; -} - static int virtio_uclass_child_pre_probe(struct udevice *vdev) { struct virtio_dev_priv *uc_priv = dev_get_uclass_priv(vdev->parent); @@ -278,6 +270,9 @@ static int virtio_uclass_child_pre_probe(struct udevice *vdev) if (device_get_uclass_id(vdev) == UCLASS_BOOTDEV) return 0; + /* Acknowledge that we've seen the device */ + virtio_add_status(vdev, VIRTIO_CONFIG_S_ACKNOWLEDGE); + /* * Save the real virtio device (eg: virtio-net, virtio-blk) to * the transport (parent) device's uclass priv for future use. @@ -391,7 +386,6 @@ UCLASS_DRIVER(virtio) = { .flags = DM_UC_FLAG_SEQ_ALIAS, .pre_probe = virtio_uclass_pre_probe, .post_probe = virtio_uclass_post_probe, - .child_post_bind = virtio_uclass_child_post_bind, .child_pre_probe = virtio_uclass_child_pre_probe, .child_post_probe = virtio_uclass_child_post_probe, .per_device_auto = sizeof(struct virtio_dev_priv), -- 2.43.0