Amit Shah
2010-Apr-05 13:54 UTC
[PATCH 00/10] (v5) virtio: console: Fixes, new way of discovering ports
Hello, This patchset is still based on Linus' tree but I'll rebase when Rusty sends out the disable multiport patches. This series reworks the ABI to allow port discovery (only) via the control queue. In addition, it adds support for non-blocking write() support, which means no spinning. This works fine with the recent patches that are on qemu-devel. Also included is removal of hvc_remove() as removing one such console port causes other console ports (registered with hvc) to stall. This has to be debugged in the hvc_console.c file, I'll do that later, but we have a nice workaround for this: returning -EPIPE on any hvc operations will make the hvc console core perform any cleanups for the removed ports. Looks like we don't lose much by removing hvc_remove(). New in this version: - Complete support for non-blocking write() - Don't call hvc_remove() - Return -EPIPE for hvc operations if a console port was hot-unplugged. Amit Shah (10): virtio: console: Add a __send_control_msg() that can send messages without a valid port virtio: console: Let host know of port or device add failures virtio: console: Return -EPIPE to hvc_console if we lost the connection virtio: console: Don't call hvc_remove() on unplugging console ports virtio: console: Remove config work handler virtio: console: Move code around for future patches virtio: console: Use a control message to add ports virtio: console: Don't always create a port 0 if using multiport virtio: console: Rename wait_is_over() to will_read_block() virtio: console: Add support for nonblocking write()s drivers/char/virtio_console.c | 533 +++++++++++++++++++++------------------- include/linux/virtio_console.h | 18 +- 2 files changed, 288 insertions(+), 263 deletions(-)
Amit Shah
2010-Apr-05 13:54 UTC
[PATCH 01/10] virtio: console: Add a __send_control_msg() that can send messages without a valid port
We will introduce control messages that operate on the device as a whole rather than just ports. Make send_control_msg() a wrapper around __send_control_msg() which does not need a valid port. Signed-off-by: Amit Shah <amit.shah at redhat.com> --- drivers/char/virtio_console.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 8f665bc..5d24015 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -373,22 +373,22 @@ out: return ret; } -static ssize_t send_control_msg(struct port *port, unsigned int event, - unsigned int value) +static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id, + unsigned int event, unsigned int value) { struct scatterlist sg[1]; struct virtio_console_control cpkt; struct virtqueue *vq; unsigned int len; - if (!use_multiport(port->portdev)) + if (!use_multiport(portdev)) return 0; - cpkt.id = port->id; + cpkt.id = port_id; cpkt.event = event; cpkt.value = value; - vq = port->portdev->c_ovq; + vq = portdev->c_ovq; sg_init_one(sg, &cpkt, sizeof(cpkt)); if (vq->vq_ops->add_buf(vq, sg, 1, 0, &cpkt) >= 0) { @@ -399,6 +399,12 @@ static ssize_t send_control_msg(struct port *port, unsigned int event, return 0; } +static ssize_t send_control_msg(struct port *port, unsigned int event, + unsigned int value) +{ + return __send_control_msg(port->portdev, port->id, event, value); +} + static ssize_t send_buf(struct port *port, void *in_buf, size_t in_count) { struct scatterlist sg[1]; -- 1.6.2.5
Amit Shah
2010-Apr-05 13:54 UTC
[PATCH 02/10] virtio: console: Let host know of port or device add failures
The host may want to know and let management apps notify of port or device add failures. Send a control message saying the device or port is not ready in this case. Signed-off-by: Amit Shah <amit.shah at redhat.com> --- drivers/char/virtio_console.c | 5 +++++ include/linux/virtio_console.h | 3 +++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 5d24015..1ae11f4 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -1217,6 +1217,8 @@ free_cdev: free_port: kfree(port); fail: + /* The host might want to notify management sw about port add failure */ + send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 0); return err; } @@ -1495,6 +1497,9 @@ free_chrdev: free: kfree(portdev); fail: + /* The host might want to notify mgmt sw about device add failure */ + __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, + VIRTIO_CONSOLE_DEVICE_READY, 0); return err; } diff --git a/include/linux/virtio_console.h b/include/linux/virtio_console.h index ae4f039..0157361 100644 --- a/include/linux/virtio_console.h +++ b/include/linux/virtio_console.h @@ -14,6 +14,8 @@ #define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */ #define VIRTIO_CONSOLE_F_MULTIPORT 1 /* Does host provide multiple ports? */ +#define VIRTIO_CONSOLE_BAD_ID (~(u32)0) + struct virtio_console_config { /* colums of the screens */ __u16 cols; @@ -42,6 +44,7 @@ struct virtio_console_control { #define VIRTIO_CONSOLE_PORT_OPEN 3 #define VIRTIO_CONSOLE_PORT_NAME 4 #define VIRTIO_CONSOLE_PORT_REMOVE 5 +#define VIRTIO_CONSOLE_DEVICE_READY 6 #ifdef __KERNEL__ int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)); -- 1.6.2.5
Possibly Parallel Threads
- [PATCH 00/10] (v5) virtio: console: Fixes, new way of discovering ports
- [PATCH 00/11] (v6) virtio: console: Fixes, new way of discovering ports
- [PATCH 00/11] (v6) virtio: console: Fixes, new way of discovering ports
- virtio: console: Return -EFAULT on copy_xx_user errors, allow larger writes
- virtio: console: Return -EFAULT on copy_xx_user errors, allow larger writes