From patchwork Tue Oct 6 17:04:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 7337831 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5BA1E9F1D5 for ; Tue, 6 Oct 2015 17:04:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B4F720776 for ; Tue, 6 Oct 2015 17:04:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D474120788 for ; Tue, 6 Oct 2015 17:04:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753490AbbJFREi (ORCPT ); Tue, 6 Oct 2015 13:04:38 -0400 Received: from foss.arm.com ([217.140.101.70]:53552 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753327AbbJFREh (ORCPT ); Tue, 6 Oct 2015 13:04:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3501C5DD; Tue, 6 Oct 2015 10:04:37 -0700 (PDT) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.209.125]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4EAD43F487; Tue, 6 Oct 2015 10:04:35 -0700 (PDT) From: Marc Zyngier To: Rob Herring , Jason Cooper , Thomas Gleixner , Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, Mark Rutland , David Daney , Robin Murphy Subject: [PATCH v2 6/8] of/irq: Use the msi-map property to provide device-specific MSI domain Date: Tue, 6 Oct 2015 18:04:01 +0100 Message-Id: <1444151043-31084-7-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444151043-31084-1-git-send-email-marc.zyngier@arm.com> References: <1444151043-31084-1-git-send-email-marc.zyngier@arm.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While msi-parent is used to point to the MSI controller that works for all the devices behind a root complex, it doesn't allow configurations where each individual device can be routed to a separate MSI controller. The msi-map property provides this flexibility (and much more), so let's add a utility function that parses it, and return the corresponding MSI domain. Signed-off-by: Marc Zyngier --- drivers/of/irq.c | 18 ++++++++++++++++++ include/linux/of_irq.h | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index ed64d98..0baf626d 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -689,6 +689,24 @@ static struct irq_domain *__of_get_msi_domain(struct device_node *np, } /** + * of_msi_map_get_device_domain - Use msi-map to find the relevant MSI domain + * @dev: device for which the mapping is to be done. + * @rid: Requester ID for the device. + * + * Walk up the device hierarchy looking for devices with a "msi-map" + * property. + * + * Returns: the MSI domain for this device (or NULL on failure) + */ +struct irq_domain *of_msi_map_get_device_domain(struct device *dev, u32 rid) +{ + struct device_node *np = NULL; + + __of_msi_map_rid(dev, &np, rid); + return __of_get_msi_domain(np, DOMAIN_BUS_PCI_MSI); +} + +/** * 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 diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index 62ae6ed..65d9692 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -49,6 +49,8 @@ extern int of_irq_to_resource_table(struct device_node *dev, extern struct irq_domain *of_msi_get_domain(struct device *dev, struct device_node *np, enum irq_domain_bus_token token); +extern struct irq_domain *of_msi_map_get_device_domain(struct device *dev, + u32 rid); #else static inline int of_irq_count(struct device_node *dev) { @@ -73,6 +75,11 @@ static inline struct irq_domain *of_msi_get_domain(struct device *dev, { return NULL; } +static inline struct irq_domain *of_msi_map_get_device_domain(struct device *dev, + u32 rid) +{ + return NULL; +} #endif #if defined(CONFIG_OF)