From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2851606A322 for ; Fri, 4 Dec 2026 08:00:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NqEy4lRK Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 61DB1112D39; Fri, 4 Dec 2026 08:00:00 +0000 (UTC) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01F2E10EB76 for ; Thu, 3 Dec 2026 21:21:33 +0000 (UTC) Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-843cf077f10so454532a34.1 for ; Thu, 03 Dec 2026 13:21:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796332893; x=1796937693; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=E7hlqVJk1RADpe4Qdsn2CxbEKlL0rKQ8KKfHU/NxgbY=; b=NqEy4lRKTd+kuQfEwuNP2OsXe37oKCyRmEATO5phvZePGfNDj63TqGwZxldkPFkcu5 UWA6wmjrlFZYnMjeE4QUn1nBjRrU1mrYS5vSlY+FIuxrrKaPefEeRe0FE17/Fo81a4co I+2+IMwi3ROv6j/dPqg6W3PsBUSOVLx9/II+0he2vdQ1cUGIqAZFSgd3O2GBNcPZxFD2 ySZUH+gU/U3SXZp/gzVP/mdaKr6UtmVEKOphMzoy/Uky4T7RxNmZeYB78Yil2iJmqg8U qsx+SI83H+48jwNBu0lMsIsyJA8UE81c5nldaK7OmbZSlRDAsUfQC8BhDiXuiamkByE+ A0Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796332893; x=1796937693; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=E7hlqVJk1RADpe4Qdsn2CxbEKlL0rKQ8KKfHU/NxgbY=; b=OMIS+xjQaLCK3N9jm8HyACkXvmdr4tXbta6Xxk3v0a123xYo5YUMGfFLEZroWRS0Ve ponLiqXJkWKfJzSn4OTHErZTOc6aWuPLJyK9vCT2V5jhiRe31QUWSC/kbKEZ1N8sby1E WIhcYwR1PHdskXICbiFIGyhd+Eli3Lcw9Q1dR279dbTR7YxWj7kPelR2t+LRJ4BVWlq7 DL+QlMzUJHgOYdsxCIXwwPhhgRmFUl/Qs7IXrAV7oBtRN5gDM20scpovFdqcfAnj8Qrv bSW+JxIdDagwyY4CFC6rn2Dl62KafB99TfZZFbP+H3nQEML6ZOwb2Ge8j6Ge2yhbcqwN ux5w== X-Forwarded-Encrypted: i=1; AL+hErExa/5RpgP7522jhKr0UeFWf6eoEU1MDzyV17PT4Fs42coOeonCS4n10QZq5RM4UP3QvlE0Q3X1PCw=@lists.freedesktop.org X-Gm-Message-State: APuU4Z+mXeLtKIVd5VezEumYfpyXPERD/Xdm82cB3SAgbQsPnZGKF2gS sXo75u4ZyQU+/Vv+/i7jWA2Fi0KKBdaTSI5j9VX14RaH4XrGIN23DeQL X-Gm-Gg: AZFdTZcsgXKxbqfs0TqRQJq1fkGlSKXJgAb5vMTX63rDoYv6194ZZzt6BQbDAJVT1hS ukGMu1CY/KaRqoyEMtZcBGY/iEkxajE774trSoPfyr2SYHfACqCQzQxE9GL0Lajx13zqOMnFHuD ool2KAX04ku/DaNYfbwmf1oEf2SzIGfHogoMDpf38Z1QQe5wibFGlNPT6c7S/MDaojMsAtAvQA8 CT2QKuIEbjZCwVojONeQ84MRGi25RFQBgCkPaVQR0QTQ3msIjNZdwD+LeMmMvEtQIb0w24hDJh3 ov4NEoj7BNSe7SMBqzfCbPcI0NVC07OuUSLiFU45s10KA0Qs6/Qvvziakns/1UESkHvmaZoiv0Z i6KwRG5pYe9S4Ut8AIxkIFPyNwPXUzPq6l8CUERddk7swFg42DY09YYPHfoXAtNKMPW2lgwzYJQ iJJ19JnyhXxb3U2wqRWgiQt0G7Zu2W7hlRlbd4xiIGPfVvae9W1iFG3f4GHWgDFnDapRrZKschU 697FFFQHUDLYEDgZ5NdaOaohEmcXD2yKmYYTTbr/upLBbrmE3xZ878R43xjZwV1/L4/O2Kk3eE8 FS0FkhmH5OciAgkb+xeWHA9w2jzVSuhEGasJkY91T3/eYcZ37Jw23gTcjlq2/WtJjZapmGyBbAJ oXpXiirUDG1vBwwyYftSdZbViPYKsrJfUGbINeag3bfH2npn7lptInnp7SdeSXPaGMN4= X-Received: by 2002:a05:6830:4388:b0:862:a0ce:f557 with SMTP id 46e09a7af769-863f8914f29mr105169a34.4.1796332893181; Thu, 03 Dec 2026 13:21:33 -0800 (PST) Received: from tempest-testimage-cc-centos9-stream-server-1191361818 (chi-dyn-129-114-108-164.tacc.chameleoncloud.org. [129.114.108.164]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f81fc6d4sm149221a34.11.2026.12.03.13.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 13:21:32 -0800 (PST) From: Yuho Choi To: Dmitry Osipenko , David Airlie , Gerd Hoffmann Cc: Gurchetan Singh , Chia-I Wu , dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, Yuho Choi Subject: [PATCH] drm/virtio: Reset device before deleting virtqueues on init failure Date: Thu, 3 Dec 2026 21:21:18 +0000 Message-ID: <20261203212127.2147347-2-oss.patchbox@gmail.com> X-Mailer: git-send-email 2.56.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 04 Dec 2026 07:59:45 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 --- 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