* [PATCH] drm/virtio: Reset device before deleting virtqueues on init failure
@ 2026-12-03 21:21 Yuho Choi
2026-12-03 21:39 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-12-03 21:21 UTC (permalink / raw)
To: Dmitry Osipenko, David Airlie, Gerd Hoffmann
Cc: Gurchetan Singh, Chia-I Wu, dri-devel, virtualization,
linux-kernel, Yuho Choi
When virtio_gpu_alloc_vbufs() or virtio_gpu_modeset_init() fails,
virtio_gpu_init() deletes the virtqueues without resetting the device,
and the virtio core does not reset it after a failed probe either. On
virtio-pci modern the queues then stay enabled, so the next probe of the
device fails in setup_vq() with -ENOENT. Reset the device before
deleting the virtqueues, as virtio_gpu_deinit() does.
Fixes: dc5698e80cf7 ("Add virtio gpu driver.")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
An LLM helped me write and run this reproduction test.
Tested on drm-misc-fixes 502ea48d0d8f in a QEMU/KVM guest with
virtio-gpu-pci. A test-only module parameter made virtio_gpu_init()
fail once, before virtio_gpu_alloc_vbufs() or before
virtio_gpu_modeset_init(), and the device was then bound again
through sysfs. Without this patch every bind failed (3 of 3 runs for
each failure point):
[drm:virtio_gpu_init] *ERROR* failed to find virt queues
virtio_gpu virtio0: probe with driver virtio_gpu failed with error -2
With this patch the first bind succeeded each time and card0 appeared.
A failure after virtio_device_ready(), where the device is now reset
twice, was tested the same way and the next bind succeeded.
drivers/gpu/drm/virtio/virtgpu_kms.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 1d4d3bf46a20..c729545e41f5 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -326,6 +326,7 @@ int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
err_scanouts:
virtio_gpu_free_vbufs(vgdev);
err_vbufs:
+ virtio_reset_device(vgdev->vdev);
vgdev->vdev->config->del_vqs(vgdev->vdev);
err_vqs:
dev->dev_private = NULL;
base-commit: 502ea48d0d8fa5dd0c31dc449efb3d82deef8efe
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] drm/virtio: Reset device before deleting virtqueues on init failure
2026-12-03 21:21 [PATCH] drm/virtio: Reset device before deleting virtqueues on init failure Yuho Choi
@ 2026-12-03 21:39 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-03 21:39 UTC (permalink / raw)
To: Yuho Choi; +Cc: dri-devel, virtualization, Michael S. Tsirkin, Eugenio Perez
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/virtio: redundant double virtio_reset_device() in
virtio_gpu_init()
--
commit 4d07ab1dc65a97542b38fd22d37c228f75391c94
Author: Yuho Choi <oss.patchbox@gmail.com>
drm/virtio: Reset device before deleting virtqueues on init failure
This commit adds a virtio_reset_device() call in the err_vbufs error path
of virtio_gpu_init() so the device is reset before deleting virtqueues when
virtio_gpu_alloc_vbufs() or virtio_gpu_modeset_init() fails.
> diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
> index 1d4d3bf46a202..c729545e41f52 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_kms.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
> @@ -326,6 +326,7 @@ int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
> err_scanouts:
> virtio_gpu_free_vbufs(vgdev);
> err_vbufs:
> + virtio_reset_device(vgdev->vdev);
> vgdev->vdev->config->del_vqs(vgdev->vdev);
> err_vqs:
> dev->dev_private = NULL;
[Severity: Low]
Does the err_reset_device unwind path now call virtio_reset_device() twice?
When waiting for display info times out, virtio_gpu_init() jumps to
err_reset_device, calls virtio_reset_device(), and falls through into
err_vbufs to reset the device again before del_vqs(). The second call
repeats the transport reset and virtio_synchronize_cbs() unnecessarily.
Skipping the second virtio_reset_device() on the err_reset_device path by
jumping directly to del_vqs() after virtio_gpu_free_vbufs() would avoid
the redundant reset.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203212127.2147347-2-oss.patchbox@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 21:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 21:21 [PATCH] drm/virtio: Reset device before deleting virtqueues on init failure Yuho Choi
2026-12-03 21:39 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.