From patchwork Fri Oct 2 00:50:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 7312381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 02BA0BEEA4 for ; Fri, 2 Oct 2015 00:53:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22D70207B6 for ; Fri, 2 Oct 2015 00:53:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 88252207C5 for ; Fri, 2 Oct 2015 00:53:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhoZR-0007MQ-Nn; Fri, 02 Oct 2015 00:51:33 +0000 Received: from mail-io0-x22b.google.com ([2607:f8b0:4001:c06::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhoYu-00073K-Ip for linux-arm-kernel@lists.infradead.org; Fri, 02 Oct 2015 00:51:01 +0000 Received: by iow1 with SMTP id 1so67755103iow.1 for ; Thu, 01 Oct 2015 17:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+DBh6jSkJ/Sk28CJEc2AVUyicl7SObTqJTlvMiTaqa4=; b=OqXkS6D8/p9CkZWi3zt/H3QFCbZV1IHawZ/04xU5FPQ1IviC+FU7YFW7rDoXywuixG 2RbDyGl1J2FdDmbjy/ToFgTOYDj2xmOT2BKkD5VlgXo1Bd/P7RkHNqRhbCiwByhYyzwC NRxZXGaJEs5vozjCBS4vcYpeMd/i4AjhA7NLBd/jYDRl0R+eeu9EjGeQt1SYX079c8kL TWY6ncJJSR3bgPhE2czkGsPlwBBEOyLg1mUlwkJS/RhlPEi+1p2qcyw62GuzL1rwye8r c5LPH7vLubXQ/eq91g2FCYFxabNCtd0VcjdinWWGNeSG/LJbwFGhNwyExu9nG1PsABRY UZSA== X-Received: by 10.107.7.41 with SMTP id 41mr15544832ioh.48.1443747039760; Thu, 01 Oct 2015 17:50:39 -0700 (PDT) Received: from dl.caveonetworks.com (64.2.3.194.ptr.us.xo.net. [64.2.3.194]) by smtp.gmail.com with ESMTPSA id e13sm3963735ioi.1.2015.10.01.17.50.35 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 01 Oct 2015 17:50:37 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id t920oYbK009968; Thu, 1 Oct 2015 17:50:34 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id t920oYsT009967; Thu, 1 Oct 2015 17:50:34 -0700 From: David Daney To: linux-kernel@vger.kernel.org, Will Deacon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Marc Zyngier , Grant Likely , Thomas Gleixner , Jason Cooper , Frank Rowand , Bjorn Helgaas , linux-pci@vger.kernel.org Subject: [PATCH v4 3/4] PCI/MSI: Add helper function pci_msi_domain_get_msi_rid(). Date: Thu, 1 Oct 2015 17:50:24 -0700 Message-Id: <1443747025-9918-4-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1443747025-9918-1-git-send-email-ddaney.cavm@gmail.com> References: <1443747025-9918-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151001_175100_802882_A5E0D30D X-CRM114-Status: GOOD ( 15.15 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Daney MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 From: David Daney Add pci_msi_domain_get_msi_rid() to return the MSI requester id (RID). Initially needed by gic-v3 based systems. It will be used by follow on patch to drivers/irqchip/irq-gic-v3-its-pci-msi.c Initially supports mapping the RID via OF device tree. In the future, this could be extended to use ACPI _IORT tables as well. Signed-off-by: David Daney Reviewed-by: Marc Zyngier --- drivers/pci/msi.c | 30 ++++++++++++++++++++++++++++++ include/linux/msi.h | 1 + 2 files changed, 31 insertions(+) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index d449714..81a2798 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "pci.h" @@ -1327,4 +1328,33 @@ struct irq_domain *pci_msi_create_default_irq_domain(struct device_node *node, return domain; } + +static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data) +{ + u32 *pa = data; + + *pa = alias; + return 0; +} +/** + * pci_msi_domain_get_msi_rid - Get the MSI requester id (RID) + * @domain: The interrupt domain + * @pdev: The PCI device. + * + * The RID for a device is formed from the alias, with a firmware + * supplied mapping applied + * + * Returns: The RID. + */ +u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev) +{ + u32 rid = 0; + + pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); + + if (domain->of_node) + rid = of_msi_map_rid(&pdev->dev, domain->of_node, rid); + + return rid; +} #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */ diff --git a/include/linux/msi.h b/include/linux/msi.h index ad939d0..56e3b76 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -293,6 +293,7 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev, struct msi_desc *desc); int pci_msi_domain_check_cap(struct irq_domain *domain, struct msi_domain_info *info, struct device *dev); +u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev); #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */ #endif /* LINUX_MSI_H */