dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Li Zetao <lizetao1@huawei.com>
To: <lizetao1@huawei.com>
Cc: lucho@ionkov.net, david@redhat.com, jasowang@redhat.com,
	linux_oss@crudebyte.com, pmorel@linux.vnet.ibm.com,
	dri-devel@lists.freedesktop.org, gurchetansingh@chromium.org,
	edumazet@google.com, kraxel@redhat.com, kuba@kernel.org,
	pabeni@redhat.com, asmadeus@codewreck.org, st@redhat.com,
	ericvh@gmail.com, rusty@rustcorp.com.au,
	linux-block@vger.kernel.org,
	v9fs-developer@lists.sourceforge.net, stefanha@redhat.com,
	airlied@redhat.com, cornelia.huck@de.ibm.com,
	virtualization@lists.linux-foundation.org, axboe@kernel.dk,
	pankaj.gupta.linux@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, pbonzini@redhat.com,
	davem@davemloft.net
Subject: [PATCH v2 5/5] drm/virtio: Fix probe failed when modprobe virtio_gpu
Date: Wed, 30 Nov 2022 00:06:15 +0800	[thread overview]
Message-ID: <20221129160615.3343036-6-lizetao1@huawei.com> (raw)
In-Reply-To: <20221129160615.3343036-1-lizetao1@huawei.com>

When doing the following test steps, an error was found:
  step 1: modprobe virtio_gpu succeeded
    # modprobe virtio_gpu      <-- OK

  step 2: fault injection in virtio_gpu_alloc_vbufs()
    # modprobe -r virtio_gpu   <-- OK
    # ...
      CPU: 0 PID: 1714 Comm: modprobe Not tainted 6.1.0-rc7-dirty
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
      Call Trace:
       <TASK>
       should_fail_ex.cold+0x1a/0x1f
       ...
       kmem_cache_create+0x12/0x20
       virtio_gpu_alloc_vbufs+0x2f/0x90 [virtio_gpu]
       virtio_gpu_init.cold+0x659/0xcad [virtio_gpu]
       virtio_gpu_probe+0x14f/0x260 [virtio_gpu]
       virtio_dev_probe+0x608/0xae0
       ?...
       </TASK>
      kmem_cache_create_usercopy(virtio-gpu-vbufs) failed with error -12

  step 3: modprobe virtio_gpu failed
    # modprobe virtio_gpu       <-- failed
      failed to find virt queues
      virtio_gpu: probe of virtio6 failed with error -2

The root cause of the problem is that the virtqueues are not
stopped on the error handling path when virtio_gpu_alloc_vbufs()
fails in virtio_gpu_init(), resulting in an error "-ENOENT"
returned in the next modprobe call in setup_vq().

virtio_pci_modern_device uses virtqueues to send or
receive message, and "queue_enable" records whether the
queues are available. In vp_modern_find_vqs(), all queues
will be selected and activated, but once queues are enabled
there is no way to go back except reset.

Fix it by reset virtio device on error handling path. After
virtio_find_vqs() succeeded, all virtqueues should be stopped
on error handling path.

Fixes: dc5698e80cf7 ("Add virtio gpu driver.")
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: patch is new.

 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 27b7f14dae89..1a03e8e13b5b 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -255,6 +255,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;
-- 
2.25.1


  parent reply	other threads:[~2022-11-30  9:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221128021005.232105-1-lizetao1@huawei.com>
2022-11-29 16:06 ` [PATCH v2 0/5] Fix probe failed when modprobe modules Li Zetao
2022-11-29 16:06   ` [PATCH v2 1/5] 9p: Fix probe failed when modprobe 9pnet_virtio Li Zetao
2022-11-29 16:06   ` [PATCH v2 2/5] virtio-mem: Fix probe failed when modprobe virtio_mem Li Zetao
2022-11-29 16:06   ` [PATCH v2 3/5] virtio-input: Fix probe failed when modprobe virtio_input Li Zetao
2022-11-29 16:06   ` [PATCH v2 4/5] virtio-blk: Fix probe failed when modprobe virtio_blk Li Zetao
2022-11-29 16:06   ` Li Zetao [this message]
2022-11-29 17:08   ` [PATCH v2 0/5] Fix probe failed when modprobe modules Jens Axboe

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=20221129160615.3343036-6-lizetao1@huawei.com \
    --to=lizetao1@huawei.com \
    --cc=airlied@redhat.com \
    --cc=asmadeus@codewreck.org \
    --cc=axboe@kernel.dk \
    --cc=cornelia.huck@de.ibm.com \
    --cc=davem@davemloft.net \
    --cc=david@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=edumazet@google.com \
    --cc=ericvh@gmail.com \
    --cc=gurchetansingh@chromium.org \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux_oss@crudebyte.com \
    --cc=lucho@ionkov.net \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pankaj.gupta.linux@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=pmorel@linux.vnet.ibm.com \
    --cc=rusty@rustcorp.com.au \
    --cc=st@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=v9fs-developer@lists.sourceforge.net \
    --cc=virtualization@lists.linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).