WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH v3 3/3] Use separate struct console structure for eac

To: Greg Kroah-Hartman <gregkh@xxxxxxx>
Subject: [Xen-devel] [PATCH v3 3/3] Use separate struct console structure for each hvc_console.
From: Miche Baker-Harvey <miche@xxxxxxxxxx>
Date: Tue, 08 Nov 2011 13:45:09 -0800
Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>, Rusty Russell <rusty@xxxxxxxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx, Anton Blanchard <anton@xxxxxxxxx>, Amit Shah <amit.shah@xxxxxxxxxx>, Mike Waychison <mikew@xxxxxxxxxx>, ppc-dev <linuxppc-dev@xxxxxxxxxxxxxxxx>, Eric Northrup <digitaleric@xxxxxxxxxx>
Delivery-date: Mon, 14 Nov 2011 15:47:55 -0800
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1320788714; bh=cWzqN3bwKRfgplU+HRIjmhZZLAU=; h=Subject:To:From:Cc:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; b=i9QLknw1WW1l+7ZCfoni2vgeu/YGMbD59/pKAFQ03brWCIFRxqt9o9Sj64hpHif+N JqeCRHfD2WaJVs0x1PDiw==
Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=subject:to:from:cc:date:message-id:in-reply-to:references: user-agent:mime-version:content-type: content-transfer-encoding:x-system-of-record; b=am5STUlkrsvXkZ6RHvxMbQIPSOkaRnguiEHGYFgwRGqcXF8F0+yubE/x72o3AHKjo bmlNbdimOvOxR4Sn3bMGg==
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20111108214452.28884.14840.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20111108214452.28884.14840.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: StGit/0.15
It is possible to make any virtio_console port be a console
by sending VIRITO_CONSOLE_CONSOLE_PORT.  But hvc_alloc was
using a single struct console hvc_console, which contains
both an index and flags which are per-port.

This adds a separate struct console for each virtio_console
that is CONSOLE_PORT.

Signed-off-by: Miche Baker-Harvey <miche@xxxxxxxxxx>
---
 drivers/tty/hvc/hvc_console.c |   20 ++++++++++++++++++++
 drivers/tty/hvc/hvc_console.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 09a6159..24a84d6 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -247,6 +247,7 @@ static void destroy_hvc_struct(struct kref *kref)
 
        spin_unlock(&hvc_structs_lock);
 
+       kfree(hp->hvc_console);
        kfree(hp);
 }
 
@@ -827,6 +828,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
                             int outbuf_size)
 {
        struct hvc_struct *hp;
+       struct console *cp;
        int i;
 
        /* We wait until a driver actually comes along */
@@ -854,6 +856,17 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
        kref_init(&hp->kref);
 
        INIT_WORK(&hp->tty_resize, hvc_set_winsz);
+       /*
+        * Make each console its own struct console.
+        */
+       cp = kmemdup(&hvc_console, sizeof(*cp), GFP_KERNEL);
+       if (!cp) {
+               kfree(hp);
+               return ERR_PTR(-ENOMEM);
+       }
+
+       hp->hvc_console = cp;
+
        spin_lock_init(&hp->lock);
        spin_lock(&hvc_structs_lock);
 
@@ -872,8 +885,13 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
 
        hp->index = i;
 
+       cp->index = i;
+       vtermnos[i] = vtermno;
+       cons_ops[i] = ops;
+
        list_add_tail(&(hp->next), &hvc_structs);
        spin_unlock(&hvc_structs_lock);
+       register_console(cp);
 
        return hp;
 }
@@ -884,6 +902,8 @@ int hvc_remove(struct hvc_struct *hp)
        unsigned long flags;
        struct tty_struct *tty;
 
+       BUG_ON(!hp->hvc_console);
+       unregister_console(hp->hvc_console);
        spin_lock_irqsave(&hp->lock, flags);
        tty = tty_kref_get(hp->tty);
 
diff --git a/drivers/tty/hvc/hvc_console.h b/drivers/tty/hvc/hvc_console.h
index c335a14..2d20ab7 100644
--- a/drivers/tty/hvc/hvc_console.h
+++ b/drivers/tty/hvc/hvc_console.h
@@ -58,6 +58,7 @@ struct hvc_struct {
        const struct hv_ops *ops;
        int irq_requested;
        int data;
+       struct console *hvc_console;
        struct winsize ws;
        struct work_struct tty_resize;
        struct list_head next;


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel