linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, Russell King <linux@arm.linux.org.uk>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
	Gregory Clement <gregory.clement@free-electrons.com>
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
	linux-arm-kernel@lists.infradead.org,
	Maen Suleiman <maen@marvell.com>,
	Lior Amsalem <alior@marvell.com>,
	Thierry Reding <thierry.reding@gmail.com>
Subject: [PATCHv6 07/13] irqdomain: add function to find a MSI irq_domain
Date: Thu,  1 Aug 2013 15:25:10 +0200	[thread overview]
Message-ID: <1375363516-2620-8-git-send-email-thomas.petazzoni@free-electrons.com> (raw)
In-Reply-To: <1375363516-2620-1-git-send-email-thomas.petazzoni@free-electrons.com>

Now that an irq_domain can be associated to a msi_chip structure, a
given PCIe driver will want to find this irq_domain, based on the
Device Tree node of the interrupt controller, as pointed by the
'msi-controller' DT property.

However, since on those platforms a single piece of hardware,
represented by a single DT node can provide both a "normal" IRQ domain
and a MSI-type IRQ domain, we need separate lookup functions to
distinguish them.

This patch makes irq_find_host() find only non-MSI-type IRQ domains,
and introduces irq_find_msi_host() to find only MSI-type IRQ
domains. It does so by factorizing the irq_find_host() logic into
__irq_find_host().

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 include/linux/irqdomain.h | 21 ++++++++++++++++++++-
 kernel/irq/irqdomain.c    | 13 ++++++++++---
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index b0504ff..fc669b4 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -129,7 +129,8 @@ 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);
+struct irq_domain *__irq_find_host(struct device_node *node,
+				   bool findmsi);
 extern void irq_set_default_host(struct irq_domain *host);
 
 /**
@@ -196,6 +197,24 @@ static inline struct irq_domain *irq_domain_add_msi(struct device_node *of_node,
 }
 
 
+/**
+ * irq_find_host() - Locates a domain for a given device node
+ * @node: device-tree node of the interrupt controller
+ */
+static inline struct irq_domain *irq_find_host(struct device_node *node)
+{
+	return __irq_find_host(node, false);
+}
+
+/**
+ * irq_find_msi_host() - Locates a MSI domain for a given device node
+ * @node: device-tree node of the interrupt controller
+ */
+static inline struct irq_domain *irq_find_msi_host(struct device_node *node)
+{
+	return __irq_find_host(node, true);
+}
+
 extern void irq_domain_remove(struct irq_domain *host);
 
 extern int irq_domain_associate(struct irq_domain *domain, unsigned int irq,
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 8d02af7..6d066e2 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -197,10 +197,14 @@ 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_host() - Locates a domain for a given device node,
+ * taking into account whether the domain is of MSI-type or not.
  * @node: device-tree node of the interrupt controller
+ * @findmsi: true when the domain being search is of MSI-type, false
+ * otherwise.
  */
-struct irq_domain *irq_find_host(struct device_node *node)
+struct irq_domain *__irq_find_host(struct device_node *node,
+				   bool findmsi)
 {
 	struct irq_domain *h, *found = NULL;
 	int rc;
@@ -212,6 +216,9 @@ struct irq_domain *irq_find_host(struct device_node *node)
 	 */
 	mutex_lock(&irq_domain_mutex);
 	list_for_each_entry(h, &irq_domain_list, link) {
+		if ((findmsi && !h->msi_chip) ||
+		    (!findmsi && h->msi_chip))
+			continue;
 		if (h->ops->match)
 			rc = h->ops->match(h, node);
 		else
@@ -225,7 +232,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_host);
 
 /**
  * irq_set_default_host() - Set a "default" irq domain
-- 
1.8.1.2


  parent reply	other threads:[~2013-08-01 13:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01 13:25 [PATCHv6 00/13] MSI support for Marvell EBU PCIe driver Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 01/13] PCI: use weak functions for MSI arch-specific functions Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 02/13] PCI: remove ARCH_SUPPORTS_MSI kconfig option Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 03/13] PCI: Introduce new MSI chip infrastructure Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 04/13] irqdomain: add irq_alloc_mapping() function Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 05/13] irqdomain: refactor __irq_domain_add() Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 06/13] irqdomain: add support to associate an irq_domain with a msi_chip Thomas Petazzoni
2013-08-01 13:25 ` Thomas Petazzoni [this message]
2013-08-01 13:25 ` [PATCHv6 08/13] irqchip: armada-370-xp: properly request resources Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 09/13] irqchip: armada-370-xp: implement MSI support Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 10/13] ARM: pci: add ->add_bus() and ->remove_bus() hooks to hw_pci Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 11/13] ARM: mvebu: the MPIC now provides MSI controller features Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 12/13] PCI: mvebu: add support for MSI Thomas Petazzoni
2013-08-01 13:25 ` [PATCHv6 13/13] ARM: mvebu: link PCIe controllers to the MSI controller Thomas Petazzoni
2013-08-01 16:08 ` [PATCHv6 00/13] MSI support for Marvell EBU PCIe driver Stephen Warren
2013-08-01 16:14   ` Thomas Petazzoni
2013-08-01 16:50 ` Bjorn Helgaas
2013-08-01 17:58   ` Thomas Petazzoni
2013-08-06 18:10 ` Thomas Petazzoni
2013-08-06 22:39   ` Benjamin Herrenschmidt
2013-08-07  9:03     ` Thomas Petazzoni
2013-09-18 20:23     ` Grant Likely
2013-08-06 20:02 ` Jason Cooper
2013-08-06 20:08   ` Stephen Warren
2013-08-07 15:51     ` Jason Cooper
2013-08-07  6:59   ` Thierry Reding
2013-08-07 15:55     ` Jason Cooper

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=1375363516-2620-8-git-send-email-thomas.petazzoni@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=alior@marvell.com \
    --cc=andrew@lunn.ch \
    --cc=bhelgaas@google.com \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=grant.likely@secretlab.ca \
    --cc=gregory.clement@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=maen@marvell.com \
    --cc=rob.herring@calxeda.com \
    --cc=tglx@linutronix.de \
    --cc=thierry.reding@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).