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: [RFC PATCH V2 6/8] xen: introduce xen_event_channel_register_3level
Date: Mon, 21 Jan 2013 14:58:26 +0000 [thread overview]
Message-ID: <1358780308-30425-7-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1358780308-30425-1-git-send-email-wei.liu2@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
drivers/xen/events.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 5b45441..cbb10ed 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -2178,6 +2178,77 @@ static struct evtchn_ops evtchn_ops_l3 __read_mostly = {
.debug_interrupt = debug_interrupt_l3,
};
+static int xen_event_channel_register_3level(void)
+{
+ evtchn_register_nlevel_t reg;
+ evtchn_register_3level_t l3;
+ int i, nr_pages, cpu;
+ unsigned long *_evtchn_pending = NULL;
+ unsigned long *_evtchn_mask = NULL;
+ unsigned long *l2sel_mfns = NULL;
+ unsigned long *l2sel_offsets = NULL;
+ int rc;
+
+ /* 1 page for 32 bit and 8 pages for 64 bit */
+ nr_pages = (sizeof(unsigned long) == 4 ? 1 : 8);
+
+ rc = -ENOMEM;
+#define __ALLOC_ARRAY(_ptr, _nr) \
+ do { \
+ (_ptr) = kzalloc(sizeof(unsigned long) * (_nr), \
+ GFP_KERNEL); \
+ if (!(_ptr)) \
+ goto out; \
+ } while (0)
+
+ __ALLOC_ARRAY(_evtchn_pending, nr_pages);
+ __ALLOC_ARRAY(_evtchn_mask, nr_pages);
+ __ALLOC_ARRAY(l2sel_mfns, nr_cpu_ids);
+ __ALLOC_ARRAY(l2sel_offsets, nr_cpu_ids);
+#undef __ALLOC_ARRAY
+
+ memset(®, 0, sizeof(reg));
+ memset(&l3, 0, sizeof(l3));
+
+ for (i = 0; i < nr_pages; i++) {
+ unsigned long offset = PAGE_SIZE * i;
+ _evtchn_pending[i] =
+ arbitrary_virt_to_mfn(
+ (void *)((unsigned long)evtchn_pending+offset));
+ _evtchn_mask[i] =
+ arbitrary_virt_to_mfn(
+ (void *)((unsigned long)evtchn_mask+offset));
+ }
+
+ for_each_possible_cpu(cpu) {
+ l2sel_mfns[cpu] =
+ arbitrary_virt_to_mfn(&per_cpu(evtchn_sel_l2, cpu));
+ l2sel_offsets[cpu] =
+ offset_in_page(&per_cpu(evtchn_sel_l2, cpu));
+ }
+
+ l3.nr_pages = nr_pages;
+ l3.evtchn_pending = _evtchn_pending;
+ l3.evtchn_mask = _evtchn_mask;
+
+ l3.nr_vcpus = nr_cpu_ids;
+ l3.l2sel_mfns = l2sel_mfns;
+ l3.l2sel_offsets = l2sel_offsets;
+
+ reg.level = 3;
+ reg.u.l3 = &l3;
+
+ rc = HYPERVISOR_event_channel_op(EVTCHNOP_register_nlevel, ®);
+
+out:
+ kfree(_evtchn_pending);
+ kfree(_evtchn_mask);
+ kfree(l2sel_mfns);
+ kfree(l2sel_offsets);
+
+ return rc;
+}
+
void __init xen_init_IRQ(void)
{
int i, rc;
--
1.7.10.4
next prev parent reply other threads:[~2013-01-21 14:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-21 14:58 [RFC PATCH V2 0/8] Implement 3-level event channel in Linux Wei Liu
2013-01-21 14:58 ` [RFC PATCH V2 1/8] xen: fix output of xen_debug_interrupt Wei Liu
2013-01-21 14:58 ` [RFC PATCH V2 2/8] xen: sync public headers Wei Liu
2013-01-21 14:58 ` [RFC PATCH V2 3/8] xen: generalized event channel operations Wei Liu
2013-01-22 9:00 ` Jan Beulich
2013-01-21 14:58 ` [RFC PATCH V2 4/8] xen: dynamically allocate cpu_evtchn_mask Wei Liu
2013-01-21 14:58 ` [RFC PATCH V2 5/8] xen: implement 3-level event channel routines Wei Liu
2013-01-22 9:12 ` Jan Beulich
2013-01-21 14:58 ` Wei Liu [this message]
2013-01-21 14:58 ` [RFC PATCH V2 7/8] xen: introduce interfaces to register N-level event channel Wei Liu
2013-01-21 14:58 ` [RFC PATCH V2 8/8] xen: register 3-level " 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=1358780308-30425-7-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).