mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@linaro.org>
To: linux-kernel@vger.kernel.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Grant Likely <grant.likely@linaro.org>
Subject: [PATCH v2 10/11] irqdomain: make irq_linear_revmap() a fast path again
Date: Fri, 14 Jun 2013 22:08:05 +0100	[thread overview]
Message-ID: <1371244086-9189-11-git-send-email-grant.likely@linaro.org> (raw)
In-Reply-To: <1371244086-9189-1-git-send-email-grant.likely@linaro.org>

Over the years, irq_linear_revmap() gained tests and checks to make sure
callers were using it safely, which while important, also make it less
of a fast path. After the irqdomain refactoring done recently, it is now
possible to make irq_linear_revmap() a fast path again. This patch moves
irq_linear_revmap() to the header file and makes it a static inline so
that interrupt controller drivers using a linear mapping can decode the
virq from a hwirq in just a couple of instructions.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 include/linux/irqdomain.h | 19 ++++++++++++++++---
 kernel/irq/irqdomain.c    | 34 ++++++++--------------------------
 2 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index fe7c57d..02f7658 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -176,6 +176,22 @@ extern void irq_domain_associate_many(struct irq_domain *domain,
 extern unsigned int irq_create_mapping(struct irq_domain *host,
 				       irq_hw_number_t hwirq);
 extern void irq_dispose_mapping(unsigned int virq);
+
+/**
+ * irq_linear_revmap() - Find a linux irq from a hw irq number.
+ * @domain: domain owning this hardware interrupt
+ * @hwirq: hardware irq number in that domain space
+ *
+ * This is a fast path alternative to irq_find_mapping() that can be
+ * called directly by irq controller code to save a handful of
+ * instructions. It is always safe to call, but won't find irqs mapped
+ * using the radix tree.
+ */
+static inline unsigned int irq_linear_revmap(struct irq_domain *domain,
+					     irq_hw_number_t hwirq)
+{
+	return hwirq < domain->revmap_size ? domain->linear_revmap[hwirq] : 0;
+}
 extern unsigned int irq_find_mapping(struct irq_domain *host,
 				     irq_hw_number_t hwirq);
 extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
@@ -189,9 +205,6 @@ static inline int irq_create_identity_mapping(struct irq_domain *host,
 	return irq_create_strict_mappings(host, hwirq, hwirq, 1);
 }
 
-extern unsigned int irq_linear_revmap(struct irq_domain *host,
-				      irq_hw_number_t hwirq);
-
 extern const struct irq_domain_ops irq_domain_simple_ops;
 
 /* stock xlate functions */
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index e47b356..836a0f7 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -559,35 +559,17 @@ unsigned int irq_find_mapping(struct irq_domain *domain,
 			return hwirq;
 	}
 
-	return irq_linear_revmap(domain, hwirq);
+	/* Check if the hwirq is in the linear revmap. */
+	if (hwirq < domain->revmap_size)
+		return domain->linear_revmap[hwirq];
+
+	rcu_read_lock();
+	data = radix_tree_lookup(&domain->revmap_tree, hwirq);
+	rcu_read_unlock();
+	return data ? data->irq : 0;
 }
 EXPORT_SYMBOL_GPL(irq_find_mapping);
 
-/**
- * irq_linear_revmap() - Find a linux irq from a hw irq number.
- * @domain: domain owning this hardware interrupt
- * @hwirq: hardware irq number in that domain space
- *
- * This is a fast path that can be called directly by irq controller code to
- * save a handful of instructions.
- */
-unsigned int irq_linear_revmap(struct irq_domain *domain,
-			       irq_hw_number_t hwirq)
-{
-	struct irq_data *data;
-
-	/* Check revmap bounds; complain if exceeded */
-	if (hwirq >= domain->revmap_size) {
-		rcu_read_lock();
-		data = radix_tree_lookup(&domain->revmap_tree, hwirq);
-		rcu_read_unlock();
-		return data ? data->irq : 0;
-	}
-
-	return domain->linear_revmap[hwirq];
-}
-EXPORT_SYMBOL_GPL(irq_linear_revmap);
-
 #ifdef CONFIG_IRQ_DOMAIN_DEBUG
 static int virq_debug_show(struct seq_file *m, void *private)
 {
-- 
1.8.1.2


  parent reply	other threads:[~2013-06-14 21:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-14 21:07 [PATCH v2 00/11] irqdomain: Refactor Grant Likely
2013-06-14 21:07 ` [PATCH v2 01/11] irqdomain: Relax failure path on setting up mappings Grant Likely
2013-06-14 21:07 ` [PATCH v2 02/11] irqdomain: Replace LEGACY mapping with LINEAR Grant Likely
2013-06-14 21:07 ` [PATCH v2 03/11] irqdomain: Add a name field Grant Likely
2013-06-14 21:07 ` [PATCH v2 04/11] irqdomain: merge linear and tree reverse mappings Grant Likely
2013-06-14 21:08 ` [PATCH v2 05/11] irqdomain: Eliminate revmap type Grant Likely
2013-06-14 21:08 ` [PATCH v2 06/11] irqdomain: Clean up aftermath of irq_domain refactoring Grant Likely
2013-06-14 21:08 ` [PATCH v2 07/11] irqdomain: Beef up debugfs output Grant Likely
2013-06-14 21:08 ` [PATCH v2 08/11] irqdomain: Refactor irq_domain_associate_many() Grant Likely
2013-06-18  1:20   ` Michael Neuling
2013-06-18  1:25     ` Michael Neuling
2013-06-18  1:37       ` Stephen Rothwell
2013-06-18  9:05       ` Grant Likely
2013-06-18  9:46         ` Grant Likely
2013-06-18 11:04           ` Michael Neuling
2013-06-18 12:13             ` Grant Likely
2013-06-14 21:08 ` [PATCH v2 09/11] irqdomain: remove irq_domain_generate_simple() Grant Likely
2013-06-14 21:08 ` Grant Likely [this message]
2013-06-14 21:08 ` [PATCH v2 11/11] irqdomain: Include hwirq number in /proc/interrupts Grant Likely

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=1371244086-9189-11-git-send-email-grant.likely@linaro.org \
    --to=grant.likely@linaro.org \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®