[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH V2 12/13] xen: introduce xen_event_channel_register_nlevel



Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.