[PATCH v3 40/70] virtio: Avoid strange behaviour on removal

Simon Glass sjg at chromium.org
Tue Jan 17 18:47:50 CET 2023


This device does a check on removal which is better handled in the actual
test. Move it.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 drivers/virtio/virtio_sandbox.c | 13 -------------
 test/dm/virtio_device.c         |  3 +++
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/virtio/virtio_sandbox.c b/drivers/virtio/virtio_sandbox.c
index 5484ae3a1a0..cf7761c75ee 100644
--- a/drivers/virtio/virtio_sandbox.c
+++ b/drivers/virtio/virtio_sandbox.c
@@ -167,18 +167,6 @@ static int virtio_sandbox_probe(struct udevice *udev)
 	return 0;
 }
 
-/* check virtio device driver's remove routine was called to reset the device */
-static int virtio_sandbox_child_post_remove(struct udevice *vdev)
-{
-	u8 status;
-
-	virtio_get_status(vdev, &status);
-	if (status)
-		panic("virtio device was not reset\n");
-
-	return 0;
-}
-
 static const struct dm_virtio_ops virtio_sandbox1_ops = {
 	.get_config	= virtio_sandbox_get_config,
 	.set_config	= virtio_sandbox_set_config,
@@ -203,7 +191,6 @@ U_BOOT_DRIVER(virtio_sandbox1) = {
 	.of_match = virtio_sandbox1_ids,
 	.ops	= &virtio_sandbox1_ops,
 	.probe	= virtio_sandbox_probe,
-	.child_post_remove = virtio_sandbox_child_post_remove,
 	.priv_auto	= sizeof(struct virtio_sandbox_priv),
 };
 
diff --git a/test/dm/virtio_device.c b/test/dm/virtio_device.c
index b5c4523a028..fdda4da4178 100644
--- a/test/dm/virtio_device.c
+++ b/test/dm/virtio_device.c
@@ -100,6 +100,7 @@ DM_TEST(dm_test_virtio_all_ops, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 static int dm_test_virtio_remove(struct unit_test_state *uts)
 {
 	struct udevice *bus, *dev;
+	u8 status;
 
 	/* check probe success */
 	ut_assertok(uclass_first_device_err(UCLASS_VIRTIO, &bus));
@@ -117,6 +118,8 @@ static int dm_test_virtio_remove(struct unit_test_state *uts)
 	ut_asserteq(-EKEYREJECTED, device_remove(bus, DM_REMOVE_ACTIVE_ALL));
 
 	ut_asserteq(false, device_active(dev));
+	virtio_get_status(dev, &status);
+	ut_assertok(status);
 
 	return 0;
 }
-- 
2.39.0.246.g2a6d74b583-goog



More information about the U-Boot mailing list