Amit Shah
2009-Nov-10 09:41 UTC
virtio_console: support for multiple ports, console and generic.
Hey Rusty, This is the way I did the split; patches 1..7 are preparation for multiple ports. Patch 8 adds multiport support. It's the big one since we have to put the header in and retain support for multiple consoles and console resizing. Patch 9 adds port hotplug Patch 10 adds sysfs entries and 12 adds debugfs. Patches 13, 14 and 15 add throttling, caching and unplug features. There's also a one-device restriction; which would be addressed once I use vdev->priv. My main aim is to get comments on the send_buf and fill_readbuf functions, the input/output workqueues and hotplug. Amit
Amit Shah
2009-Nov-10 09:41 UTC
[PATCH 01/15] virtio_console: Initialize hv_ops struct at declaration instead of in the probe() routine
Initialize the hv_ops function pointers using C99 style. However, we
need to re-init the 'put_chars' field to our implementation in the
probe() routine as we replace it for early_init to use the caller's
put_chars implementation.
Signed-off-by: Amit Shah <amit.shah at redhat.com>
---
drivers/char/virtio_console.c | 50 ++++++++++++++++++++++++----------------
1 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index a035ae3..e5284a9 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -43,9 +43,6 @@ static struct virtio_device *vdev;
static unsigned int in_len;
static char *in, *inbuf;
-/* The operations for our console. */
-static struct hv_ops virtio_cons;
-
/* The hvc device */
static struct hvc_struct *hvc;
@@ -125,18 +122,6 @@ static int get_chars(u32 vtermno, char *buf, int count)
}
/*:*/
-/*D:320 Console drivers are initialized very early so boot messages can go out,
- * so we do things slightly differently from the generic virtio initialization
- * of the net and block drivers.
- *
- * At this stage, the console is output-only. It's too early to set up a
- * virtqueue, so we let the drivers do some boutique early-output thing. */
-int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int))
-{
- virtio_cons.put_chars = put_chars;
- return hvc_instantiate(0, 0, &virtio_cons);
-}
-
/*
* virtio console configuration. This supports:
* - console resize
@@ -173,6 +158,30 @@ static void notifier_del_vio(struct hvc_struct *hp, int
data)
hp->irq_requested = 0;
}
+/* The operations for our console. */
+static struct hv_ops virtio_cons = {
+ .get_chars = get_chars,
+ .put_chars = put_chars,
+ .notifier_add = notifier_add_vio,
+ .notifier_del = notifier_del_vio,
+ .notifier_hangup = notifier_del_vio,
+};
+
+/*D:320
+ * Console drivers are initialized very early so boot messages can go
+ * out, so we do things slightly differently from the generic virtio
+ * initialization of the net and block drivers.
+ *
+ * At this stage, the console is output-only. It's too early to set
+ * up a virtqueue, so we let the drivers do some boutique early-output
+ * thing.
+ */
+int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int))
+{
+ virtio_cons.put_chars = put_chars;
+ return hvc_instantiate(0, 0, &virtio_cons);
+}
+
static void hvc_handle_input(struct virtqueue *vq)
{
if (hvc_poll(hvc))
@@ -212,12 +221,13 @@ static int __devinit virtcons_probe(struct virtio_device
*dev)
in_vq = vqs[0];
out_vq = vqs[1];
- /* Start using the new console output. */
- virtio_cons.get_chars = get_chars;
+ /*
+ * We had set the virtio_cons ->put_chars implementation to an
+ * architecture-provided put_chars for early_init. Now that
+ * we're done with the early init phase, replace it with our
+ * implementation.
+ */
virtio_cons.put_chars = put_chars;
- virtio_cons.notifier_add = notifier_add_vio;
- virtio_cons.notifier_del = notifier_del_vio;
- virtio_cons.notifier_hangup = notifier_del_vio;
/* The first argument of hvc_alloc() is the virtual console number, so
* we use zero. The second argument is the parameter for the
--
1.6.2.5
Amit Shah
2009-Nov-10 09:41 UTC
[PATCH 02/15] virtio_console: We support only one device at a time
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 <amit.shah at redhat.com>
---
drivers/char/virtio_console.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index e5284a9..21039b8 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -202,6 +202,10 @@ static int __devinit virtcons_probe(struct virtio_device
*dev)
struct virtqueue *vqs[2];
int err;
+ if (vdev) {
+ pr_err("Multiple virtio-console devices not supported yet\n");
+ return -EEXIST;
+ }
vdev = dev;
/* This is the scratch page we use to receive console input */
--
1.6.2.5
Apparently Analagous Threads
- virtio_console: support for multiple ports, console and generic.
- [PATCH 00/32] virtio: console: Fixes, multiple devices and generic ports
- [PATCH 00/32] virtio: console: Fixes, multiple devices and generic ports
- [PATCH 00/28] virtio: console: Fixes, support for generic ports
- [PATCH 00/28] virtio: console: Fixes, support for generic ports