[PATCH 00/28] virtio: console: Fixes, support for generic ports

2009-11-27 Thread Amit Shah
Hey Rusty, This is a respin of my patches on top of the series you posted. I've taken the liberty to modify your patches for style consistency and comments where needed, keeping the authorship info intact. I've had to update a few of your patches for functional changes, I've changed the authorsh

[PATCH 02/28] virtio: console: statically initialize virtio_cons

2009-11-27 Thread Amit Shah
From: Rusty Russell That way, we can make it const as is good kernel style. We use a separate indirection for the early console, rather than mugging ops.put_chars. We rename it hv_ops, too. Signed-off-by: Rusty Russell Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 60 ++

[PATCH 01/28] virtio: console: comment cleanup

2009-11-27 Thread Amit Shah
From: Rusty Russell Remove old lguest-style comments. [Amit: - wingify comments acc. to kernel style - indent comments ] Signed-off-by: Rusty Russell Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 108 include/linux/virtio_conso

[PATCH 03/28] hvc_console: make the ops pointer const.

2009-11-27 Thread Amit Shah
From: Rusty Russell This is nicer for modern R/O protection. And noone needs it non-const, so constify the callers as well. Signed-off-by: Rusty Russell Signed-off-by: Amit Shah To: Christian Borntraeger Cc: linuxppc-...@ozlabs.org --- drivers/char/hvc_beat.c |2 +- drivers/char/h

[PATCH 06/28] virtio: console: use vdev->priv to avoid accessing global var.

2009-11-27 Thread Amit Shah
From: Rusty Russell Part of removing our "one console" assumptions, use vdev->priv to point to the port (currently == the global console). Signed-off-by: Rusty Russell Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-

[PATCH 05/28] virtio: console: port encapsulation

2009-11-27 Thread Amit Shah
From: Rusty Russell We are heading towards a multiple-"port" system, so as part of weaning off globals we encapsulate the information into 'struct port'. Signed-off-by: Rusty Russell Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 103 +--- 1

[PATCH 04/28] virtio: console: We support only one device at a time

2009-11-27 Thread Amit Shah
We support only one virtio_console device at a time. If multiple are found, error out if one is already initialized. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/cha

[PATCH 09/28] virtio: console: struct ports for multiple ports per device.

2009-11-27 Thread Amit Shah
Rather than assume a single port, add a 'struct ports_device' which stores data related to all the ports for that device. Currently, there's only one port and is hooked up with hvc, but that will change. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 154 +++--

[PATCH 07/28] virtio: console: don't assume a single console port.

2009-11-27 Thread Amit Shah
Keep a list of all ports being used as a console, and provide a lock and a lookup function. The hvc callbacks only give us a vterm number, so we need to map this. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 72 + 1 files changed, 65 ins

[PATCH 10/28] virtio: console: ensure console size is updated on hvc open

2009-11-27 Thread Amit Shah
When multiple console support is added, ensure each port's size gets updated when a new one is opened via hvc. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 33 + 1 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/char/virtio

[PATCH 08/28] virtio: console: remove global var

2009-11-27 Thread Amit Shah
From: Rusty Russell Now we can use an allocation function to remove our global console variable. Signed-off-by: Rusty Russell Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 70 +++- 1 files changed, 47 insertions(+), 23 deletions(-) diff --

[PATCH 11/28] virtio: console: Introduce a workqueue for handling host->guest notifications

2009-11-27 Thread Amit Shah
We currently only maintain one buffer per port for any data the host sends us. If we're slow in consuming that data, we might lose old data. To buffer the data that the host sends us, we need to be able to allocate buffers as and when the host sends us some. Using a workqueue gives us the freedom

[PATCH 15/28] virtio: console: Separate out console init into a new function

2009-11-27 Thread Amit Shah
Console ports could be hot-added. Also, with the new multiport support, a port is identified as a console port only if the host sends a control message. Move the console port init into a separate function so it can be invoked from other places. Signed-off-by: Amit Shah --- drivers/char/virtio_c

[PATCH 16/28] virtio: console: Introduce a 'header' for each buffer towards supporting multiport

2009-11-27 Thread Amit Shah
To identify which port data that gets sent to the Host belongs to, we'll have to add a 'header' to each outgoing buffer that will tell the Host the port number. This is also done for each buffer that's received from userspace. The header is currently a 0-length field, but will contain the port id

[PATCH 18/28] virtio: console: Associate each port with a char device

2009-11-27 Thread Amit Shah
The char device will be used as an interface by applications on the guest to communicate with apps on the host. The devices created are placed in /dev/vportNpn where N is the virtio-console device number and n is the port number for that device. The file operation for the char devs will be added

[PATCH 17/28] virtio: console: Add a new MULTIPORT feature, support for generic ports

2009-11-27 Thread Amit Shah
This commit adds a new feature, MULTIPORT. If the host supports this feature as well, the config space has the number of ports defined for that device. New ports are spawned according to this information. Using this feature, generic ports can be created which are not tied to hvc consoles. We also

[PATCH 25/28] virtio: console: Handle port hot-plug

2009-11-27 Thread Amit Shah
If the 'nr_ports' variable in the config space is updated to a higher value, that means new ports have been hotplugged. Introduce a new workqueue to handle such updates and create new ports. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 73 +-

[PATCH 14/28] virtio: console: Separate out console-specific data into a separate struct

2009-11-27 Thread Amit Shah
Move out console-specific stuff into a separate struct from 'struct port' as we need to maintain two lists: one for all the ports (which includes consoles) and one only for consoles since the hvc callbacks only give us the vtermno. This makes console handling cleaner. Signed-off-by: Amit Shah --

[PATCH 28/28] virtio: console: Add debugfs files for each port to expose debug info

2009-11-27 Thread Amit Shah
This is helpful in examining ports' state. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 78 + 1 files changed, 78 insertions(+), 0 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 8ed57c2..1ca

[PATCH 21/28] virtio: console: Ensure only one process can have a port open at a time

2009-11-27 Thread Amit Shah
Add a guest_connected field that ensures only one process can have a port open at a time. This also ensures we don't have a race when we later add support for dropping buffers when closing the char dev and buffer caching is turned off for the particular port. Signed-off-by: Amit Shah --- driver

[PATCH 27/28] virtio: console: Add ability to hot-unplug ports

2009-11-27 Thread Amit Shah
Remove port data; deregister from the hvc core if it's a console port. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 69 +-- include/linux/virtio_console.h |1 + 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/drivers/char

[PATCH 24/28] virtio: console: Add option to remove cached buffers on port close

2009-11-27 Thread Amit Shah
If caching of buffers upon closing a port is not desired, delete all the buffers queued up for the port upon port close. This only applies to generic ports; console ports aren't opened / closed by the chardev interface. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 37

[PATCH 20/28] virtio: console: Add file operations to ports for open/read/write/poll

2009-11-27 Thread Amit Shah
Allow guest userspace applications to open, read from, write to, poll the ports via the char dev interface. When a port gets opened, a notification is sent to the host via a control message indicating a connection has been established. Similarly, on closing of the port, a notification is sent indi

[PATCH 26/28] hvc_console: Export (GPL'ed) hvc_remove

2009-11-27 Thread Amit Shah
The virtio console, which uses hvc, will get the ability to hot-unplug ports. Export hvc_remove so that virtio_console can disassociate with hvc. Signed-off-by: Amit Shah Cc: linuxppc-...@ozlabs.org --- drivers/char/hvc_console.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff -

[PATCH 23/28] virtio: console: Add throttling support to prevent flooding ports

2009-11-27 Thread Amit Shah
Rogue processes on guests or hosts could pump in data and cause an OOM condition. Add support for throttling so that a limit to the number of outstanding buffers can be specified. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 78 ++- include/

[PATCH 12/28] virtio: console: Buffer data that comes in from the host

2009-11-27 Thread Amit Shah
The console could be flooded with data from the host; handle this situation by buffering the data. We move from the per-port inbuf to a per-device queue of buffers, shared by all the ports for that device, ready to receive host data. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c |

[PATCH 13/28] virtio: console: Create a buffer pool for sending data to host

2009-11-27 Thread Amit Shah
The old way of sending data to the host was to populate one buffer and then wait till the host consumed it before sending the next chunk of data. Also, there was no support to send large chunks of data. We now maintain a per-device list of buffers that are ready to be passed on to the host. This

[PATCH 22/28] virtio: console: Register with sysfs and create a 'name' attribute for ports

2009-11-27 Thread Amit Shah
The host can set a name for ports so that they're easily discoverable instead of going by the /dev/vportNpn naming. This attribute will be placed in /sys/class/vportdevN/vportNpn/name. udev scripts can then create symlinks to the port using the name. Signed-off-by: Amit Shah --- drivers/char/vir

[PATCH 19/28] virtio: console: Prepare for writing to / reading from userspace buffers

2009-11-27 Thread Amit Shah
When ports get advertised as char devices, the buffers will come from userspace. Equip the send_buf and fill_readbuf functions with the ability to write to / read from userspace buffers respectively. Signed-off-by: Amit Shah --- drivers/char/virtio_console.c | 51 --