diff options
author | Philip Chen <philipchen@chromium.org> | 2024-08-15 00:46:17 +0000 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2024-11-12 18:07:24 -0500 |
commit | 76f0d870e75e0b00843668ace7603a47890cb9ff (patch) | |
tree | d05c209e21a9d017d81bd9d54f5f585caa898212 | |
parent | 35025963326e44d8bced3eecd42d2f040f4f0024 (diff) | |
download | lwn-76f0d870e75e0b00843668ace7603a47890cb9ff.tar.gz lwn-76f0d870e75e0b00843668ace7603a47890cb9ff.zip |
virtio_pmem: Add freeze/restore callbacks
Add basic freeze/restore PM callbacks to support hibernation (S4):
- On freeze, delete vq and quiesce the device to prepare for
snapshotting.
- On restore, re-init vq and mark DRIVER_OK.
Signed-off-by: Philip Chen <philipchen@chromium.org>
Message-Id: <20240815004617.2325269-1-philipchen@chromium.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | drivers/nvdimm/virtio_pmem.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/nvdimm/virtio_pmem.c b/drivers/nvdimm/virtio_pmem.c index c9b97aeabf85..2396d19ce549 100644 --- a/drivers/nvdimm/virtio_pmem.c +++ b/drivers/nvdimm/virtio_pmem.c @@ -143,6 +143,28 @@ static void virtio_pmem_remove(struct virtio_device *vdev) virtio_reset_device(vdev); } +static int virtio_pmem_freeze(struct virtio_device *vdev) +{ + vdev->config->del_vqs(vdev); + virtio_reset_device(vdev); + + return 0; +} + +static int virtio_pmem_restore(struct virtio_device *vdev) +{ + int ret; + + ret = init_vq(vdev->priv); + if (ret) { + dev_err(&vdev->dev, "failed to initialize virtio pmem's vq\n"); + return ret; + } + virtio_device_ready(vdev); + + return 0; +} + static unsigned int features[] = { VIRTIO_PMEM_F_SHMEM_REGION, }; @@ -155,6 +177,8 @@ static struct virtio_driver virtio_pmem_driver = { .validate = virtio_pmem_validate, .probe = virtio_pmem_probe, .remove = virtio_pmem_remove, + .freeze = virtio_pmem_freeze, + .restore = virtio_pmem_restore, }; module_virtio_driver(virtio_pmem_driver); |