From 935b357507729f57ee482dfaad5d6fcb6286ee09 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Thu, 22 Dec 2011 16:58:28 +0530 Subject: [PATCH] --- yaml --- r: 284247 b: refs/heads/master c: 2b8f41d846990c3c1c8addbaed2cf53c3ef91d25 h: refs/heads/master i: 284245: ab63b6aefe25fc94b5976147a7b84d6b77d464f2 284243: 4bf02df611c9cfc69ab25b5433c94c2486e93dde 284239: b8de77cd2a205cb64bfb835f2789bee06af43db6 v: v3 --- [refs] | 2 +- trunk/drivers/char/virtio_console.c | 58 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 7e1880142d09..a13099f56b33 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a0e2dbfc223028b72a1c193f94fcd3f67253ba4a +refs/heads/master: 2b8f41d846990c3c1c8addbaed2cf53c3ef91d25 diff --git a/trunk/drivers/char/virtio_console.c b/trunk/drivers/char/virtio_console.c index 9681ffd79904..614b84d38d7a 100644 --- a/trunk/drivers/char/virtio_console.c +++ b/trunk/drivers/char/virtio_console.c @@ -1844,6 +1844,60 @@ static unsigned int features[] = { VIRTIO_CONSOLE_F_MULTIPORT, }; +#ifdef CONFIG_PM +static int virtcons_freeze(struct virtio_device *vdev) +{ + struct ports_device *portdev; + struct port *port; + + portdev = vdev->priv; + + vdev->config->reset(vdev); + + cancel_work_sync(&portdev->control_work); + remove_controlq_data(portdev); + + list_for_each_entry(port, &portdev->ports, list) { + /* + * We'll ask the host later if the new invocation has + * the port opened or closed. + */ + port->host_connected = false; + remove_port_data(port); + } + remove_vqs(portdev); + + return 0; +} + +static int virtcons_restore(struct virtio_device *vdev) +{ + struct ports_device *portdev; + struct port *port; + int ret; + + portdev = vdev->priv; + + ret = init_vqs(portdev); + if (ret) + return ret; + + if (use_multiport(portdev)) + fill_queue(portdev->c_ivq, &portdev->cvq_lock); + + list_for_each_entry(port, &portdev->ports, list) { + port->in_vq = portdev->in_vqs[port->id]; + port->out_vq = portdev->out_vqs[port->id]; + + fill_queue(port->in_vq, &port->inbuf_lock); + + /* Get port open/close status on the host */ + send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 1); + } + return 0; +} +#endif + static struct virtio_driver virtio_console = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), @@ -1853,6 +1907,10 @@ static struct virtio_driver virtio_console = { .probe = virtcons_probe, .remove = virtcons_remove, .config_changed = config_intr, +#ifdef CONFIG_PM + .freeze = virtcons_freeze, + .restore = virtcons_restore, +#endif }; static int __init init(void)