From patchwork Thu Aug 1 13:25:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 2837001 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 301F6C0319 for ; Thu, 1 Aug 2013 13:25:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 83A83202BC for ; Thu, 1 Aug 2013 13:25:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52828202B7 for ; Thu, 1 Aug 2013 13:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754860Ab3HANZa (ORCPT ); Thu, 1 Aug 2013 09:25:30 -0400 Received: from up.free-electrons.com ([94.23.35.102]:53503 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754381Ab3HANZ3 (ORCPT ); Thu, 1 Aug 2013 09:25:29 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id 40B1D1218; Thu, 1 Aug 2013 15:25:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id 8F2137A4; Thu, 1 Aug 2013 15:25:27 +0200 (CEST) From: Thomas Petazzoni To: Bjorn Helgaas , linux-pci@vger.kernel.org, Russell King , Grant Likely , Rob Herring , Thomas Gleixner , Jason Cooper , Andrew Lunn , Gregory Clement Cc: Ezequiel Garcia , linux-arm-kernel@lists.infradead.org, Maen Suleiman , Lior Amsalem , Thierry Reding Subject: [PATCHv6 07/13] irqdomain: add function to find a MSI irq_domain Date: Thu, 1 Aug 2013 15:25:10 +0200 Message-Id: <1375363516-2620-8-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1375363516-2620-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1375363516-2620-1-git-send-email-thomas.petazzoni@free-electrons.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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