From: tip-bot for Marc Zyngier <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jiang.liu@linux.intel.com, graeme@xora.org.uk,
tglx@linutronix.de, tomasz.nowicki@linaro.org,
jason@lakedaemon.net, linux-kernel@vger.kernel.org,
hpa@zytor.com, jakeo@microsoft.com, rafael.j.wysocki@intel.com,
mingo@kernel.org, rjw@rjwysocki.net,
Suravee.Suthikulpanit@amd.com,
linux-arm-kernel@lists.infradead.org, hanjun.guo@linaro.org,
lorenzo.pieralisi@arm.com, marc.zyngier@arm.com
Subject: [tip:irq/core] irqdomain: Add a fwnode_handle allocator
Date: Tue, 13 Oct 2015 10:57:03 -0700 [thread overview]
Message-ID: <tip-b145dcc45a6af0abfcf9b4de8006d40559c50fc6@git.kernel.org> (raw)
In-Reply-To: <1444737105-31573-9-git-send-email-marc.zyngier@arm.com>
Commit-ID: b145dcc45a6af0abfcf9b4de8006d40559c50fc6
Gitweb: http://git.kernel.org/tip/b145dcc45a6af0abfcf9b4de8006d40559c50fc6
Author: Marc Zyngier <marc.zyngier@arm.com>
AuthorDate: Tue, 13 Oct 2015 12:51:36 +0100
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 13 Oct 2015 19:01:24 +0200
irqdomain: Add a fwnode_handle allocator
In order to be able to reference an irqdomain from ACPI, we need
to be able to create an identifier, which is usually a struct
device_node.
This device node does't really fit the ACPI infrastructure, so
we cunningly allocate a new structure containing a fwnode_handle,
and return that.
This structure doesn't really point to a device (interrupt
controllers are not "real" devices in Linux), but as we cannot
really deny that they exist, we create them with a new fwnode_type
(FWNODE_IRQCHIP).
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.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-9-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/fwnode.h | 1 +
include/linux/irqdomain.h | 2 ++
kernel/irq/irqdomain.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+)
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 0408545..37ec668 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -17,6 +17,7 @@ enum fwnode_type {
FWNODE_OF,
FWNODE_ACPI,
FWNODE_PDATA,
+ FWNODE_IRQCHIP,
};
struct fwnode_handle {
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 995d4c5..949caa7 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -188,6 +188,8 @@ static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
}
#ifdef CONFIG_IRQ_DOMAIN
+struct fwnode_handle *irq_domain_alloc_fwnode(void *data);
+void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
irq_hw_number_t hwirq_max, int direct_max,
const struct irq_domain_ops *ops,
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index de6d749..41151d3 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -27,6 +27,57 @@ static int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
irq_hw_number_t hwirq, int node);
static void irq_domain_check_hierarchy(struct irq_domain *domain);
+struct irqchip_fwid {
+ struct fwnode_handle fwnode;
+ char *name;
+ void *data;
+};
+
+/**
+ * irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for
+ * identifying an irq domain
+ * @data: optional user-provided data
+ *
+ * Allocate a struct device_node, and return a poiner to the embedded
+ * fwnode_handle (or NULL on failure).
+ */
+struct fwnode_handle *irq_domain_alloc_fwnode(void *data)
+{
+ struct irqchip_fwid *fwid;
+ char *name;
+
+ fwid = kzalloc(sizeof(*fwid), GFP_KERNEL);
+ name = kasprintf(GFP_KERNEL, "irqchip@%p", data);
+
+ if (!fwid || !name) {
+ kfree(fwid);
+ kfree(name);
+ return NULL;
+ }
+
+ fwid->name = name;
+ fwid->data = data;
+ fwid->fwnode.type = FWNODE_IRQCHIP;
+ return &fwid->fwnode;
+}
+
+/**
+ * irq_domain_free_fwnode - Free a non-OF-backed fwnode_handle
+ *
+ * Free a fwnode_handle allocated with irq_domain_alloc_fwnode.
+ */
+void irq_domain_free_fwnode(struct fwnode_handle *fwnode)
+{
+ struct irqchip_fwid *fwid;
+
+ if (WARN_ON(fwnode->type != FWNODE_IRQCHIP))
+ return;
+
+ fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
+ kfree(fwid->name);
+ kfree(fwid);
+}
+
/**
* __irq_domain_add() - Allocate a new irq_domain data structure
* @of_node: optional device-tree node of the interrupt controller
next prev parent reply other threads:[~2015-10-13 17:57 UTC|newest]
Thread overview: 42+ 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 ` [PATCH v2 01/17] irqdomain: Use irq_domain_get_of_node() instead of direct field access 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 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 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 17:55 ` [tip:irq/core] " tip-bot for Marc Zyngier
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 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:31 ` Marc Zyngier
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 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 17:56 ` [tip:irq/core] irqdomain: Introduce irq_domain_create_{linear, tree} 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 17:57 ` tip-bot for Marc Zyngier [this message]
2015-10-13 11:51 ` [PATCH v2 09/17] acpi/gsi: Always perform an irq domain lookup 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 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 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 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 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 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 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 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 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 15:33 ` Hanjun Guo
2015-10-13 15:38 ` Marc Zyngier
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-b145dcc45a6af0abfcf9b4de8006d40559c50fc6@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=rafael.j.wysocki@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox