From: Marc Zyngier <marc.zyngier@arm.com>
To: Rob Herring <robh+dt@kernel.org>,
Jason Cooper <jason@lakedaemon.net>,
Thomas Gleixner <tglx@linutronix.de>,
Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
Mark Rutland <Mark.Rutland@arm.com>,
David Daney <ddaney.cavm@gmail.com>,
Robin Murphy <robin.murphy@arm.com>
Subject: [PATCH v2 1/8] of/irq: Add support code for multi-parent version of "msi-parent"
Date: Tue, 6 Oct 2015 18:03:56 +0100 [thread overview]
Message-ID: <1444151043-31084-2-git-send-email-marc.zyngier@arm.com> (raw)
In-Reply-To: <1444151043-31084-1-git-send-email-marc.zyngier@arm.com>
Since 126b16e2ad98 ("Docs: dt: add generic MSI bindings"),
the definition of "msi-parent" has evolved, while maintaining
some degree of compatibility. It can now express multiple MSI
controllers as parents, as well as some sideband data being
communicated to the controller.
This patch adds the parsing of the property, iterating over
the multiple parents until a suitable irqdomain is found.
It can also fallback to the original parsing if the old
binding is detected.
This support code gets used in the subsequent patches.
Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
drivers/of/irq.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/of_irq.h | 9 ++++++++
2 files changed, 68 insertions(+)
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index c90bd4e..62cfdc2 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -682,3 +682,62 @@ u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in)
return rid_out;
}
+
+static struct irq_domain *__of_get_msi_domain(struct device_node *np,
+ enum irq_domain_bus_token token)
+{
+ struct irq_domain *d;
+
+ d = irq_find_matching_host(np, token);
+ if (!d)
+ d = irq_find_host(np);
+
+ return d;
+}
+
+/**
+ * of_msi_get_domain - Use msi-parent to find the relevant MSI domain
+ * @dev: device for which the domain is requested
+ * @np: device node for @dev
+ * @token: bus type for this domain
+ *
+ * Parse the msi-parent property (both the simple and the complex
+ * versions), and returns the corresponding MSI domain.
+ *
+ * Returns: the MSI domain for this device (or NULL on failure).
+ */
+struct irq_domain *of_msi_get_domain(struct device *dev,
+ struct device_node *np,
+ enum irq_domain_bus_token token)
+{
+ struct device_node *msi_np;
+ struct irq_domain *d;
+
+ /* Check for a single msi-parent property */
+ msi_np = of_parse_phandle(np, "msi-parent", 0);
+ if (msi_np && !of_property_read_bool(msi_np, "#msi-cells")) {
+ d = __of_get_msi_domain(msi_np, token);
+ if (!d)
+ of_node_put(msi_np);
+ return d;
+ }
+
+ if (token == DOMAIN_BUS_PLATFORM_MSI) {
+ /* Check for the complex msi-parent version */
+ struct of_phandle_args args;
+ int index = 0;
+
+ while (!of_parse_phandle_with_args(np, "msi-parent",
+ "#msi-cells",
+ index, &args)) {
+ d = __of_get_msi_domain(args.np, token);
+ if (d)
+ return d;
+
+ of_node_put(args.np);
+ index++;
+ }
+ }
+
+ return NULL;
+}
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index 8cd9334..62ae6ed 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -46,6 +46,9 @@ extern int of_irq_get(struct device_node *dev, int index);
extern int of_irq_get_byname(struct device_node *dev, const char *name);
extern int of_irq_to_resource_table(struct device_node *dev,
struct resource *res, int nr_irqs);
+extern struct irq_domain *of_msi_get_domain(struct device *dev,
+ struct device_node *np,
+ enum irq_domain_bus_token token);
#else
static inline int of_irq_count(struct device_node *dev)
{
@@ -64,6 +67,12 @@ static inline int of_irq_to_resource_table(struct device_node *dev,
{
return 0;
}
+static inline struct irq_domain *of_msi_get_domain(struct device *dev,
+ struct device_node *np,
+ enum irq_domain_bus_token token)
+{
+ return NULL;
+}
#endif
#if defined(CONFIG_OF)
--
2.1.4
next prev parent reply other threads:[~2015-10-06 17:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-06 17:03 [PATCH v2 0/8] of: Handle multi-parent version of msi-parent & msi-map Marc Zyngier
2015-10-06 17:03 ` Marc Zyngier [this message]
2015-10-06 17:03 ` [PATCH v2 2/8] of/irq: Use of_msi_get_domain instead of open-coded "msi-parent" parsing Marc Zyngier
2015-10-06 17:03 ` [PATCH v2 3/8] PCI/MSI: " Marc Zyngier
2015-10-15 20:10 ` Bjorn Helgaas
2015-10-06 17:03 ` [PATCH v2 4/8] irqchip/gic-v3-its: Parse new version of msi-parent property Marc Zyngier
2015-10-06 17:04 ` [PATCH v2 5/8] of/irq: Split of_msi_map_rid to reuse msi-map lookup Marc Zyngier
2015-10-06 17:04 ` [PATCH v2 6/8] of/irq: Use the msi-map property to provide device-specific MSI domain Marc Zyngier
2015-10-06 17:04 ` [PATCH v2 7/8] PCI: Add per-device MSI domain hook Marc Zyngier
2015-10-15 20:11 ` Bjorn Helgaas
2015-10-06 17:04 ` [PATCH v2 8/8] PCI/MSI: Allow the MSI domain to be device-specific Marc Zyngier
2015-10-15 20:11 ` Bjorn Helgaas
2015-10-15 20:39 ` [PATCH v2 0/8] of: Handle multi-parent version of msi-parent & msi-map Rob Herring
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=1444151043-31084-2-git-send-email-marc.zyngier@arm.com \
--to=marc.zyngier@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=bhelgaas@google.com \
--cc=ddaney.cavm@gmail.com \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--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®