All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] virtio: console: Handle multiple console port resizes
@ 2010-05-05 20:35 Amit Shah
  2010-05-05 20:35 ` [PATCH 1/3] virtio: console: Resize console port 0 on config intr only if multiport is off Amit Shah
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Amit Shah @ 2010-05-05 20:35 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Amit Shah, Virtualization List

Hello,

This series adds resize support for multiple console ports. The size
for each console is stored in its structure and the host informs the
guest about size changes via the VIRTIO_CONSOLE_RESIZE control
message.

This is easily tested by the qemu patches provided by Kusanagi Kouichi
with some updates, which I will shortly send to the qemu-devel list.

Please apply,

	Amit.

Amit Shah (3):
  virtio: console: Resize console port 0 on config intr only if
    multiport is off
  virtio: console: Store each console's size in the console structure
  virtio: console: Accept console size along with resize control
    message

 drivers/char/virtio_console.c |   71 ++++++++++++++++++++++++++++++-----------
 1 files changed, 52 insertions(+), 19 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] virtio: console: Resize console port 0 on config intr only if multiport is off
  2010-05-05 20:35 [PATCH 0/3] virtio: console: Handle multiple console port resizes Amit Shah
  2010-05-05 20:35 ` [PATCH 1/3] virtio: console: Resize console port 0 on config intr only if multiport is off Amit Shah
@ 2010-05-05 20:35 ` Amit Shah
  2010-05-05 20:35   ` [PATCH 2/3] virtio: console: Store each console's size in the console structure Amit Shah
  2010-05-05 20:35   ` Amit Shah
  2010-05-06  2:27 ` [PATCH 0/3] virtio: console: Handle multiple console port resizes Rusty Russell
  2 siblings, 2 replies; 8+ messages in thread
From: Amit Shah @ 2010-05-05 20:35 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Amit Shah, Christian Borntraeger, Kusanagi Kouichi, linuxppc-dev,
	Virtualization List

When using multiport, we'll use control messages. Ensure we don't
accidentally update port 0 size on config interrupts.

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>
---
 drivers/char/virtio_console.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index a64558f..e2d05ea 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1319,13 +1319,16 @@ static void config_intr(struct virtio_device *vdev)
 
 	portdev = vdev->priv;
 
-	/*
-	 * We'll use this way of resizing only for legacy support.
-	 * For newer userspace (VIRTIO_CONSOLE_F_MULTPORT+), use
-	 * control messages to indicate console size changes so that
-	 * it can be done per-port
-	 */
-	resize_console(find_port_by_id(portdev, 0));
+	if (!use_multiport(portdev)) {
+		/*
+		 * We'll use this way of resizing only for legacy
+		 * support.  For newer userspace
+		 * (VIRTIO_CONSOLE_F_MULTPORT+), use control messages
+		 * to indicate console size changes so that it can be
+		 * done per-port.
+		 */
+		resize_console(find_port_by_id(portdev, 0));
+	}
 }
 
 static int init_vqs(struct ports_device *portdev)
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 1/3] virtio: console: Resize console port 0 on config intr only if multiport is off
  2010-05-05 20:35 [PATCH 0/3] virtio: console: Handle multiple console port resizes Amit Shah
@ 2010-05-05 20:35 ` Amit Shah
  2010-05-05 20:35 ` Amit Shah
  2010-05-06  2:27 ` [PATCH 0/3] virtio: console: Handle multiple console port resizes Rusty Russell
  2 siblings, 0 replies; 8+ messages in thread
From: Amit Shah @ 2010-05-05 20:35 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Amit Shah, Christian Borntraeger, Kusanagi Kouichi, linuxppc-dev,
	Virtualization List

When using multiport, we'll use control messages. Ensure we don't
accidentally update port 0 size on config interrupts.

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>
---
 drivers/char/virtio_console.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index a64558f..e2d05ea 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1319,13 +1319,16 @@ static void config_intr(struct virtio_device *vdev)
 
 	portdev = vdev->priv;
 
-	/*
-	 * We'll use this way of resizing only for legacy support.
-	 * For newer userspace (VIRTIO_CONSOLE_F_MULTPORT+), use
-	 * control messages to indicate console size changes so that
-	 * it can be done per-port
-	 */
-	resize_console(find_port_by_id(portdev, 0));
+	if (!use_multiport(portdev)) {
+		/*
+		 * We'll use this way of resizing only for legacy
+		 * support.  For newer userspace
+		 * (VIRTIO_CONSOLE_F_MULTPORT+), use control messages
+		 * to indicate console size changes so that it can be
+		 * done per-port.
+		 */
+		resize_console(find_port_by_id(portdev, 0));
+	}
 }
 
 static int init_vqs(struct ports_device *portdev)
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] virtio: console: Store each console's size in the console structure
  2010-05-05 20:35 ` Amit Shah
  2010-05-05 20:35   ` [PATCH 2/3] virtio: console: Store each console's size in the console structure Amit Shah
@ 2010-05-05 20:35   ` Amit Shah
  2010-05-05 20:35     ` [PATCH 3/3] virtio: console: Accept console size along with resize control message Amit Shah
  2010-05-05 20:35     ` Amit Shah
  1 sibling, 2 replies; 8+ messages in thread
From: Amit Shah @ 2010-05-05 20:35 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Amit Shah, Christian Borntraeger, Kusanagi Kouichi, linuxppc-dev,
	Virtualization List

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>
---
 drivers/char/virtio_console.c |   43 +++++++++++++++++++++++++++++-----------
 1 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index e2d05ea..ccfe68a 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -78,6 +78,9 @@ struct console {
 	/* The hvc device associated with this console port */
 	struct hvc_struct *hvc;
 
+	/* The size of the console */
+	struct winsize ws;
+
 	/*
 	 * This number identifies the number that we used to register
 	 * 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)
 static void resize_console(struct port *port)
 {
 	struct virtio_device *vdev;
-	struct winsize ws;
 
 	/* The port could have been hot-unplugged */
-	if (!port)
+	if (!port || !is_console_port(port))
 		return;
 
 	vdev = port->portdev->vdev;
-	if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) {
-		vdev->config->get(vdev,
-				  offsetof(struct virtio_console_config, cols),
-				  &ws.ws_col, sizeof(u16));
-		vdev->config->get(vdev,
-				  offsetof(struct virtio_console_config, rows),
-				  &ws.ws_row, sizeof(u16));
-		hvc_resize(port->cons.hvc, ws);
-	}
+	if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE))
+		hvc_resize(port->cons.hvc, port->cons.ws);
 }
 
 /* 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 = {
 	.read  = debugfs_read,
 };
 
+static void set_console_size(struct port *port, u16 rows, u16 cols)
+{
+	if (!port || !is_console_port(port))
+		return;
+
+	port->cons.ws.ws_row = rows;
+	port->cons.ws.ws_col = cols;
+}
+
 static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
 {
 	struct port_buffer *buf;
@@ -1000,6 +1004,8 @@ static int add_port(struct ports_device *portdev, u32 id)
 	port->inbuf = NULL;
 	port->cons.hvc = NULL;
 
+	port->cons.ws.ws_row = port->cons.ws.ws_col = 0;
+
 	port->host_connected = port->guest_connected = false;
 
 	port->outvq_full = false;
@@ -1320,6 +1326,19 @@ static void config_intr(struct virtio_device *vdev)
 	portdev = vdev->priv;
 
 	if (!use_multiport(portdev)) {
+		struct port *port;
+		u16 rows, cols;
+
+		vdev->config->get(vdev,
+				  offsetof(struct virtio_console_config, cols),
+				  &cols, sizeof(u16));
+		vdev->config->get(vdev,
+				  offsetof(struct virtio_console_config, rows),
+				  &rows, sizeof(u16));
+
+		port = find_port_by_id(portdev, 0);
+		set_console_size(port, rows, cols);
+
 		/*
 		 * We'll use this way of resizing only for legacy
 		 * support.  For newer userspace
@@ -1327,7 +1346,7 @@ static void config_intr(struct virtio_device *vdev)
 		 * to indicate console size changes so that it can be
 		 * done per-port.
 		 */
-		resize_console(find_port_by_id(portdev, 0));
+		resize_console(port);
 	}
 }
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] virtio: console: Store each console's size in the console structure
  2010-05-05 20:35 ` Amit Shah
@ 2010-05-05 20:35   ` Amit Shah
  2010-05-05 20:35   ` Amit Shah
  1 sibling, 0 replies; 8+ messages in thread
From: Amit Shah @ 2010-05-05 20:35 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Amit Shah, Christian Borntraeger, Kusanagi Kouichi, linuxppc-dev,
	Virtualization List

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>
---
 drivers/char/virtio_console.c |   43 +++++++++++++++++++++++++++++-----------
 1 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index e2d05ea..ccfe68a 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -78,6 +78,9 @@ struct console {
 	/* The hvc device associated with this console port */
 	struct hvc_struct *hvc;
 
+	/* The size of the console */
+	struct winsize ws;
+
 	/*
 	 * This number identifies the number that we used to register
 	 * 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)
 static void resize_console(struct port *port)
 {
 	struct virtio_device *vdev;
-	struct winsize ws;
 
 	/* The port could have been hot-unplugged */
-	if (!port)
+	if (!port || !is_console_port(port))
 		return;
 
 	vdev = port->portdev->vdev;
-	if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) {
-		vdev->config->get(vdev,
-				  offsetof(struct virtio_console_config, cols),
-				  &ws.ws_col, sizeof(u16));
-		vdev->config->get(vdev,
-				  offsetof(struct virtio_console_config, rows),
-				  &ws.ws_row, sizeof(u16));
-		hvc_resize(port->cons.hvc, ws);
-	}
+	if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE))
+		hvc_resize(port->cons.hvc, port->cons.ws);
 }
 
 /* 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 = {
 	.read  = debugfs_read,
 };
 
+static void set_console_size(struct port *port, u16 rows, u16 cols)
+{
+	if (!port || !is_console_port(port))
+		return;
+
+	port->cons.ws.ws_row = rows;
+	port->cons.ws.ws_col = cols;
+}
+
 static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
 {
 	struct port_buffer *buf;
@@ -1000,6 +1004,8 @@ static int add_port(struct ports_device *portdev, u32 id)
 	port->inbuf = NULL;
 	port->cons.hvc = NULL;
 
+	port->cons.ws.ws_row = port->cons.ws.ws_col = 0;
+
 	port->host_connected = port->guest_connected = false;
 
 	port->outvq_full = false;
@@ -1320,6 +1326,19 @@ static void config_intr(struct virtio_device *vdev)
 	portdev = vdev->priv;
 
 	if (!use_multiport(portdev)) {
+		struct port *port;
+		u16 rows, cols;
+
+		vdev->config->get(vdev,
+				  offsetof(struct virtio_console_config, cols),
+				  &cols, sizeof(u16));
+		vdev->config->get(vdev,
+				  offsetof(struct virtio_console_config, rows),
+				  &rows, sizeof(u16));
+
+		port = find_port_by_id(portdev, 0);
+		set_console_size(port, rows, cols);
+
 		/*
 		 * We'll use this way of resizing only for legacy
 		 * support.  For newer userspace
@@ -1327,7 +1346,7 @@ static void config_intr(struct virtio_device *vdev)
 		 * to indicate console size changes so that it can be
 		 * done per-port.
 		 */
-		resize_console(find_port_by_id(portdev, 0));
+		resize_console(port);
 	}
 }
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] virtio: console: Accept console size along with resize control message
  2010-05-05 20:35   ` Amit Shah
@ 2010-05-05 20:35     ` Amit Shah
  2010-05-05 20:35     ` Amit Shah
  1 sibling, 0 replies; 8+ messages in thread
From: Amit Shah @ 2010-05-05 20:35 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Amit Shah, Christian Borntraeger, Kusanagi Kouichi, linuxppc-dev,
	Virtualization List

The VIRTIO_CONSOLE_RESIZE control message sent to us by the host now
contains the new {rows, cols} values for the console. This ensures each
console port gets its own size, and we don't depend on the config-space
rows and cols values at all now.

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>
---
 drivers/char/virtio_console.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index ccfe68a..5cab839 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1194,12 +1194,23 @@ static void handle_control_message(struct ports_device *portdev,
 		 * have to notify the host first.
 		 */
 		break;
-	case VIRTIO_CONSOLE_RESIZE:
+	case VIRTIO_CONSOLE_RESIZE: {
+		struct {
+			__u16 rows;
+			__u16 cols;
+		} size;
+
 		if (!is_console_port(port))
 			break;
+
+		memcpy(&size, buf->buf + buf->offset + sizeof(*cpkt),
+		       sizeof(size));
+		set_console_size(port, size.rows, size.cols);
+
 		port->cons.hvc->irq_requested = 1;
 		resize_console(port);
 		break;
+	}
 	case VIRTIO_CONSOLE_PORT_OPEN:
 		port->host_connected = cpkt->value;
 		wake_up_interruptible(&port->waitqueue);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] virtio: console: Accept console size along with resize control message
  2010-05-05 20:35   ` Amit Shah
  2010-05-05 20:35     ` [PATCH 3/3] virtio: console: Accept console size along with resize control message Amit Shah
@ 2010-05-05 20:35     ` Amit Shah
  1 sibling, 0 replies; 8+ messages in thread
From: Amit Shah @ 2010-05-05 20:35 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Amit Shah, Christian Borntraeger, Kusanagi Kouichi, linuxppc-dev,
	Virtualization List

The VIRTIO_CONSOLE_RESIZE control message sent to us by the host now
contains the new {rows, cols} values for the console. This ensures each
console port gets its own size, and we don't depend on the config-space
rows and cols values at all now.

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>
---
 drivers/char/virtio_console.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index ccfe68a..5cab839 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1194,12 +1194,23 @@ static void handle_control_message(struct ports_device *portdev,
 		 * have to notify the host first.
 		 */
 		break;
-	case VIRTIO_CONSOLE_RESIZE:
+	case VIRTIO_CONSOLE_RESIZE: {
+		struct {
+			__u16 rows;
+			__u16 cols;
+		} size;
+
 		if (!is_console_port(port))
 			break;
+
+		memcpy(&size, buf->buf + buf->offset + sizeof(*cpkt),
+		       sizeof(size));
+		set_console_size(port, size.rows, size.cols);
+
 		port->cons.hvc->irq_requested = 1;
 		resize_console(port);
 		break;
+	}
 	case VIRTIO_CONSOLE_PORT_OPEN:
 		port->host_connected = cpkt->value;
 		wake_up_interruptible(&port->waitqueue);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] virtio: console: Handle multiple console port resizes
  2010-05-05 20:35 [PATCH 0/3] virtio: console: Handle multiple console port resizes Amit Shah
  2010-05-05 20:35 ` [PATCH 1/3] virtio: console: Resize console port 0 on config intr only if multiport is off Amit Shah
  2010-05-05 20:35 ` Amit Shah
@ 2010-05-06  2:27 ` Rusty Russell
  2 siblings, 0 replies; 8+ messages in thread
From: Rusty Russell @ 2010-05-06  2:27 UTC (permalink / raw)
  To: Amit Shah; +Cc: Virtualization List

On Thu, 6 May 2010 06:05:06 am Amit Shah wrote:
> Hello,
> 
> This series adds resize support for multiple console ports. The size
> for each console is stored in its structure and the host informs the
> guest about size changes via the VIRTIO_CONSOLE_RESIZE control
> message.

Thanks, applied!

Rusty.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-05-06  2:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-05 20:35 [PATCH 0/3] virtio: console: Handle multiple console port resizes Amit Shah
2010-05-05 20:35 ` [PATCH 1/3] virtio: console: Resize console port 0 on config intr only if multiport is off Amit Shah
2010-05-05 20:35 ` Amit Shah
2010-05-05 20:35   ` [PATCH 2/3] virtio: console: Store each console's size in the console structure Amit Shah
2010-05-05 20:35   ` Amit Shah
2010-05-05 20:35     ` [PATCH 3/3] virtio: console: Accept console size along with resize control message Amit Shah
2010-05-05 20:35     ` Amit Shah
2010-05-06  2:27 ` [PATCH 0/3] virtio: console: Handle multiple console port resizes Rusty Russell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.