]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
genirq/irqdomain: Allow irq domain aliasing
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 28 Jul 2015 13:46:08 +0000 (14:46 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 29 Jul 2015 22:14:36 +0000 (00:14 +0200)
It is not uncommon (at least with the ARM stuff) to have a piece
of hardware that implements different flavours of "interrupts".
A typical example of this is the GICv3 ITS, which implements
standard PCI/MSI support, but also some form of "generic MSI".

So far, the PCI/MSI domain is registered using the ITS device_node,
so that irq_find_host can return it. On the contrary, the raw MSI
domain is not registered with an device_node, making it impossible
to be looked up by another subsystem (obviously, using the same
device_node twice would only result in confusion, as it is not
defined which one irq_find_host would return).

A solution to this is to "type" domains that may be aliasing, and
to be able to lookup an device_node that matches a given type.
For this, we introduce irq_find_matching_host() as a superset
of irq_find_host:

struct irq_domain *irq_find_matching_host(struct device_node *node,
                                enum irq_domain_bus_token bus_token);

where bus_token is the "type" we want to match the domain against
(so far, only DOMAIN_BUS_ANY is defined). This result in some
moderately invasive changes on the PPC side (which is the only
user of the .match method).

This has otherwise no functionnal change.

Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: Yijing Wang <wangyijing@huawei.com>
Cc: Ma Jun <majun258@huawei.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Duc Dang <dhdang@apm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Link: http://lkml.kernel.org/r/1438091186-10244-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
14 files changed:
arch/powerpc/platforms/512x/mpc5121_ads_cpld.c
arch/powerpc/platforms/cell/interrupt.c
arch/powerpc/platforms/embedded6xx/flipper-pic.c
arch/powerpc/platforms/powermac/pic.c
arch/powerpc/platforms/powernv/opal-irqchip.c
arch/powerpc/platforms/ps3/interrupt.c
arch/powerpc/sysdev/ehv_pic.c
arch/powerpc/sysdev/i8259.c
arch/powerpc/sysdev/ipic.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/sysdev/qe_lib/qe_ic.c
arch/powerpc/sysdev/xics/xics-common.c
include/linux/irqdomain.h
kernel/irq/irqdomain.c

index ca3a062ed1b928327a15d34d3f6bbb89f0913648..11090ab4bf59a38f2b78074fd8b7a9e10467656d 100644 (file)
@@ -123,7 +123,8 @@ cpld_pic_cascade(unsigned int irq, struct irq_desc *desc)
 }
 
 static int
-cpld_pic_host_match(struct irq_domain *h, struct device_node *node)
+cpld_pic_host_match(struct irq_domain *h, struct device_node *node,
+                   enum irq_domain_bus_token bus_token)
 {
        return cpld_pic_node == node;
 }
index 3af8324c122e60ba952b137bc912806f0f596f9a..a15f1efc295f936d3de64bb17a62d76c86778a1c 100644 (file)
@@ -222,7 +222,8 @@ void iic_request_IPIs(void)
 #endif /* CONFIG_SMP */
 
 
-static int iic_host_match(struct irq_domain *h, struct device_node *node)
+static int iic_host_match(struct irq_domain *h, struct device_node *node,
+                         enum irq_domain_bus_token bus_token)
 {
        return of_device_is_compatible(node,
                                    "IBM,CBEA-Internal-Interrupt-Controller");
index 4cde8e7da4b8e0f9ec8afdd9fd1d0d0eb8f8090a..b7866e01483d5d4eb7f7e816ca38da8a8c1c42b6 100644 (file)
@@ -108,7 +108,8 @@ static int flipper_pic_map(struct irq_domain *h, unsigned int virq,
        return 0;
 }
 
-static int flipper_pic_match(struct irq_domain *h, struct device_node *np)
+static int flipper_pic_match(struct irq_domain *h, struct device_node *np,
+                            enum irq_domain_bus_token bus_token)
 {
        return 1;
 }
index 59cfc9d63c2d51a711448c1de281cf42fcf04349..6f4f8b060def53cc1afc55b80ffd3f230766bb81 100644 (file)
@@ -268,7 +268,8 @@ static struct irqaction gatwick_cascade_action = {
        .name           = "cascade",
 };
 
-static int pmac_pic_host_match(struct irq_domain *h, struct device_node *node)
+static int pmac_pic_host_match(struct irq_domain *h, struct device_node *node,
+                              enum irq_domain_bus_token bus_token)
 {
        /* We match all, we don't always have a node anyway */
        return 1;
index e2e7d75f52f39234487e1ba51c9014f2c3427b78..2c91ee7800b90e09edb93a35aa162da74071ba8c 100644 (file)
@@ -134,7 +134,8 @@ static void opal_handle_irq_work(struct irq_work *work)
        opal_handle_events(be64_to_cpu(last_outstanding_events));
 }
 
-static int opal_event_match(struct irq_domain *h, struct device_node *node)
+static int opal_event_match(struct irq_domain *h, struct device_node *node,
+                           enum irq_domain_bus_token bus_token)
 {
        return h->of_node == node;
 }
index a6c42f34303aaa3ae0d47542493006fcd952bded..638c4060938e387aa55629a085dd0fa1ad993e4c 100644 (file)
@@ -678,7 +678,8 @@ static int ps3_host_map(struct irq_domain *h, unsigned int virq,
        return 0;
 }
 
-static int ps3_host_match(struct irq_domain *h, struct device_node *np)
+static int ps3_host_match(struct irq_domain *h, struct device_node *np,
+                         enum irq_domain_bus_token bus_token)
 {
        /* Match all */
        return 1;
index 2d20f10a42030394581c001e9f19793ebe4667bd..eca0b00794fa567edb3edc2d12650328b4dec486 100644 (file)
@@ -177,7 +177,8 @@ unsigned int ehv_pic_get_irq(void)
        return irq_linear_revmap(global_ehv_pic->irqhost, irq);
 }
 
-static int ehv_pic_host_match(struct irq_domain *h, struct device_node *node)
+static int ehv_pic_host_match(struct irq_domain *h, struct device_node *node,
+                             enum irq_domain_bus_token bus_token)
 {
        /* Exact match, unless ehv_pic node is NULL */
        return h->of_node == NULL || h->of_node == node;
index 31c33475c7b7042e2224a1094c9070c558096990..e1a9c2c2d5d357c7e88083d60a6f89c0d04219c2 100644 (file)
@@ -162,7 +162,8 @@ static struct resource pic_edgectrl_iores = {
        .flags = IORESOURCE_BUSY,
 };
 
-static int i8259_host_match(struct irq_domain *h, struct device_node *node)
+static int i8259_host_match(struct irq_domain *h, struct device_node *node,
+                           enum irq_domain_bus_token bus_token)
 {
        return h->of_node == NULL || h->of_node == node;
 }
index d78f1364b639d8ab0f208d37b0ef8662b3d7568e..6b2b689148104a25003fba7380af676f2a85e055 100644 (file)
@@ -671,7 +671,8 @@ static struct irq_chip ipic_edge_irq_chip = {
        .irq_set_type   = ipic_set_irq_type,
 };
 
-static int ipic_host_match(struct irq_domain *h, struct device_node *node)
+static int ipic_host_match(struct irq_domain *h, struct device_node *node,
+                          enum irq_domain_bus_token bus_token)
 {
        /* Exact match, unless ipic node is NULL */
        return h->of_node == NULL || h->of_node == node;
index c8e73332eaad5ab1d08ef3036be34b4b484d8ef6..97a8ae8f94dd5d3fe77753c4546c6c7ab6329a49 100644 (file)
@@ -1007,7 +1007,8 @@ static struct irq_chip mpic_irq_ht_chip = {
 #endif /* CONFIG_MPIC_U3_HT_IRQS */
 
 
-static int mpic_host_match(struct irq_domain *h, struct device_node *node)
+static int mpic_host_match(struct irq_domain *h, struct device_node *node,
+                          enum irq_domain_bus_token bus_token)
 {
        /* Exact match, unless mpic node is NULL */
        return h->of_node == NULL || h->of_node == node;
index 6512cd8caa517d92496110e8119af46ae067d242..47b352e4bc743f532aa637d9d18daf7319207f92 100644 (file)
@@ -244,7 +244,8 @@ static struct irq_chip qe_ic_irq_chip = {
        .irq_mask_ack = qe_ic_mask_irq,
 };
 
-static int qe_ic_host_match(struct irq_domain *h, struct device_node *node)
+static int qe_ic_host_match(struct irq_domain *h, struct device_node *node,
+                           enum irq_domain_bus_token bus_token)
 {
        /* Exact match, unless qe_ic node is NULL */
        return h->of_node == NULL || h->of_node == node;
index 08c248eb491bad53e82afe28a73b510d4aa87f86..47e43b7b076bb2e4aa0cd3790e132185b422f9ae 100644 (file)
@@ -298,7 +298,8 @@ int xics_get_irq_server(unsigned int virq, const struct cpumask *cpumask,
 }
 #endif /* CONFIG_SMP */
 
-static int xics_host_match(struct irq_domain *h, struct device_node *node)
+static int xics_host_match(struct irq_domain *h, struct device_node *node,
+                          enum irq_domain_bus_token bus_token)
 {
        struct ics *ics;
 
index 744ac0ec98eb2c9e094f8ebdcfd71aebcdd32026..91a83adf5e45849ccdf97bb68c2da0a2418a441f 100644 (file)
@@ -45,6 +45,17 @@ struct irq_data;
 /* Number of irqs reserved for a legacy isa controller */
 #define NUM_ISA_INTERRUPTS     16
 
+/*
+ * Should several domains have the same device node, but serve
+ * different purposes (for example one domain is for PCI/MSI, and the
+ * other for wired IRQs), they can be distinguished using a
+ * bus-specific token. Most domains are expected to only carry
+ * DOMAIN_BUS_ANY.
+ */
+enum irq_domain_bus_token {
+       DOMAIN_BUS_ANY          = 0,
+};
+
 /**
  * struct irq_domain_ops - Methods for irq_domain objects
  * @match: Match an interrupt controller device node to a host, returns
@@ -61,7 +72,8 @@ struct irq_data;
  * to setup the irq_desc when returning from map().
  */
 struct irq_domain_ops {
-       int (*match)(struct irq_domain *d, struct device_node *node);
+       int (*match)(struct irq_domain *d, struct device_node *node,
+                    enum irq_domain_bus_token bus_token);
        int (*map)(struct irq_domain *d, unsigned int virq, irq_hw_number_t hw);
        void (*unmap)(struct irq_domain *d, unsigned int virq);
        int (*xlate)(struct irq_domain *d, struct device_node *node,
@@ -116,6 +128,7 @@ struct irq_domain {
 
        /* Optional data */
        struct device_node *of_node;
+       enum irq_domain_bus_token bus_token;
        struct irq_domain_chip_generic *gc;
 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
        struct irq_domain *parent;
@@ -161,9 +174,15 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
                                         irq_hw_number_t first_hwirq,
                                         const struct irq_domain_ops *ops,
                                         void *host_data);
-extern struct irq_domain *irq_find_host(struct device_node *node);
+extern struct irq_domain *irq_find_matching_host(struct device_node *node,
+                                                enum irq_domain_bus_token bus_token);
 extern void irq_set_default_host(struct irq_domain *host);
 
+static inline struct irq_domain *irq_find_host(struct device_node *node)
+{
+       return irq_find_matching_host(node, DOMAIN_BUS_ANY);
+}
+
 /**
  * irq_domain_add_linear() - Allocate and register a linear revmap irq_domain.
  * @of_node: pointer to interrupt controller's device tree node.
index 8c3577fef78c4ee50cd6912d1cc87202e7d17cf2..79baaf8a7813a601659d1316becba1fe0fd9807c 100644 (file)
@@ -187,10 +187,12 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
 EXPORT_SYMBOL_GPL(irq_domain_add_legacy);
 
 /**
- * irq_find_host() - Locates a domain for a given device node
+ * irq_find_matching_host() - Locates a domain for a given device node
  * @node: device-tree node of the interrupt controller
+ * @bus_token: domain-specific data
  */
-struct irq_domain *irq_find_host(struct device_node *node)
+struct irq_domain *irq_find_matching_host(struct device_node *node,
+                                         enum irq_domain_bus_token bus_token)
 {
        struct irq_domain *h, *found = NULL;
        int rc;
@@ -199,13 +201,19 @@ struct irq_domain *irq_find_host(struct device_node *node)
         * it might potentially be set to match all interrupts in
         * the absence of a device node. This isn't a problem so far
         * yet though...
+        *
+        * bus_token == DOMAIN_BUS_ANY matches any domain, any other
+        * values must generate an exact match for the domain to be
+        * selected.
         */
        mutex_lock(&irq_domain_mutex);
        list_for_each_entry(h, &irq_domain_list, link) {
                if (h->ops->match)
-                       rc = h->ops->match(h, node);
+                       rc = h->ops->match(h, node, bus_token);
                else
-                       rc = (h->of_node != NULL) && (h->of_node == node);
+                       rc = ((h->of_node != NULL) && (h->of_node == node) &&
+                             ((bus_token == DOMAIN_BUS_ANY) ||
+                              (h->bus_token == bus_token)));
 
                if (rc) {
                        found = h;
@@ -215,7 +223,7 @@ struct irq_domain *irq_find_host(struct device_node *node)
        mutex_unlock(&irq_domain_mutex);
        return found;
 }
-EXPORT_SYMBOL_GPL(irq_find_host);
+EXPORT_SYMBOL_GPL(irq_find_matching_host);
 
 /**
  * irq_set_default_host() - Set a "default" irq domain