[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110428200209.8979.85021.stgit@ponder>
Date: Thu, 28 Apr 2011 14:02:09 -0600
From: Grant Likely <grant.likely@...retlab.ca>
To: Michal Simek <monstr@...str.eu>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
linux-kernel@...r.kernel.org, Ralf Baechle <ralf@...ux-mips.org>,
hpa@...or.com, Dirk Brandewie <dirk.brandewie@...il.com>,
Thomas Gleixner <tglx@...utronix.de>
Cc: devicetree-discuss@...ts.ozlabs.org, x86@...nel.org,
linuxppc-dev@...ts.ozlabs.org
Subject: [PATCH 5/6] powerpc: move irq_alloc_descs_at() call into
irq_alloc_virt()
This is a stepping stone to using core code for allocating virqs
instead of the powerpc architecture specific code. A subsequent patch
will drop the algorithm that searches for a free irq and replaces it
with irq_alloc_desc()
Signed-off-by: Grant Likely <grant.likely@...retlab.ca>
---
arch/powerpc/kernel/irq.c | 49 ++++++++++++++++++++++++++-------------------
1 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 9300e1c..0fb90ab 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -665,16 +665,6 @@ static void irq_free_virt(unsigned int virq);
static int irq_setup_virq(struct irq_host *host, unsigned int virq,
irq_hw_number_t hwirq)
{
- int res;
-
- res = irq_alloc_desc_at(virq, 0);
- if (res != virq) {
- pr_debug("irq: -> allocating desc failed\n");
- goto error;
- }
-
- irq_clear_status_flags(virq, IRQ_NOREQUEST);
-
/* map it */
smp_wmb();
irq_map[virq].hwirq = hwirq;
@@ -688,8 +678,6 @@ static int irq_setup_virq(struct irq_host *host, unsigned int virq,
return 0;
errdesc:
- irq_free_descs(virq, 1);
-error:
irq_free_virt(virq);
return -1;
}
@@ -754,14 +742,14 @@ unsigned int irq_create_mapping(struct irq_host *host,
if (virq == 0 || virq >= NUM_ISA_INTERRUPTS)
return NO_IRQ;
return virq;
- } else {
- /* Allocate a virtual interrupt number */
- hint = hwirq % irq_virq_count;
- virq = irq_alloc_virt(host, hint);
- if (virq == NO_IRQ) {
- pr_debug("irq: -> virq allocation failed\n");
- return NO_IRQ;
- }
+ }
+
+ /* Allocate a virtual interrupt number */
+ hint = hwirq % irq_virq_count;
+ virq = irq_alloc_virt(host, hint);
+ if (virq == NO_IRQ) {
+ pr_debug("irq: -> virq allocation failed\n");
+ return NO_IRQ;
}
if (irq_setup_virq(host, virq, hwirq))
@@ -867,7 +855,6 @@ void irq_dispose_mapping(unsigned int virq)
irq_set_status_flags(virq, IRQ_NOREQUEST);
- irq_free_descs(virq, 1);
/* Free it */
irq_free_virt(virq);
}
@@ -998,6 +985,7 @@ static unsigned int irq_alloc_virt(struct irq_host *host, unsigned int hint)
{
unsigned long flags;
unsigned int i, j, found = NO_IRQ;
+ int res;
raw_spin_lock_irqsave(&irq_big_lock, flags);
@@ -1024,7 +1012,25 @@ static unsigned int irq_alloc_virt(struct irq_host *host, unsigned int hint)
smp_wmb();
irq_map[found].host = host;
raw_spin_unlock_irqrestore(&irq_big_lock, flags);
+
+ res = irq_alloc_desc_at(found, 0);
+ if (res != found) {
+ pr_debug("irq: -> allocating desc failed\n");
+ goto error_desc;
+ }
+
+ irq_clear_status_flags(found, IRQ_NOREQUEST);
+
return found;
+
+ error_desc:
+ raw_spin_lock_irqsave(&irq_big_lock, flags);
+ host = irq_map[found].host;
+ irq_map[found].hwirq = host->inval_irq;
+ smp_wmb();
+ irq_map[found].host = NULL;
+ raw_spin_unlock_irqrestore(&irq_big_lock, flags);
+ return NO_IRQ;
}
/**
@@ -1045,6 +1051,7 @@ static void irq_free_virt(unsigned int virq)
return;
}
+ irq_free_descs(virq, 1);
raw_spin_lock_irqsave(&irq_big_lock, flags);
host = irq_map[virq].host;
irq_map[virq].hwirq = host->inval_irq;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists