提交 9b84512c 编写于 作者: J Johannes Berg 提交者: Richard Weinberger

um: virtio: disable VQs during suspend

If the system is suspended, the device shouldn't be able to send
anything to it. Disable virtqueues in suspend to simulate this,
and as we might be only using s2idle (kernel services are still
on), prevent sending anything on them as well.
Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
Signed-off-by: NRichard Weinberger <richard@nod.at>
上级 10c2b5ae
...@@ -65,6 +65,7 @@ struct virtio_uml_vq_info { ...@@ -65,6 +65,7 @@ struct virtio_uml_vq_info {
vq_callback_t *callback; vq_callback_t *callback;
struct time_travel_event defer; struct time_travel_event defer;
#endif #endif
bool suspended;
}; };
extern unsigned long long physmem_size, highmem; extern unsigned long long physmem_size, highmem;
...@@ -725,6 +726,9 @@ static bool vu_notify(struct virtqueue *vq) ...@@ -725,6 +726,9 @@ static bool vu_notify(struct virtqueue *vq)
const uint64_t n = 1; const uint64_t n = 1;
int rc; int rc;
if (info->suspended)
return true;
time_travel_propagate_time(); time_travel_propagate_time();
if (info->kick_fd < 0) { if (info->kick_fd < 0) {
...@@ -1288,6 +1292,36 @@ static const struct of_device_id virtio_uml_match[] = { ...@@ -1288,6 +1292,36 @@ static const struct of_device_id virtio_uml_match[] = {
}; };
MODULE_DEVICE_TABLE(of, virtio_uml_match); MODULE_DEVICE_TABLE(of, virtio_uml_match);
static int virtio_uml_suspend(struct platform_device *pdev, pm_message_t state)
{
struct virtio_uml_device *vu_dev = platform_get_drvdata(pdev);
struct virtqueue *vq;
virtio_device_for_each_vq((&vu_dev->vdev), vq) {
struct virtio_uml_vq_info *info = vq->priv;
info->suspended = true;
vhost_user_set_vring_enable(vu_dev, vq->index, false);
}
return 0;
}
static int virtio_uml_resume(struct platform_device *pdev)
{
struct virtio_uml_device *vu_dev = platform_get_drvdata(pdev);
struct virtqueue *vq;
virtio_device_for_each_vq((&vu_dev->vdev), vq) {
struct virtio_uml_vq_info *info = vq->priv;
info->suspended = false;
vhost_user_set_vring_enable(vu_dev, vq->index, true);
}
return 0;
}
static struct platform_driver virtio_uml_driver = { static struct platform_driver virtio_uml_driver = {
.probe = virtio_uml_probe, .probe = virtio_uml_probe,
.remove = virtio_uml_remove, .remove = virtio_uml_remove,
...@@ -1295,6 +1329,8 @@ static struct platform_driver virtio_uml_driver = { ...@@ -1295,6 +1329,8 @@ static struct platform_driver virtio_uml_driver = {
.name = "virtio-uml", .name = "virtio-uml",
.of_match_table = virtio_uml_match, .of_match_table = virtio_uml_match,
}, },
.suspend = virtio_uml_suspend,
.resume = virtio_uml_resume,
}; };
static int __init virtio_uml_init(void) static int __init virtio_uml_init(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册