From: Yuho Choi <oss.patchbox@gmail.com>
To: Dmitry Osipenko <dmitry.osipenko@collabora.com>,
David Airlie <airlied@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>
Cc: Gurchetan Singh <gurchetansingh@chromium.org>,
Chia-I Wu <olvaffe@gmail.com>,
dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev,
linux-kernel@vger.kernel.org, Yuho Choi <oss.patchbox@gmail.com>
Subject: [PATCH] drm/virtio: Reset device before deleting virtqueues on init failure
Date: Thu, 3 Dec 2026 21:21:18 +0000 [thread overview]
Message-ID: <20261203212127.2147347-2-oss.patchbox@gmail.com> (raw)
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
reply other threads:[~2026-12-03 21:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203212127.2147347-2-oss.patchbox@gmail.com \
--to=oss.patchbox@gmail.com \
--cc=airlied@redhat.com \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olvaffe@gmail.com \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox