All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yuho Choi" <oss.patchbox@gmail.com>
Cc: virtualization@lists.linux.dev,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v3] vdpa/vp_vdpa: Wait for device reset to complete
Date: Thu, 03 Dec 2026 15:40:18 +0000	[thread overview]
Message-ID: <sashiko-outbox-248133@kernel.org> (raw)
In-Reply-To: <20261203152530.1953781-2-oss.patchbox@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] vdpa/vp_vdpa: unbounded loop in vp_vdpa_reset() hangs on PCI
  surprise removal
--

commit 70fcb12db8da3c2444a449999ffa84aee5127406
Author: Yuho Choi <oss.patchbox@gmail.com>

vdpa/vp_vdpa: Wait for device reset to complete

This commit adds a polling loop in vp_vdpa_reset() to wait until
device_status reads back 0 after writing 0.

> diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c b/drivers/vdpa/virtio_pci/vp_vdpa.c
> index 646efd9384fba..eba82ff253ea3 100644
> --- a/drivers/vdpa/virtio_pci/vp_vdpa.c
> +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c

[ ... ]

> @@ -236,6 +237,9 @@ static int vp_vdpa_reset(struct vdpa_device *vdpa)
>  	u8 s = vp_vdpa_get_status(vdpa);
>  
>  	vp_modern_set_status(mdev, 0);
> +	/* Wait for the reset to complete */
> +	while (vp_modern_get_status(mdev))
> +		fsleep(1000);
>  
>  	if (s & VIRTIO_CONFIG_S_DRIVER_OK)
>  		vp_vdpa_free_irq(vp_vdpa);

[Severity: High]
Can this loop hang indefinitely when the PCI device is surprise-removed?

After surprise removal, MMIO reads in vp_modern_get_status() return 0xff,
which never satisfies the exit condition.  The uninterruptible loop then
spins forever without reaching vp_vdpa_free_irq().

Because PCI hot-unplug reaches vp_vdpa_reset() through vp_vdpa_remove() ->
vdpa_mgmtdev_unregister() -> vdpa_reset() while holding the global
vdpa_dev_lock and vdev->cf_lock for write, this hang permanently deadlocks
host-wide vDPA management and PCI removal, and skips the rest of teardown.

Unlike vp_reset(), vdpa_config_ops.reset returns an int.  Checking for
0xff or !pci_device_is_present(mdev->pci_dev) and bounding the wait with a
timeout while still calling vp_vdpa_free_irq() would avoid this deadlock.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203152530.1953781-2-oss.patchbox@gmail.com?part=1

      reply	other threads:[~2026-12-03 15:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 15:24 [PATCH v3] vdpa/vp_vdpa: Wait for device reset to complete Yuho Choi
2026-12-03 15:40 ` sashiko-bot [this message]

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=sashiko-outbox-248133@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=mst@redhat.com \
    --cc=oss.patchbox@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.