From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796332894; b=M59hU2qJAos6+H84/8KPmqjfRJZfpXEycm/eO2dHFFpIU//U6/RTRLXpaHlBcDrD0z/F Kh7UCnHIMwarJH0LvFZw3REPhQxw4IyR+YUXrLRr7WufvFekcshfWMkRq178kGX0V0DU7 HLEfHPjMJFe77+l90eriptdMjLS+amDOsEJj6eytB+ur+ZiIIc8s2vRpKw5WIBRoEjxMV 1LkAXp6C4RU+tFRsCrIyb27xic0EkOC1HMr+q4HC2AmuIG6uuyWNH2akK1YxKPEpxomo8 BMg25B4uBCMwM0rlR4vMaMx1oZ1aa2Y+k73IQW0js7xmySmJnm3VjkFOPc4S83zqu8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796332894; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=E7hlqVJk1RADpe4Qdsn2CxbEKlL0rKQ8KKfHU/NxgbY=; b=NVDprFtqGoqq3FkQJoDpIBT9Qbl/1Uw1GLHEGLaN5bbu7wW2IAmAclTpqK/wFFk/hqMx +HR80rfpRB2DEjtC0JeMM+PHOWkwx+vJqKre2QUMFlSvUlxpWr/+0Yox2XMyIPICqs+Ju Eq8fkJZxBLN+402w7IVDDVjS/yIQlgHm1DqYluJsef/V0+wR0N9BhsXeF07TpB6q+J2lQ NdKHz/gePbtej24iNvMO5T9jPqby5oNf7xSdbbu/6VNPMgGt0J7cmBiRordDW6rUyEtEA bCGbQfZCSuR5f+enYyiFYAhFG4aiZFCQIPSkeCNPSRZBT0bvBVo/LhJ2hMJeKReVhCw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=TesRfFUh; arc=none smtp.remote-ip=209.85.210.43 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46780606A32D for ; Thu, 3 Dec 2026 21:21:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 46780606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=TesRfFUh Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-862b3938d98so164619a34.3 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.linux.dev; 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=TesRfFUhdetZYP52kuPPYBBGRmLK02WMB9TJbTU09084/eDa9VxyBK5Si3dakDuUUG oCsg8ab+1Pbq0eE9tdu2DGa7t4aILyk4D9SUcQkfdK8VRzuERLlZxMVw/SPb/g4fsg3y T3lIAXsR1cSsaXihE71gzhtXUIEgAQnjGb0SZbMN3bnVgj1I7g3dVRJnwutYPILHzQFH k5ZJXg6gbirrvOzKV1Zm660rif0fU6rp5xXQlQWfjQWL8bdTCcyOIprLpQELkQanmhcj MfUvd79bMsTFzu3n+5CI7i3dp3NEwuKIGjmx9fZfCtKaTLv2QqtTIPJ5MRnMjMsxRGg4 XTMA== 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=Kg5TQP0HU3ht9gelPfIeXqkTBgWpTo0nWBXEnQ7qE44Ez5Py5TbStNN1TgW8dkm+LS EJl0aMVxlWIipnzX6jij6x5q2lSq/0Mi8x1D1HYYWvVZsjWfhiVPsl1cp8okG5NUMVev /RdODXXCNpj6PWAKmly/MD1ncG7MGWSOdCK57856rkVMWW9LDvw+C28Y3kbJg1OLr5iI Ku4enA96RpVBtdMdYhT4yi9+oFVd4UPC+4SlfoKhKUpiqh0zGgT7YZ+ZMuE6+f5qFTB1 2nMU1hyQcMKePEHoCvq+qaZvvCUFPi969+cCE75jVYjqGJWrUbF2X6UbJhX+fjM3my6u hvvQ== X-Forwarded-Encrypted: i=1; AL+hErGq3Kv02TgUjbJ8eR4x10jzRsoMWNW3IXJqDo2y2jIyrgrnQeD0gdIMKOv4iCK/iHwSkVg9sm/FtLjQCpskbg==@lists.linux.dev X-Gm-Message-State: APuU4Z/XGSRyq3abFzbgDb+ys9H0wkSbAbdn6ipb3kxkxYcxImZiqrjJ P9KldJVuku+oeBjpjY9hOmG/WqNQbBz8FloVaqb2kN6MbP2fMQW4RdIn X-Gm-Gg: AZFdTZeo4ORIopBrzfUFwFhqgpC0UTld0ZLunmVDwxwpJNARevTNTurYu1Li4wz3nOm JCHYaZImXJsmLG+7MBUkeUhqCnqQSOcWHdB5KDWjzkq98lpPc5Qkm13T6G5D2bDjQZAVlZFS+gm dPZ4qTIJrckFWDI9Np1WEp6TgEU6p7RTUX1yRk8PijKSGzvn/Ic5dSHolavTQxlBJx1CTasbdPW ZsjRX85TVQDLDvvsp3FIKMs//EaA/8nW6PFu/02wsWR4BpvLHDZ8sxIvJMCzXTzDOfLFq4j04b9 hsatOYhDGk6b/I3N7a7jHLfvmkB0nNksFB6meuDT+5OkO/NCBcvSAWpZwvaVfA+OM2+ePYh8nEK 8g7mtwBu/qNxjo6ipKfkPz7yxx6mUEn4NgMzy7VaU7QX9yKFSg4XBQ3Mio9z8LVW3Y7Dmr33Q15 5ZIxkGFHMvccGeHEKS+RIardXV+Fbz/LHiN4Acgw1FQaN8kdJO8Xn3boimc5cLoSZaIknkTJQ5U B4zKHetCijka8dEOFXzv4GYDino+YgtwODagkgPfzGPnCghAV+/16QnmaArBGTP3S4Jmo7PGkVe VZZFx0vybXzdwsM1BHUIhip0IYHyflQORkfJD4AbNQZuaoltS2dm73krbon1eyv4xVGVsVYq3QT eNqnqpNEcpJY/M9kbNrl0tSYX33exuNeTOjxQ7zrat08h/7Smq9auA4/mKqy8RZz8qWk= 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-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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