All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Marc Zyngier <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jason@lakedaemon.net, marc.zyngier@arm.com, hpa@zytor.com,
	Suravee.Suthikulpanit@amd.com, hanjun.guo@linaro.org,
	graeme@xora.org.uk, mingo@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, jiang.liu@linux.intel.com,
	tomasz.nowicki@linaro.org, rjw@rjwysocki.net,
	lorenzo.pieralisi@arm.com, jakeo@microsoft.com,
	tglx@linutronix.de
Subject: [tip:irq/core] irqdomain: Introduce a firmware-specific IRQ specifier structure
Date: Tue, 13 Oct 2015 10:55:41 -0700	[thread overview]
Message-ID: <tip-11e4438ee330fab0f216ee7cc1b651cb2ddceb5d@git.kernel.org> (raw)
In-Reply-To: <1444737105-31573-5-git-send-email-marc.zyngier@arm.com>

Commit-ID:  11e4438ee330fab0f216ee7cc1b651cb2ddceb5d
Gitweb:     http://git.kernel.org/tip/11e4438ee330fab0f216ee7cc1b651cb2ddceb5d
Author:     Marc Zyngier <marc.zyngier@arm.com>
AuthorDate: Tue, 13 Oct 2015 12:51:32 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 13 Oct 2015 19:01:23 +0200

irqdomain: Introduce a firmware-specific IRQ specifier structure

So far the closest thing to a generic IRQ specifier structure is
of_phandle_args, which happens to be pretty OF specific (the of_node
pointer in there is quite annoying).

Let's introduce 'struct irq_fwspec' that can be used in place of
of_phandle_args for OF, but also for other firmware implementations
(that'd be ACPI). This is used together with a new 'translate' method
that is the pendent of 'xlate'.

We convert irq_create_of_mapping to use this new structure (with a
small hack that will be removed later).

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-and-tested-by: Hanjun Guo <hanjun.guo@linaro.org>
Tested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Cc: Graeme Gregory <graeme@xora.org.uk>
Cc: Jake Oshins <jakeo@microsoft.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Link: http://lkml.kernel.org/r/1444737105-31573-5-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/irqdomain.h | 20 ++++++++++++++++
 kernel/irq/irqdomain.c    | 59 ++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 68 insertions(+), 11 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 607c185..533c974 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -46,6 +46,24 @@ struct irq_data;
 /* Number of irqs reserved for a legacy isa controller */
 #define NUM_ISA_INTERRUPTS	16
 
+#define IRQ_DOMAIN_IRQ_SPEC_PARAMS 16
+
+/**
+ * struct irq_fwspec - generic IRQ specifier structure
+ *
+ * @fwnode:		Pointer to a firmware-specific descriptor
+ * @param_count:	Number of device-specific parameters
+ * @param:		Device-specific parameters
+ *
+ * This structure, directly modeled after of_phandle_args, is used to
+ * pass a device-specific description of an interrupt.
+ */
+struct irq_fwspec {
+	struct fwnode_handle *fwnode;
+	int param_count;
+	u32 param[IRQ_DOMAIN_IRQ_SPEC_PARAMS];
+};
+
 /*
  * Should several domains have the same device node, but serve
  * different purposes (for example one domain is for PCI/MSI, and the
@@ -92,6 +110,8 @@ struct irq_domain_ops {
 		     unsigned int nr_irqs);
 	void (*activate)(struct irq_domain *d, struct irq_data *irq_data);
 	void (*deactivate)(struct irq_domain *d, struct irq_data *irq_data);
+	int (*translate)(struct irq_domain *d, struct irq_fwspec *fwspec,
+			 unsigned long *out_hwirq, unsigned int *out_type);
 #endif
 };
 
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 023ab6d..86dfd40 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -484,30 +484,67 @@ int irq_create_strict_mappings(struct irq_domain *domain, unsigned int irq_base,
 }
 EXPORT_SYMBOL_GPL(irq_create_strict_mappings);
 
+static int irq_domain_translate(struct irq_domain *d,
+				struct irq_fwspec *fwspec,
+				irq_hw_number_t *hwirq, unsigned int *type)
+{
+#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
+	if (d->ops->translate)
+		return d->ops->translate(d, fwspec, hwirq, type);
+#endif
+	if (d->ops->xlate)
+		return d->ops->xlate(d, to_of_node(fwspec->fwnode),
+				     fwspec->param, fwspec->param_count,
+				     hwirq, type);
+
+	/* If domain has no translation, then we assume interrupt line */
+	*hwirq = fwspec->param[0];
+	return 0;
+}
+
+static void of_phandle_args_to_fwspec(struct of_phandle_args *irq_data,
+				      struct irq_fwspec *fwspec)
+{
+	int i;
+
+	fwspec->fwnode = irq_data->np ? &irq_data->np->fwnode : NULL;
+	fwspec->param_count = irq_data->args_count;
+
+	for (i = 0; i < irq_data->args_count; i++)
+		fwspec->param[i] = irq_data->args[i];
+}
+
 unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data)
 {
+	struct irq_fwspec fwspec;
 	struct irq_domain *domain;
 	irq_hw_number_t hwirq;
 	unsigned int type = IRQ_TYPE_NONE;
 	int virq;
 
-	domain = irq_data->np ? irq_find_host(irq_data->np) : irq_default_domain;
+	of_phandle_args_to_fwspec(irq_data, &fwspec);
+
+	if (fwspec.fwnode)
+		domain = irq_find_matching_fwnode(fwspec.fwnode, DOMAIN_BUS_ANY);
+	else
+		domain = irq_default_domain;
+
 	if (!domain) {
 		pr_warn("no irq domain found for %s !\n",
-			of_node_full_name(irq_data->np));
+			of_node_full_name(to_of_node(fwspec.fwnode)));
 		return 0;
 	}
 
-	/* If domain has no translation, then we assume interrupt line */
-	if (domain->ops->xlate == NULL)
-		hwirq = irq_data->args[0];
-	else {
-		if (domain->ops->xlate(domain, irq_data->np, irq_data->args,
-					irq_data->args_count, &hwirq, &type))
-			return 0;
-	}
+	if (irq_domain_translate(domain, &fwspec, &hwirq, &type))
+		return 0;
 
 	if (irq_domain_is_hierarchy(domain)) {
+		/* Temporary hack */
+		void *desc = &fwspec;
+#ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
+		if (!domain->ops->translate)
+			desc = irq_data;
+#endif
 		/*
 		 * If we've already configured this interrupt,
 		 * don't do it again, or hell will break loose.
@@ -516,7 +553,7 @@ unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data)
 		if (virq)
 			return virq;
 
-		virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, irq_data);
+		virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, desc);
 		if (virq <= 0)
 			return 0;
 	} else {

  reply	other threads:[~2015-10-13 17:56 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-13 11:51 [PATCH v2 00/17] Divorcing irqdomain and device_node Marc Zyngier
2015-10-13 11:51 ` Marc Zyngier
2015-10-13 11:51 ` Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 01/17] irqdomain: Use irq_domain_get_of_node() instead of direct field access Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:54   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 02/17] irqdomain: Convert irqdomain->of_node to fwnode Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:55   ` [tip:irq/core] irqdomain: Convert irqdomain-%3Eof_node " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 03/17] irqdomain: Allow irq domain lookup by fwnode Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:55   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 04/17] irqdomain: Introduce a firmware-specific IRQ specifier structure Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:55   ` tip-bot for Marc Zyngier [this message]
2015-10-13 11:51 ` [PATCH v2 05/17] irqchip: Convert all alloc/xlate users from of_node to fwnode Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:56   ` [tip:irq/core] irqchip: Convert all alloc/ xlate " tip-bot for Marc Zyngier
2015-10-14 15:26   ` [PATCH v2 05/17] irqchip: Convert all alloc/xlate " Tomasz Nowicki
2015-10-14 15:26     ` Tomasz Nowicki
2015-10-14 15:31     ` Marc Zyngier
2015-10-14 15:31       ` Marc Zyngier
2015-10-14 15:37       ` Tomasz Nowicki
2015-10-14 15:37         ` Tomasz Nowicki
2015-10-13 11:51 ` [PATCH v2 06/17] irqdomain: Introduce irq_create_fwspec_mapping Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:56   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 07/17] irqdomain: Introduce irq_domain_create_{linear, tree} Marc Zyngier
2015-10-13 11:51   ` [PATCH v2 07/17] irqdomain: Introduce irq_domain_create_{linear,tree} Marc Zyngier
2015-10-13 11:51   ` [PATCH v2 07/17] irqdomain: Introduce irq_domain_create_{linear, tree} Marc Zyngier
2015-10-13 17:56   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 08/17] irqdomain: Add a fwnode_handle allocator Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:57   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 09/17] acpi/gsi: Always perform an irq domain lookup Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:57   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 10/17] acpi/gsi: Add acpi_set_irq_model to initialize the GSI layer Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:57   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 11/17] irqchip/gic: Get rid of gic_init_bases() Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:58   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 12/17] irqchip/gic: Switch ACPI support to stacked domains Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:58   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 13/17] irqchip/gic: Kill the xlate method Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:58   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 14/17] acpi/gsi: Cleanup acpi_register_gsi Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:59   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 15/17] irqdomain: Introduce irq_domain_create_hierarchy Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:59   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 16/17] irqdomain/msi: Use fwnode instead of of_node Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 17:59   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 11:51 ` [PATCH v2 17/17] irqdomain: Documentation updates Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 11:51   ` Marc Zyngier
2015-10-13 18:00   ` [tip:irq/core] " tip-bot for Marc Zyngier
2015-10-13 13:49 ` [PATCH v2 00/17] Divorcing irqdomain and device_node Hanjun Guo
2015-10-13 13:49   ` Hanjun Guo
2015-10-13 15:33   ` Hanjun Guo
2015-10-13 15:33     ` Hanjun Guo
2015-10-13 15:38   ` Marc Zyngier
2015-10-13 15:38     ` Marc Zyngier
2015-10-13 16:39 ` Lorenzo Pieralisi
2015-10-13 16:39   ` Lorenzo Pieralisi

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=tip-11e4438ee330fab0f216ee7cc1b651cb2ddceb5d@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=Suravee.Suthikulpanit@amd.com \
    --cc=graeme@xora.org.uk \
    --cc=hanjun.guo@linaro.org \
    --cc=hpa@zytor.com \
    --cc=jakeo@microsoft.com \
    --cc=jason@lakedaemon.net \
    --cc=jiang.liu@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=marc.zyngier@arm.com \
    --cc=mingo@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    --cc=tomasz.nowicki@linaro.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.