From: Bin Meng <bin.meng@processmission.com>
To: U-Boot Mailing List <u-boot@lists.u-boot-project.org>
Cc: Bin Meng <bmeng.cn@gmail.com>, Simon Glass <sjg@chromium.org>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH 8/8] test: dm: Check virtio queue cleanup on device removal
Date: Thu, 15 Oct 2026 19:13:23 +0800 [thread overview]
Message-ID: <20261015111328.1269775-9-bin.meng@processmission.com> (raw)
In-Reply-To: <20261015111328.1269775-1-bin.meng@processmission.com>
Checking device status alone does not detect queues left allocated when
a virtio device is removed.
Probe the virtio child before removal so that it owns a real queue.
Verify that removal for DMA shutdown resets the child and releases its
queue. Reprobe it and check that the old queue is not retained, then
verify cleanup on normal removal.
Signed-off-by: Bin Meng <bin.meng@processmission.com>
---
test/dm/virtio_device.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/test/dm/virtio_device.c b/test/dm/virtio_device.c
index c2cd0630d97..64e09049ded 100644
--- a/test/dm/virtio_device.c
+++ b/test/dm/virtio_device.c
@@ -100,6 +100,7 @@ DM_TEST(dm_test_virtio_all_ops, UTF_SCAN_PDATA | UTF_SCAN_FDT);
static int dm_test_virtio_remove(struct unit_test_state *uts)
{
struct udevice *bus, *dev;
+ struct virtio_dev_priv *uc_priv;
u8 status;
/* check probe success */
@@ -110,16 +111,24 @@ static int dm_test_virtio_remove(struct unit_test_state *uts)
ut_assertok(device_find_first_child(bus, &dev));
ut_assertnonnull(dev);
- /* set driver status to VIRTIO_CONFIG_S_DRIVER_OK */
- ut_assertok(virtio_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK));
+ /* Probe the driver so removal must release a real queue */
+ ut_assertok(device_probe(dev));
+ uc_priv = dev_get_uclass_priv(bus);
+ ut_asserteq(1, list_count_nodes(&uc_priv->vqs));
/* check the device can be successfully removed */
- dev_or_flags(dev, DM_FLAG_ACTIVATED);
ut_asserteq(-EKEYREJECTED, device_remove(bus, DM_REMOVE_ACTIVE_ALL));
ut_asserteq(false, device_active(dev));
- virtio_get_status(dev, &status);
- ut_assertok(status);
+ ut_assertok(virtio_get_status(dev, &status));
+ ut_asserteq(0, status);
+ ut_assert(list_empty(&uc_priv->vqs));
+
+ /* Reprobing must not accumulate queues from the previous instance */
+ ut_assertok(device_probe(dev));
+ ut_asserteq(1, list_count_nodes(&uc_priv->vqs));
+ ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
+ ut_assert(list_empty(&uc_priv->vqs));
return 0;
}
--
2.53.0
prev parent reply other threads:[~2026-10-15 13:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 11:13 [PATCH 0/8] virtio: Fix virtqueue teardown and probe cleanup Bin Meng
2026-10-15 11:13 ` [PATCH 1/8] virtio: mmio: Fix private data lookup when deleting queues Bin Meng
2026-10-15 11:13 ` [PATCH 2/8] virtio: pci: Fix legacy " Bin Meng
2026-10-15 11:13 ` [PATCH 3/8] virtio: pci: Fix modern " Bin Meng
2026-10-15 11:13 ` [PATCH 4/8] virtio: Release virtqueues after device reset Bin Meng
2026-10-15 11:13 ` [PATCH 5/8] virtio: 9p: Reset the device before releasing its queues Bin Meng
2026-10-15 11:13 ` [PATCH 6/8] virtio: blk: Validate configuration before creating the virtqueue Bin Meng
2026-10-15 11:13 ` [PATCH 7/8] MAINTAINERS: Cover all virtio driver-model tests Bin Meng
2026-10-15 11:18 ` Quentin Schulz
2026-10-15 11:13 ` Bin Meng [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=20261015111328.1269775-9-bin.meng@processmission.com \
--to=bin.meng@processmission.com \
--cc=bmeng.cn@gmail.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.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 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.