virtio: console: tell host of open ports after resume from s3/s4
[linux-flexiantxendom0-3.2.10.git] / drivers / char / virtio_console.c
index 614b84d..cdf2f54 100644 (file)
@@ -1038,12 +1038,6 @@ static struct attribute_group port_attribute_group = {
        .attrs = port_sysfs_entries,
 };
 
-static int debugfs_open(struct inode *inode, struct file *filp)
-{
-       filp->private_data = inode->i_private;
-       return 0;
-}
-
 static ssize_t debugfs_read(struct file *filp, char __user *ubuf,
                            size_t count, loff_t *offp)
 {
@@ -1087,7 +1081,7 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf,
 
 static const struct file_operations port_debugfs_ops = {
        .owner = THIS_MODULE,
-       .open  = debugfs_open,
+       .open  = simple_open,
        .read  = debugfs_read,
 };
 
@@ -1854,10 +1848,18 @@ static int virtcons_freeze(struct virtio_device *vdev)
 
        vdev->config->reset(vdev);
 
+       virtqueue_disable_cb(portdev->c_ivq);
        cancel_work_sync(&portdev->control_work);
+       /*
+        * Once more: if control_work_handler() was running, it would
+        * enable the cb as the last step.
+        */
+       virtqueue_disable_cb(portdev->c_ivq);
        remove_controlq_data(portdev);
 
        list_for_each_entry(port, &portdev->ports, list) {
+               virtqueue_disable_cb(port->in_vq);
+               virtqueue_disable_cb(port->out_vq);
                /*
                 * We'll ask the host later if the new invocation has
                 * the port opened or closed.
@@ -1893,6 +1895,13 @@ static int virtcons_restore(struct virtio_device *vdev)
 
                /* Get port open/close status on the host */
                send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 1);
+
+               /*
+                * If a port was open at the time of suspending, we
+                * have to let the host know that it's still open.
+                */
+               if (port->guest_connected)
+                       send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
        }
        return 0;
 }