aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/virtio_console.c
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-05-05 16:35:08 -0400
committerRusty Russell <rusty@rustcorp.com.au>2010-05-19 08:45:51 -0400
commit9778829cffd4d8d68c7e457645f958a82d4c4d8b (patch)
tree3bf9ec66c8af66430b2aaf3d089d39c8b4338b30 /drivers/char/virtio_console.c
parent4038f5b767a610c5a5d92d7047755c663ead1568 (diff)
virtio: console: Store each console's size in the console structure
With support for multiple consoles, just using one {rows,cols} pair in the config space is not going to suffice. Store each console's size as part of the console struct. This changes the behaviour for one case when multiport is not enabled: when notifier_add_vio() is called, the console size is taken from that of the last config-space update instead of fetching it afresh from the config space. Also add a helper to update the size in the console struct as we'll need to use the same code to update the size via control messages when multiport support is enabled. Signed-off-by: Amit Shah <amit.shah@redhat.com> CC: Christian Borntraeger <borntraeger@de.ibm.com> CC: linuxppc-dev@ozlabs.org CC: Kusanagi Kouichi <slash@ac.auone-net.jp> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/char/virtio_console.c')
-rw-r--r--drivers/char/virtio_console.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 1e3f4674da4a..f1fe11a344e9 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -78,6 +78,9 @@ struct console {
78 /* The hvc device associated with this console port */ 78 /* The hvc device associated with this console port */
79 struct hvc_struct *hvc; 79 struct hvc_struct *hvc;
80 80
81 /* The size of the console */
82 struct winsize ws;
83
81 /* 84 /*
82 * This number identifies the number that we used to register 85 * This number identifies the number that we used to register
83 * with hvc in hvc_instantiate() and hvc_alloc(); this is the 86 * with hvc in hvc_instantiate() and hvc_alloc(); this is the
@@ -773,22 +776,14 @@ static int get_chars(u32 vtermno, char *buf, int count)
773static void resize_console(struct port *port) 776static void resize_console(struct port *port)
774{ 777{
775 struct virtio_device *vdev; 778 struct virtio_device *vdev;
776 struct winsize ws;
777 779
778 /* The port could have been hot-unplugged */ 780 /* The port could have been hot-unplugged */
779 if (!port) 781 if (!port || !is_console_port(port))
780 return; 782 return;
781 783
782 vdev = port->portdev->vdev; 784 vdev = port->portdev->vdev;
783 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) { 785 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE))
784 vdev->config->get(vdev, 786 hvc_resize(port->cons.hvc, port->cons.ws);
785 offsetof(struct virtio_console_config, cols),
786 &ws.ws_col, sizeof(u16));
787 vdev->config->get(vdev,
788 offsetof(struct virtio_console_config, rows),
789 &ws.ws_row, sizeof(u16));
790 hvc_resize(port->cons.hvc, ws);
791 }
792} 787}
793 788
794/* We set the configuration at this point, since we now have a tty */ 789/* We set the configuration at this point, since we now have a tty */
@@ -952,6 +947,15 @@ static const struct file_operations port_debugfs_ops = {
952 .read = debugfs_read, 947 .read = debugfs_read,
953}; 948};
954 949
950static void set_console_size(struct port *port, u16 rows, u16 cols)
951{
952 if (!port || !is_console_port(port))
953 return;
954
955 port->cons.ws.ws_row = rows;
956 port->cons.ws.ws_col = cols;
957}
958
955static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock) 959static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
956{ 960{
957 struct port_buffer *buf; 961 struct port_buffer *buf;
@@ -1000,6 +1004,8 @@ static int add_port(struct ports_device *portdev, u32 id)
1000 port->inbuf = NULL; 1004 port->inbuf = NULL;
1001 port->cons.hvc = NULL; 1005 port->cons.hvc = NULL;
1002 1006
1007 port->cons.ws.ws_row = port->cons.ws.ws_col = 0;
1008
1003 port->host_connected = port->guest_connected = false; 1009 port->host_connected = port->guest_connected = false;
1004 1010
1005 port->outvq_full = false; 1011 port->outvq_full = false;
@@ -1320,6 +1326,19 @@ static void config_intr(struct virtio_device *vdev)
1320 portdev = vdev->priv; 1326 portdev = vdev->priv;
1321 1327
1322 if (!use_multiport(portdev)) { 1328 if (!use_multiport(portdev)) {
1329 struct port *port;
1330 u16 rows, cols;
1331
1332 vdev->config->get(vdev,
1333 offsetof(struct virtio_console_config, cols),
1334 &cols, sizeof(u16));
1335 vdev->config->get(vdev,
1336 offsetof(struct virtio_console_config, rows),
1337 &rows, sizeof(u16));
1338
1339 port = find_port_by_id(portdev, 0);
1340 set_console_size(port, rows, cols);
1341
1323 /* 1342 /*
1324 * We'll use this way of resizing only for legacy 1343 * We'll use this way of resizing only for legacy
1325 * support. For newer userspace 1344 * support. For newer userspace
@@ -1327,7 +1346,7 @@ static void config_intr(struct virtio_device *vdev)
1327 * to indicate console size changes so that it can be 1346 * to indicate console size changes so that it can be
1328 * done per-port. 1347 * done per-port.
1329 */ 1348 */
1330 resize_console(find_port_by_id(portdev, 0)); 1349 resize_console(port);
1331 } 1350 }
1332} 1351}
1333 1352