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

[Xen-devel] [PATCH 2/2] xen: events: propagate irq allocation failure instead of panicing



Running out of IRQs need not be fatal to the machine as a whole.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Cc: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
---
 drivers/xen/events.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index ce33061..51051cf 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -376,7 +376,7 @@ static void unmask_evtchn(int port)
        put_cpu();
 }
 
-static int xen_allocate_irq_dynamic(void)
+static int __must_check xen_allocate_irq_dynamic(void)
 {
        int first = 0;
        int irq;
@@ -395,13 +395,10 @@ static int xen_allocate_irq_dynamic(void)
 
        irq = irq_alloc_desc_from(first, -1);
 
-       if (irq < 0)
-               panic("No available IRQ to bind to: increase nr_irqs!\n");
-
        return irq;
 }
 
-static int xen_allocate_irq_gsi(unsigned gsi)
+static int __must_check xen_allocate_irq_gsi(unsigned gsi)
 {
        int irq;
 
@@ -419,8 +416,6 @@ static int xen_allocate_irq_gsi(unsigned gsi)
                return gsi;
 
        irq = irq_alloc_desc_at(gsi, -1);
-       if (irq < 0)
-               panic("Unable to allocate to IRQ%d (%d)\n", gsi, irq);
 
        return irq;
 }
@@ -609,6 +604,8 @@ int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int 
shareable, char *name)
        }
 
        irq = xen_allocate_irq_gsi(gsi);
+       if (irq < 0)
+               goto out;
 
        set_irq_chip_and_handler_name(irq, &xen_pirq_chip,
                                      handle_level_irq, name);
@@ -795,6 +792,8 @@ int bind_evtchn_to_irq(unsigned int evtchn)
 
        if (irq == -1) {
                irq = xen_allocate_irq_dynamic();
+               if (irq == -1)
+                       goto out;
 
                set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
                                              handle_fasteoi_irq, "event");
@@ -803,6 +802,7 @@ int bind_evtchn_to_irq(unsigned int evtchn)
                irq_info[irq] = mk_evtchn_info(evtchn);
        }
 
+out:
        spin_unlock(&irq_mapping_update_lock);
 
        return irq;
@@ -856,6 +856,8 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
 
        if (irq == -1) {
                irq = xen_allocate_irq_dynamic();
+               if (irq == -1)
+                       goto out;
 
                set_irq_chip_and_handler_name(irq, &xen_percpu_chip,
                                              handle_percpu_irq, "virq");
@@ -875,6 +877,7 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
                bind_evtchn_to_cpu(evtchn, cpu);
        }
 
+out:
        spin_unlock(&irq_mapping_update_lock);
 
        return irq;
-- 
1.5.6.5


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


 


Rackspace

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