xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xen.org
Cc: david.vrabel@citrix.com, Wei Liu <wei.liu2@citrix.com>,
	ian.campbell@citrix.com, jbeulich@suse.com,
	konrad.wilk@oracle.com
Subject: [PATCH V2 12/13] xen: introduce xen_event_channel_register_nlevel
Date: Mon, 4 Feb 2013 17:23:53 +0000	[thread overview]
Message-ID: <1359998635-16866-13-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1359998635-16866-1-git-send-email-wei.liu2@citrix.com>

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 drivers/xen/events.c |   55 ++++++++++++++++++++++++++++++++++++++++++++------
 include/xen/events.h |    7 +++++++
 2 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 6e0283c..6a0307c 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -2217,17 +2217,60 @@ err:
 	return rc;
 }
 
+void xen_event_channel_register_nlevel(unsigned int highest_level)
+{
+	int rc;
+
+	switch (highest_level) {
+	case 3:
+		rc = xen_event_channel_register_3level();
+		if (rc == 0) {
+			printk(KERN_INFO "Register 3-level event channel succeed.\n");
+			xen_set_event_channel_nlevel(3);
+			break;
+		} else {
+			printk(KERN_INFO "Regsiter 3-level event channel failed with %d\n",
+			       rc);
+		}
+		/* fall through */
+	case 2:
+		printk(KERN_INFO "Using 2-level event channel\n");
+		xen_set_event_channel_nlevel(2);
+		break;
+	default:
+		printk(KERN_INFO "Trying to register unsupported %d-level event channel\n",
+		       highest_level);
+	}
+}
+
+void xen_set_event_channel_nlevel(unsigned int level)
+{
+	struct shared_info *s = HYPERVISOR_shared_info;
+	switch (level) {
+	case 2:
+		evtchn_pending = s->evtchn_pending;
+		evtchn_mask = s->evtchn_mask;
+		evtchn_level = 2;
+		nr_event_channels = NR_EVENT_CHANNELS_L2;
+		break;
+	case 3:
+		/* evtchn_pending/mask already set */
+		evtchn_level = 3;
+		nr_event_channels = NR_EVENT_CHANNELS_L3;
+		break;
+	default:
+		printk(KERN_EMERG "Trying to set unsupported %d-level event channel\n",
+		       level);
+		BUG();
+	}
+}
+
 void __init xen_init_IRQ(void)
 {
 	int i, rc;
 	int cpu;
-	struct shared_info *s = HYPERVISOR_shared_info;
-
-	evtchn_pending = s->evtchn_pending;
-	evtchn_mask = s->evtchn_mask;
 
-	evtchn_level = 2;
-	nr_event_channels = NR_EVENT_CHANNELS_L2;
+	xen_set_event_channel_nlevel(2);
 
 	evtchn_to_irq = kcalloc(nr_event_channels, sizeof(*evtchn_to_irq),
 				    GFP_KERNEL);
diff --git a/include/xen/events.h b/include/xen/events.h
index 6b117ac..6b6c4fb 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -111,4 +111,11 @@ int xen_test_irq_shared(int irq);
 
 extern unsigned int nr_event_channels;
 
+/* Register N-level event channel. If register N-level fails, it will try to
+ * register N-1 level, until it reaches the default 2-level event channel. */
+void xen_event_channel_register_nlevel(unsigned int highest_level);
+
+/* Set event channel to N-level if registration succeed */
+void xen_set_event_channel_nlevel(unsigned int level);
+
 #endif	/* _XEN_EVENTS_H */
-- 
1.7.10.4

  parent reply	other threads:[~2013-02-04 17:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-04 17:23 [PATCH V2] Implement 3-level event channel in Linux Wei Liu
2013-02-04 17:23 ` [PATCH V2 01/13] xen: add KERN_DEBUG in printk Wei Liu
2013-02-04 17:23 ` [PATCH V2 02/13] xen: fix output of xen_debug_interrupt Wei Liu
2013-02-04 17:23 ` [PATCH V2 03/13] xen: fix error handling path if xen_allocate_irq_dynamic fails Wei Liu
2013-02-04 17:23 ` [PATCH V2 04/13] xen: close evtchn port if binding to irq fails Wei Liu
2013-02-06  8:05   ` Jan Beulich
2013-02-04 17:23 ` [PATCH V2 05/13] xen: sync public headers Wei Liu
2013-02-04 17:23 ` [PATCH V2 06/13] xen: introduce test_and_set_mask Wei Liu
2013-02-04 17:23 ` [PATCH V2 07/13] xen: replace raw bit ops with functions Wei Liu
2013-02-04 17:23 ` [PATCH V2 08/13] xen: generalized event channel operations Wei Liu
2013-02-04 17:23 ` [PATCH V2 09/13] xen: dynamically allocate cpu_evtchn_mask Wei Liu
2013-02-04 17:23 ` [PATCH V2 10/13] xen: implement 3-level event channel routines Wei Liu
2013-02-04 17:23 ` [PATCH V2 11/13] xen: introduce xen_event_channel_register_3level Wei Liu
2013-02-04 17:23 ` Wei Liu [this message]
2013-02-04 17:23 ` [PATCH V2 13/13] xen: register 3-level event channel Wei Liu

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=1359998635-16866-13-git-send-email-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=konrad.wilk@oracle.com \
    --cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).