* [RFC PATCH] virtio: do not reset stateful devices on resume
@ 2021-12-14 16:33 Mikhail Golubev
2021-12-14 23:26 ` Michael S. Tsirkin
0 siblings, 1 reply; 4+ messages in thread
From: Mikhail Golubev @ 2021-12-14 16:33 UTC (permalink / raw)
To: Michael S. Tsirkin, Jason Wang
Cc: virtualization, linux-kernel, Anton Yakovlev, Mikhail Golubev
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
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] virtio: do not reset stateful devices on resume
2021-12-14 16:33 [RFC PATCH] virtio: do not reset stateful devices on resume Mikhail Golubev
@ 2021-12-14 23:26 ` Michael S. Tsirkin
2021-12-15 17:27 ` Mikhail Golubev
0 siblings, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2021-12-14 23:26 UTC (permalink / raw)
To: Mikhail Golubev; +Cc: Jason Wang, virtualization, linux-kernel, Anton Yakovlev
On Tue, Dec 14, 2021 at 05:33:05PM +0100, Mikhail Golubev wrote:
> 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>
A bit more specific? Which configs does this patch fix?
> ---
> 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
>
>
> --
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] virtio: do not reset stateful devices on resume
2021-12-14 23:26 ` Michael S. Tsirkin
@ 2021-12-15 17:27 ` Mikhail Golubev
2021-12-16 2:55 ` Jason Wang
0 siblings, 1 reply; 4+ messages in thread
From: Mikhail Golubev @ 2021-12-15 17:27 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Mikhail Golubev, Jason Wang, virtualization, linux-kernel,
Anton Yakovlev
The 12/14/2021 18:26, Michael S. Tsirkin wrote:
> On Tue, Dec 14, 2021 at 05:33:05PM +0100, Mikhail Golubev wrote:
> > 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>
>
> A bit more specific? Which configs does this patch fix?
We had encountered an issue related to 'stateful' GPU 3d (virglrenderer) and
video (gstreamer) devices.
BR,
Mikhail
>
> > ---
> > 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
> >
> >
> > --
>
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] virtio: do not reset stateful devices on resume
2021-12-15 17:27 ` Mikhail Golubev
@ 2021-12-16 2:55 ` Jason Wang
0 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2021-12-16 2:55 UTC (permalink / raw)
To: Mikhail Golubev
Cc: Michael S. Tsirkin, Mikhail Golubev, virtualization,
linux-kernel, Anton Yakovlev, Gerd Hoffmann, Stefan Hajnoczi
On Thu, Dec 16, 2021 at 1:27 AM Mikhail Golubev <mgo@opensynergy.com> wrote:
>
> The 12/14/2021 18:26, Michael S. Tsirkin wrote:
> > On Tue, Dec 14, 2021 at 05:33:05PM +0100, Mikhail Golubev wrote:
> > > 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>
> >
> > A bit more specific? Which configs does this patch fix?
>
> We had encountered an issue related to 'stateful' GPU 3d (virglrenderer) and
> video (gstreamer) devices.
Adding Gerd and Stefan.
I wonder if we suffer from a similar issue with virtio-fs.
Thanks
>
> BR,
> Mikhail
>
> >
> > > ---
> > > 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
> > >
> > >
> > > --
> >
>
> --
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-16 2:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 16:33 [RFC PATCH] virtio: do not reset stateful devices on resume Mikhail Golubev
2021-12-14 23:26 ` Michael S. Tsirkin
2021-12-15 17:27 ` Mikhail Golubev
2021-12-16 2:55 ` Jason Wang
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).