linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xie Yongji <xieyongji@bytedance.com>
To: mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com
Cc: amit@kernel.org, arei.gonglei@huawei.com, airlied@linux.ie,
	kraxel@redhat.com, jean-philippe@linaro.org, ohad@wizery.com,
	bjorn.andersson@linaro.org, david@redhat.com, vgoyal@redhat.com,
	miklos@szeredi.hu, lucho@ionkov.net, asmadeus@codewreck.org,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 07/15] virtio-net: Handle virtio_device_ready() failure
Date: Mon, 17 May 2021 17:34:20 +0800	[thread overview]
Message-ID: <20210517093428.670-8-xieyongji@bytedance.com> (raw)
In-Reply-To: <20210517093428.670-1-xieyongji@bytedance.com>

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@bytedance.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


  parent reply	other threads:[~2021-05-17  9:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  9:34 [RFC PATCH 00/15] Handle virtio_device_ready() failure Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 01/15] virtio_config: Add return value to virtio_device_ready() Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 02/15] virtio-blk: Handle virtio_device_ready() failure Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 03/15] virtio_console: " Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 04/15] virtio_crypto: " Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 05/15] drm/virtio: " Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 06/15] virtio-iommu: " Xie Yongji
2021-05-17  9:34 ` Xie Yongji [this message]
2021-05-17  9:34 ` [RFC PATCH 07/15] virtio-net: " Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 08/15] rpmsg: virtio: " Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 10/15] " Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 11/15] virtio-balloon: " Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 12/15] virtio-input: " Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 13/15] virtio-mem: " Xie Yongji
2021-05-17  9:48   ` David Hildenbrand
2021-05-17 10:08     ` Yongji Xie
2021-05-17  9:34 ` [RFC PATCH 14/15] virtiofs: " Xie Yongji
2021-05-17  9:34 ` [RFC PATCH 15/15] 9p/trans_virtio: " Xie Yongji
2021-05-17  9:53   ` asmadeus

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=20210517093428.670-8-xieyongji@bytedance.com \
    --to=xieyongji@bytedance.com \
    --cc=airlied@linux.ie \
    --cc=amit@kernel.org \
    --cc=arei.gonglei@huawei.com \
    --cc=asmadeus@codewreck.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=david@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jean-philippe@linaro.org \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=miklos@szeredi.hu \
    --cc=mst@redhat.com \
    --cc=ohad@wizery.com \
    --cc=stefanha@redhat.com \
    --cc=vgoyal@redhat.com \
    --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).