All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, Alan Cox <alan@linux.intel.com>
Subject: Re: [PATCH] virtio_console: Add support for multiple ports for generic guest and host communication
Date: Thu, 1 Oct 2009 15:34:39 +0530	[thread overview]
Message-ID: <20091001100439.GA9684__10452.629105612$1254391589$gmane$org@amit-x200.redhat.com> (raw)
In-Reply-To: <200910011100.48087.borntraeger@de.ibm.com>

On (Thu) Oct 01 2009 [11:00:48], Christian Borntraeger wrote:
> Am Mittwoch 30 September 2009 19:13:21 schrieb Amit Shah:
> > - uses port->id instead of a static hvc_vtermno to pass on a value to
> >   hvc_alloc(). Motivation explained within comments in the code.
> 
> [...]
> > +	 * The first argument of hvc_alloc() is the virtual console
> > +	 * number. hvc_alloc() checks if a console with the same value
> > +	 * was used in hvc_instantiate(). We may not end up passing
> > +	 * the same value here (we use the value 0 in
> > +	 * hvc_instantiate() but the console port may not be at id
> > +	 * 0). This isn't a problem, though. Nothing in hvc really
> > +	 * depends on these numbers and since this number is passed on
> > +	 * to us when cons_get/put_chars() is called, it's preferable
> > +	 * to pass on the port->id so that we can get the port struct
> > +	 * via get_port_from_id().
> [...]
> > +	port->hvc = hvc_alloc(port->id, 0, &virtio_cons, PAGE_SIZE);
> 
> I am not sure if this is going to be ok. 
> 
> When I change the old code (without your patch) to use vtermno=0 in 
> hvc_instantiate and vtermno=1 in hvc_alloc I get 
> "Warning: unable to open an initial console."
> 
> It seems to me that we have to pass the same values.

OK; that's bad enough. The following diff reverts that patch and adds a
new get_port_from_vtermno() that works from hvc callbacks.

What do you think? (Applies on top of the latest patch I sent.)

		Amit


diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index b2de2df..a8ba5aa 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -105,12 +105,42 @@ struct virtio_console_port {
 	/* The 'id' to identify the port with the Host */
 	u32 id;
 
+	/*
+	 * If this port is a console port, this number identifies the
+	 * number that we used to register with hvc in
+	 * hvc_instantiate() and hvc_alloc().
+	 */
+	u32 vtermno;
+
 	/* Is the host device open */
 	bool host_connected;
 };
 
 static struct virtio_console_struct virtconsole;
 
+/*
+ * This is used to keep track of the number of hvc consoles spawned.
+ * This number is given as first argument to hvc_alloc(). We could as
+ * well pass on the minor number of the char device but to correctly
+ * map an initial console spawned via hvc_instantiate to the console
+ * being hooked up via hvc_alloc, we need to pass the same vtermno.
+ *
+ * With this int, we just assume the first console being initialised
+ * was the first one that got used as the initial console.
+ */
+static unsigned int hvc_vtermno;
+
+static struct virtio_console_port *get_port_from_vtermno(u32 vtermno)
+{
+	struct virtio_console_port *port;
+
+	list_for_each_entry(port, &virtconsole.port_head, next) {
+		if (port->vtermno == vtermno)
+			return port;
+	}
+	return NULL;
+}
+
 static struct virtio_console_port *get_port_from_devt(dev_t devt)
 {
 	struct virtio_console_port *port;
@@ -457,7 +487,7 @@ static int cons_put_chars(u32 vtermno, const char *buf, int count)
 {
 	struct virtio_console_port *port;
 
-	port = get_port_from_id(vtermno);
+	port = get_port_from_vtermno(vtermno);
 	if (!port)
 		return 0;
 
@@ -478,7 +508,7 @@ static int cons_get_chars(u32 vtermno, char *buf, int count)
 	/* If we don't have an input queue yet, we can't get input. */
 	BUG_ON(!virtconsole.in_vq);
 
-	port = get_port_from_id(vtermno);
+	port = get_port_from_vtermno(vtermno);
 	if (!port)
 		return 0;
 
@@ -566,32 +596,23 @@ int init_port_console(struct virtio_console_port *port)
 	 * hvc_alloc().
 	 *
 	 * The first argument of hvc_alloc() is the virtual console
-	 * number. hvc_alloc() checks if a console with the same value
-	 * was used in hvc_instantiate(). We may not end up passing
-	 * the same value here (we use the value 0 in
-	 * hvc_instantiate() but the console port may not be at id
-	 * 0). This isn't a problem, though. Nothing in hvc really
-	 * depends on these numbers and since this number is passed on
-	 * to us when cons_get/put_chars() is called, it's preferable
-	 * to pass on the port->id so that we can get the port struct
-	 * via get_port_from_id().
-	 *
-	 * The second argument is the parameter for the notification
-	 * mechanism (like irq number). We currently leave this as
-	 * zero, virtqueues have implicit notifications.
+	 * number.  The second argument is the parameter for the
+	 * notification mechanism (like irq number). We currently
+	 * leave this as zero, virtqueues have implicit notifications.
 	 *
 	 * The third argument is a "struct hv_ops" containing the
 	 * put_chars() get_chars(), notifier_add() and notifier_del()
 	 * pointers.  The final argument is the output buffer size: we
 	 * can do any size, so we put PAGE_SIZE here.
 	 */
-	port->hvc = hvc_alloc(port->id, 0, &virtio_cons, PAGE_SIZE);
+	port->hvc = hvc_alloc(hvc_vtermno, 0, &virtio_cons, PAGE_SIZE);
 	if (IS_ERR(port->hvc)) {
 		ret = PTR_ERR(port->hvc);
 		pr_err("%s: Could not alloc hvc for virtio console port, ret = %d\n",
 		       __func__, ret);
 		port->hvc = NULL;
 	}
+	port->vtermno = hvc_vtermno++;
 	return ret;
 }

  reply	other threads:[~2009-10-01 10:04 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-11 14:13 Multiple ports support for virtio_console; major number for dev Amit Shah
2009-09-11 14:13 ` [PATCH] virtio_console: Add support for multiple ports for generic guest and host communication Amit Shah
2009-09-11 14:13 ` Amit Shah
2009-09-11 16:00   ` Alan Cox
2009-09-11 16:00   ` Alan Cox
2009-09-11 16:38     ` Amit Shah
2009-09-11 17:26       ` Anthony Liguori
2009-09-11 17:33         ` Amit Shah
2009-09-11 17:33         ` Amit Shah
2009-09-11 17:35           ` Anthony Liguori
2009-09-16 10:23             ` Alan Cox
2009-09-16 22:20               ` Anthony Liguori
2009-09-17 13:06                 ` Markus Armbruster
2009-09-17 13:15                   ` Alan Cox
2009-09-17 13:41                     ` Amit Shah
2009-09-17 13:41                     ` Amit Shah
2009-09-17 15:57                       ` Alan Cox
2009-09-17 15:57                       ` Alan Cox
2009-09-17 16:46                         ` Amit Shah
2009-09-17 16:46                         ` Amit Shah
2009-09-17 13:15                   ` Alan Cox
2009-09-17 13:06                 ` Markus Armbruster
2009-09-18 16:00                 ` Alan Cox
2009-09-18 17:55                   ` Anthony Liguori
2009-09-18 17:55                   ` Anthony Liguori
2009-09-18 17:57                     ` H. Peter Anvin
2009-09-18 18:02                       ` Anthony Liguori
2009-09-18 18:02                       ` Anthony Liguori
2009-09-19  7:04                       ` Amit Shah
2009-09-19  7:04                       ` Amit Shah
2009-09-18 17:57                     ` H. Peter Anvin
2009-09-18 20:11                     ` Gerd Hoffmann
2009-09-18 20:11                     ` Gerd Hoffmann
2009-09-19  7:01                     ` Amit Shah
2009-09-19  7:01                     ` Amit Shah
2009-09-21 10:06                     ` Alan Cox
2009-09-21 10:06                     ` Alan Cox
2009-09-18 16:00                 ` Alan Cox
2009-09-16 22:20               ` Anthony Liguori
2009-09-16 10:23             ` Alan Cox
2009-09-11 17:35           ` Anthony Liguori
2009-09-11 17:26       ` Anthony Liguori
2009-09-11 16:38     ` Amit Shah
2009-09-15 12:37     ` Amit Shah
2009-09-15 12:37     ` Amit Shah
2009-09-15 12:57       ` Anthony Liguori
2009-09-15 12:57       ` Anthony Liguori
2009-09-15 13:03         ` Amit Shah
2009-09-15 13:03         ` Amit Shah
2009-09-15 13:37           ` Anthony Liguori
2009-09-15 13:37           ` Anthony Liguori
2009-09-15 14:08         ` Gerd Hoffmann
2009-09-15 14:08           ` Gerd Hoffmann
2009-09-15 14:09           ` Anthony Liguori
2009-09-15 14:09             ` Anthony Liguori
2009-09-22  2:44     ` Rusty Russell
2009-09-22  2:44     ` Rusty Russell
2009-09-22 15:45       ` Amit Shah
2009-09-22 15:45       ` Amit Shah
2009-09-29  9:24         ` Amit Shah
2009-09-29  9:24         ` Amit Shah
2009-09-29 10:09           ` Christian Borntraeger
2009-09-29 10:33             ` Amit Shah
2009-09-29 11:02               ` Christian Borntraeger
2009-09-29 11:40                 ` Christian Borntraeger
2009-09-29 11:40                 ` Christian Borntraeger
2009-09-29 11:02               ` Christian Borntraeger
2009-09-29 10:33             ` Amit Shah
2009-09-29 10:09           ` Christian Borntraeger
2009-09-29 12:03           ` Christian Borntraeger
2009-09-29 12:03           ` Christian Borntraeger
2009-09-29 12:20             ` Amit Shah
2009-09-29 12:20             ` Amit Shah
2009-09-29 12:56               ` Christian Borntraeger
2009-09-29 12:56               ` Christian Borntraeger
2009-09-29 13:09                 ` Amit Shah
2009-09-29 13:31                   ` Christian Borntraeger
2009-09-30 17:13                     ` Amit Shah
2009-09-30 17:13                     ` Amit Shah
2009-10-01  8:17                       ` Christian Borntraeger
2009-10-01  8:17                       ` Christian Borntraeger
2009-10-01  8:47                         ` Amit Shah
2009-10-01  8:47                         ` Amit Shah
2009-10-01  8:55                           ` Christian Borntraeger
2009-10-01  8:55                           ` Christian Borntraeger
2009-10-01  9:00                       ` Christian Borntraeger
2009-10-01 10:04                         ` Amit Shah [this message]
2009-10-01 10:04                         ` Amit Shah
2009-10-01  9:00                       ` Christian Borntraeger
2009-10-01 10:28                       ` Christian Borntraeger
2009-10-01 10:28                       ` Christian Borntraeger
2009-10-01 10:42                         ` Amit Shah
2009-10-01 10:42                         ` Amit Shah
2009-10-01 11:58                         ` Amit Shah
2009-10-01 11:58                         ` Amit Shah
2009-10-01 12:04                           ` Christian Borntraeger
2009-10-01 13:50                             ` Amit Shah
2009-10-01 13:50                             ` Amit Shah
2009-10-01 12:04                           ` Christian Borntraeger
2009-10-05 14:05                         ` Amit Shah
2009-10-05 14:05                           ` Amit Shah
2009-10-06  6:49                           ` Christian Borntraeger
2009-10-06  6:49                             ` Christian Borntraeger
2009-10-06  6:55                             ` Amit Shah
2009-10-06  6:55                               ` Amit Shah
2009-09-29 13:31                   ` Christian Borntraeger
2009-09-29 13:09                 ` Amit Shah
2009-09-29 13:11   ` Rusty Russell
2009-09-29 13:24     ` Amit Shah
2009-09-29 13:24     ` Amit Shah
2009-09-29 13:11   ` Rusty Russell
  -- strict thread matches above, loose matches on Subject: below --
2009-09-09  8:11 Multiple Port Support for virtio-console Amit Shah
2009-09-09  8:12 ` [PATCH] virtio_console: Add support for multiple ports for generic guest and host communication Amit Shah
2009-09-09  8:12 ` Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20091001100439.GA9684__10452.629105612$1254391589$gmane$org@amit-x200.redhat.com' \
    --to=amit.shah@redhat.com \
    --cc=alan@linux.intel.com \
    --cc=borntraeger@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.