From: Mikhail Golubev <Mikhail.Golubev@opensynergy.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>
Cc: virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org,
Anton Yakovlev <Anton.Yakovlev@opensynergy.com>,
Mikhail Golubev <Mikhail.Golubev@opensynergy.com>
Subject: [RFC PATCH] virtio: do not reset stateful devices on resume
Date: Tue, 14 Dec 2021 17:33:05 +0100 [thread overview]
Message-ID: <20211214163249.GA253555@opensynergy.com> (raw)
From: Anton Yakovlev <Anton.Yakovlev@opensynergy.com>
We assume that stateful devices can maintain their state while
suspended. And for this reason they don't have a freeze callback. If
such a device is reset during resume, the device state/context will be
lost on the device side. And the virtual device will stop working.
Signed-off-by: Anton Yakovlev <Anton.Yakovlev@opensynergy.com>
Signed-off-by: Mikhail Golubev <mikhail.golubev@opensynergy.com>
---
drivers/virtio/virtio.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 236081afe9a2..defa15b56eb8 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -472,6 +472,13 @@ int virtio_device_restore(struct virtio_device *dev)
struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
int ret;
+ /* Short path for stateful devices. Here we assume that if the device
+ * does not have a freeze callback, its state was not changed when
+ * suspended.
+ */
+ if (drv && !drv->freeze)
+ goto on_config_enable;
+
/* We always start by resetting the device, in case a previous
* driver messed it up. */
dev->config->reset(dev);
@@ -503,6 +510,7 @@ int virtio_device_restore(struct virtio_device *dev)
/* Finally, tell the device we're all set */
virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
+on_config_enable:
virtio_config_enable(dev);
return 0;
--
2.34.1
--
next reply other threads:[~2021-12-14 16:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-14 16:33 Mikhail Golubev [this message]
2021-12-14 23:26 ` [RFC PATCH] virtio: do not reset stateful devices on resume Michael S. Tsirkin
2021-12-15 17:27 ` Mikhail Golubev
2021-12-16 2:55 ` Jason Wang
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=20211214163249.GA253555@opensynergy.com \
--to=mikhail.golubev@opensynergy.com \
--cc=Anton.Yakovlev@opensynergy.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@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