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 v2 3/3] Use separate struct console structure for eac

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH v2 3/3] Use separate struct console structure for each hvc_console.
From: Miche Baker-Harvey <miche@xxxxxxxxxx>
Date: Tue, 08 Nov 2011 11:29:48 -0800
Delivery-date: Mon, 14 Nov 2011 15:44:27 -0800
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1320780591; bh=cWzqN3bwKRfgplU+HRIjmhZZLAU=; h=Subject:To:From:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; b=VTOL6yGKWMUo9et6rfPSB+FBu9tqBTCDxJHldlWOg4HK2wABVJRca69XIRWPmemuQ /tDodSGQP/L478mqaEF3g==
Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=subject:to:from:date:message-id:in-reply-to:references: user-agent:mime-version:content-type: content-transfer-encoding:x-system-of-record; b=rUj4DNkKdW5beXsYsKqsGpjPeVuxlC9PyeZXIu4EZw4ldFU8ytrk4mTHl6Bkr8v2b U7+1NPUs/s4jHUml2xIng==
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20111108192932.30528.88994.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: <20111108192932.30528.88994.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

<Prev in Thread] Current Thread [Next in Thread>