From: Grant Likely <grant.likely@secretlab.ca>
To: Michal Simek <monstr@monstr.eu>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org, Ralf Baechle <ralf@linux-mips.org>,
hpa@zytor.com, Dirk Brandewie <dirk.brandewie@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>
Cc: devicetree-discuss@lists.ozlabs.org, x86@kernel.org,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 6/6] powerpc: use irq_alloc_desc() to manage irq allocations
Date: Thu, 28 Apr 2011 14:02:14 -0600 [thread overview]
Message-ID: <20110428200214.8979.84221.stgit@ponder> (raw)
In-Reply-To: <20110428192227.8979.49181.stgit@ponder>
This patch drops the architecture specific code for managing irq
assignments and uses core code instead.
*RFC*
This patch is *not* ready for merging. The locking is messed up where
the irq_map is still used to find out if a mapping is already established,
but irq_alloc_desc() is now called before the irq_map is updated which
creates a race condition. I've not completely sorted out how to solve
this yet. The solution may very well be to convert the irq_big_lock
to a mutex (but I'm not sure if anything that sleeps calls the affected
code), and hold the mutex over the entire operation.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/powerpc/kernel/irq.c | 51 ++++++++++++---------------------------------
1 files changed, 14 insertions(+), 37 deletions(-)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 0fb90ab..e4a6646 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -984,53 +984,29 @@ unsigned int irq_linear_revmap(struct irq_host *host,
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;
+ int found;
- raw_spin_lock_irqsave(&irq_big_lock, flags);
-
- /* Use hint for 1 interrupt if any */
- if (hint >= NUM_ISA_INTERRUPTS &&
- hint < irq_virq_count && irq_map[hint].host == NULL) {
- found = hint;
- goto hint_found;
- }
-
- /* Look for a free virq in the allocatable (non-legacy) space */
- for (i = NUM_ISA_INTERRUPTS, j = 0; i < irq_virq_count; i++) {
- if (irq_map[i].host == NULL) {
- found = i;
- break;
- }
- }
- if (found == NO_IRQ) {
- raw_spin_unlock_irqrestore(&irq_big_lock, flags);
+ /*
+ * Find an unused interrupt. First, attempt to allocate
+ * 'hint'. If that fails, then just allocate any free one.
+ */
+ found = irq_alloc_desc_at(hint, 0);
+ if (found <= NO_IRQ)
+ found = irq_alloc_desc(0);
+ if (found <= NO_IRQ) {
+ pr_debug("irq: -> allocating desc failed\n");
return NO_IRQ;
}
- hint_found:
+
+ raw_spin_lock_irqsave(&irq_big_lock, flags);
irq_map[found].hwirq = host->inval_irq;
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;
}
/**
@@ -1051,13 +1027,14 @@ 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;
smp_wmb();
irq_map[virq].host = NULL;
raw_spin_unlock_irqrestore(&irq_big_lock, flags);
+
+ irq_free_descs(virq, 1);
}
int arch_early_irq_init(void)
WARNING: multiple messages have this Message-ID (diff)
From: Grant Likely <grant.likely@secretlab.ca>
To: Michal Simek <monstr@monstr.eu>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org, Ralf Baechle <ralf>
Cc: devicetree-discuss@lists.ozlabs.org, x86@kernel.org,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 6/6] powerpc: use irq_alloc_desc() to manage irq allocations
Date: Thu, 28 Apr 2011 14:02:14 -0600 [thread overview]
Message-ID: <20110428200214.8979.84221.stgit@ponder> (raw)
In-Reply-To: <20110428192227.8979.49181.stgit@ponder>
This patch drops the architecture specific code for managing irq
assignments and uses core code instead.
*RFC*
This patch is *not* ready for merging. The locking is messed up where
the irq_map is still used to find out if a mapping is already established,
but irq_alloc_desc() is now called before the irq_map is updated which
creates a race condition. I've not completely sorted out how to solve
this yet. The solution may very well be to convert the irq_big_lock
to a mutex (but I'm not sure if anything that sleeps calls the affected
code), and hold the mutex over the entire operation.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/powerpc/kernel/irq.c | 51 ++++++++++++---------------------------------
1 files changed, 14 insertions(+), 37 deletions(-)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 0fb90ab..e4a6646 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -984,53 +984,29 @@ unsigned int irq_linear_revmap(struct irq_host *host,
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;
+ int found;
- raw_spin_lock_irqsave(&irq_big_lock, flags);
-
- /* Use hint for 1 interrupt if any */
- if (hint >= NUM_ISA_INTERRUPTS &&
- hint < irq_virq_count && irq_map[hint].host == NULL) {
- found = hint;
- goto hint_found;
- }
-
- /* Look for a free virq in the allocatable (non-legacy) space */
- for (i = NUM_ISA_INTERRUPTS, j = 0; i < irq_virq_count; i++) {
- if (irq_map[i].host == NULL) {
- found = i;
- break;
- }
- }
- if (found == NO_IRQ) {
- raw_spin_unlock_irqrestore(&irq_big_lock, flags);
+ /*
+ * Find an unused interrupt. First, attempt to allocate
+ * 'hint'. If that fails, then just allocate any free one.
+ */
+ found = irq_alloc_desc_at(hint, 0);
+ if (found <= NO_IRQ)
+ found = irq_alloc_desc(0);
+ if (found <= NO_IRQ) {
+ pr_debug("irq: -> allocating desc failed\n");
return NO_IRQ;
}
- hint_found:
+
+ raw_spin_lock_irqsave(&irq_big_lock, flags);
irq_map[found].hwirq = host->inval_irq;
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;
}
/**
@@ -1051,13 +1027,14 @@ 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;
smp_wmb();
irq_map[virq].host = NULL;
raw_spin_unlock_irqrestore(&irq_big_lock, flags);
+
+ irq_free_descs(virq, 1);
}
int arch_early_irq_init(void)
next prev parent reply other threads:[~2011-04-28 20:02 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-28 20:01 [PATCH 0/6] General device tree irq domain infrastructure Grant Likely
2011-04-28 20:01 ` Grant Likely
2011-04-28 20:01 ` [PATCH 1/6] powerpc: stop exporting irq_map Grant Likely
2011-04-28 20:01 ` Grant Likely
2011-05-03 1:44 ` Benjamin Herrenschmidt
2011-05-03 1:44 ` Benjamin Herrenschmidt
2011-05-03 1:44 ` Benjamin Herrenschmidt
2011-04-28 20:01 ` [PATCH 2/6] powerpc: make irq_{alloc, free}_virt private and remove count argument Grant Likely
2011-04-28 20:01 ` Grant Likely
2011-05-03 1:47 ` Benjamin Herrenschmidt
2011-05-03 1:47 ` Benjamin Herrenschmidt
2011-05-03 1:47 ` Benjamin Herrenschmidt
2011-05-04 15:59 ` Grant Likely
2011-05-04 15:59 ` Grant Likely
2011-05-05 0:39 ` Benjamin Herrenschmidt
2011-05-05 0:39 ` Benjamin Herrenschmidt
2011-04-28 20:01 ` [PATCH 3/6] powerpc: Make struct irq_host semi-private by moving into irqhost.h Grant Likely
2011-04-28 20:01 ` Grant Likely
2011-05-03 1:48 ` Benjamin Herrenschmidt
2011-05-03 1:48 ` Benjamin Herrenschmidt
2011-05-03 1:48 ` Benjamin Herrenschmidt
2011-04-28 20:02 ` [PATCH 4/6] dt: generalize irq_of_create_mapping() Grant Likely
2011-04-28 20:02 ` Grant Likely
2011-05-03 1:50 ` Benjamin Herrenschmidt
2011-05-03 1:50 ` Benjamin Herrenschmidt
2011-05-03 1:50 ` Benjamin Herrenschmidt
2011-05-04 16:05 ` Grant Likely
2011-05-04 16:05 ` Grant Likely
2011-05-05 0:43 ` Benjamin Herrenschmidt
2011-05-05 0:43 ` Benjamin Herrenschmidt
2011-05-05 0:43 ` Benjamin Herrenschmidt
2011-04-28 20:02 ` [PATCH 5/6] powerpc: move irq_alloc_descs_at() call into irq_alloc_virt() Grant Likely
2011-04-28 20:02 ` Grant Likely
2011-04-28 20:02 ` Grant Likely [this message]
2011-04-28 20:02 ` [PATCH 6/6] powerpc: use irq_alloc_desc() to manage irq allocations Grant Likely
2011-04-29 16:16 ` [PATCH 0/6] General device tree irq domain infrastructure Sebastian Andrzej Siewior
2011-04-29 16:16 ` Sebastian Andrzej Siewior
2011-04-29 17:43 ` Grant Likely
2011-04-29 17:43 ` Grant Likely
2011-05-03 1:43 ` Benjamin Herrenschmidt
2011-05-03 1:43 ` Benjamin Herrenschmidt
2011-05-03 1:43 ` Benjamin Herrenschmidt
2011-05-04 15:52 ` Grant Likely
2011-05-04 15:52 ` Grant Likely
2011-05-05 0:39 ` Benjamin Herrenschmidt
2011-05-05 0:39 ` Benjamin Herrenschmidt
2011-05-05 0:39 ` Benjamin Herrenschmidt
2011-05-05 8:37 ` Thomas Gleixner
2011-05-05 8:37 ` Thomas Gleixner
2011-05-05 14:07 ` Grant Likely
2011-05-05 14:07 ` Grant Likely
2011-05-05 14:07 ` Grant Likely
2011-05-05 14:14 ` Sebastian Andrzej Siewior
2011-05-05 14:14 ` Sebastian Andrzej Siewior
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=20110428200214.8979.84221.stgit@ponder \
--to=grant.likely@secretlab.ca \
--cc=benh@kernel.crashing.org \
--cc=bigeasy@linutronix.de \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=dirk.brandewie@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=monstr@monstr.eu \
--cc=ralf@linux-mips.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.