FROMLIST: virtio: do not reset stateful devices on resume
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> Bug: 180046477 Link: https://lore.kernel.org/all/20211214163249.GA253555@opensynergy.com/ Change-Id: I20410a5af8f73eebba1986965c347288ee07c0ab Signed-off-by: Mikhail Golubev <Mikhail.Golubev@opensynergy.com>
This commit is contained in:

committed by
Todd Kjos

parent
392cb940f6
commit
9180348b91
@@ -408,6 +408,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);
|
||||
@@ -439,6 +446,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;
|
||||
|
Reference in New Issue
Block a user