[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210517093428.670-9-xieyongji@bytedance.com>
Date: Mon, 17 May 2021 17:34:21 +0800
From: Xie Yongji <xieyongji@...edance.com>
To: mst@...hat.com, jasowang@...hat.com, stefanha@...hat.com
Cc: amit@...nel.org, arei.gonglei@...wei.com, airlied@...ux.ie,
kraxel@...hat.com, jean-philippe@...aro.org, ohad@...ery.com,
bjorn.andersson@...aro.org, david@...hat.com, vgoyal@...hat.com,
miklos@...redi.hu, lucho@...kov.net, asmadeus@...ewreck.org,
virtualization@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 07/15] virtio-net: Handle virtio_device_ready() failure
Now virtio_device_ready() will return error if we get
invalid status. Let's handle this case in both probe
and resume paths.
Signed-off-by: Xie Yongji <xieyongji@...edance.com>
---
drivers/net/virtio_net.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 01e54e99cae6..c4711e23af88 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -2341,6 +2341,7 @@ static void virtnet_freeze_down(struct virtio_device *vdev)
}
static int init_vqs(struct virtnet_info *vi);
+static void virtnet_del_vqs(struct virtnet_info *vi);
static int virtnet_restore_up(struct virtio_device *vdev)
{
@@ -2351,7 +2352,11 @@ static int virtnet_restore_up(struct virtio_device *vdev)
if (err)
return err;
- virtio_device_ready(vdev);
+ err = virtio_device_ready(vdev);
+ if (err) {
+ virtnet_del_vqs(vi);
+ return err;
+ }
if (netif_running(vi->dev)) {
for (i = 0; i < vi->curr_queue_pairs; i++)
@@ -3148,12 +3153,16 @@ static int virtnet_probe(struct virtio_device *vdev)
goto free_failover;
}
- virtio_device_ready(vdev);
+ err = virtio_device_ready(vdev);
+ if (err) {
+ pr_debug("virtio_net: enable virtio device failed\n");
+ goto free_unregister_netdev;
+ }
err = virtnet_cpu_notif_add(vi);
if (err) {
pr_debug("virtio_net: registering cpu notifier failed\n");
- goto free_unregister_netdev;
+ goto reset_virtio_device;
}
virtnet_set_queues(vi, vi->curr_queue_pairs);
@@ -3179,9 +3188,9 @@ static int virtnet_probe(struct virtio_device *vdev)
return 0;
-free_unregister_netdev:
+reset_virtio_device:
vi->vdev->config->reset(vdev);
-
+free_unregister_netdev:
unregister_netdev(dev);
free_failover:
net_failover_destroy(vi->failover);
--
2.11.0
Powered by blists - more mailing lists