Skip to content

Commit

Permalink
xen: events: propagate irq allocation failure instead of panicking
Browse files Browse the repository at this point in the history
Running out of IRQs need not be fatal to the machine as a whole.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Ian Campbell authored and Konrad Rzeszutek Wilk committed Mar 10, 2011
1 parent 6cb9bf3 commit 7bee976
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions drivers/xen/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ static void xen_irq_init(unsigned irq)
list_add_tail(&info->list, &xen_irq_list_head);
}

static int xen_allocate_irq_dynamic(void)
static int __must_check xen_allocate_irq_dynamic(void)
{
int first = 0;
int irq;
Expand All @@ -425,15 +425,12 @@ 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");

xen_irq_init(irq);

return irq;
}

static int xen_allocate_irq_gsi(unsigned gsi)
static int __must_check xen_allocate_irq_gsi(unsigned gsi)
{
int irq;

Expand All @@ -452,9 +449,6 @@ static int xen_allocate_irq_gsi(unsigned gsi)
else
irq = irq_alloc_desc_at(gsi, -1);

if (irq < 0)
panic("Unable to allocate to IRQ%d (%d)\n", gsi, irq);

xen_irq_init(irq);

return irq;
Expand Down Expand Up @@ -640,6 +634,8 @@ int xen_bind_pirq_gsi_to_irq(unsigned gsi,
}

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);
Expand Down Expand Up @@ -771,13 +767,16 @@ 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");

xen_irq_info_evtchn_init(irq, evtchn);
}

out:
spin_unlock(&irq_mapping_update_lock);

return irq;
Expand Down Expand Up @@ -829,6 +828,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");
Expand All @@ -845,6 +846,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;
Expand Down Expand Up @@ -897,6 +899,8 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn,
int retval;

irq = bind_evtchn_to_irq(evtchn);
if (irq < 0)
return irq;
retval = request_irq(irq, handler, irqflags, devname, dev_id);
if (retval != 0) {
unbind_from_irq(irq);
Expand All @@ -915,6 +919,8 @@ int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
int retval;

irq = bind_virq_to_irq(virq, cpu);
if (irq < 0)
return irq;
retval = request_irq(irq, handler, irqflags, devname, dev_id);
if (retval != 0) {
unbind_from_irq(irq);
Expand Down

0 comments on commit 7bee976

Please sign in to comment.