* [PATCH] drm/virtio: Reset device before deleting virtqueues on init failure
@ 2026-12-03 21:21 Yuho Choi
0 siblings, 0 replies; only message 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] only message in thread
only message in thread, other threads:[~2026-12-03 21:21 UTC | newest]
Thread overview: (only message) (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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox