]> git.karo-electronics.de Git - linux-beck.git/commitdiff
irqdomain: make irq_linear_revmap() a fast path again
authorGrant Likely <grant.likely@linaro.org>
Mon, 10 Jun 2013 11:19:17 +0000 (12:19 +0100)
committerGrant Likely <grant.likely@linaro.org>
Mon, 24 Jun 2013 13:02:41 +0000 (14:02 +0100)
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
kernel/irq/irqdomain.c

index 6efbeccac56cd7840b28a560a6b0675342578b63..c983ed18c3326d8531a8acd01f1d83c65d9756e5 100644 (file)
@@ -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 */
index e47b356713842accfc1ae33aeb7d481bd5a4e08b..836a0f7ec2a9b52ee97ad0c71af5525e6ab0b21e 100644 (file)
@@ -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)
 {