Skip to content

Commit 76f0d87

Browse files
Philip Chenmstsirkin
authored andcommitted
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>
1 parent 3502596 commit 76f0d87

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/nvdimm/virtio_pmem.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,28 @@ static void virtio_pmem_remove(struct virtio_device *vdev)
143143
virtio_reset_device(vdev);
144144
}
145145

146+
static int virtio_pmem_freeze(struct virtio_device *vdev)
147+
{
148+
vdev->config->del_vqs(vdev);
149+
virtio_reset_device(vdev);
150+
151+
return 0;
152+
}
153+
154+
static int virtio_pmem_restore(struct virtio_device *vdev)
155+
{
156+
int ret;
157+
158+
ret = init_vq(vdev->priv);
159+
if (ret) {
160+
dev_err(&vdev->dev, "failed to initialize virtio pmem's vq\n");
161+
return ret;
162+
}
163+
virtio_device_ready(vdev);
164+
165+
return 0;
166+
}
167+
146168
static unsigned int features[] = {
147169
VIRTIO_PMEM_F_SHMEM_REGION,
148170
};
@@ -155,6 +177,8 @@ static struct virtio_driver virtio_pmem_driver = {
155177
.validate = virtio_pmem_validate,
156178
.probe = virtio_pmem_probe,
157179
.remove = virtio_pmem_remove,
180+
.freeze = virtio_pmem_freeze,
181+
.restore = virtio_pmem_restore,
158182
};
159183

160184
module_virtio_driver(virtio_pmem_driver);

0 commit comments

Comments
 (0)