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: 7312311 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 260F1BEEA4 for ; Fri, 2 Oct 2015 00:51:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A68D204E0 for ; Fri, 2 Oct 2015 00:51:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73AE620451 for ; Fri, 2 Oct 2015 00:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750803AbbJBAum (ORCPT ); Thu, 1 Oct 2015 20:50:42 -0400 Received: from mail-io0-f181.google.com ([209.85.223.181]:32938 "EHLO mail-io0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407AbbJBAuk (ORCPT ); Thu, 1 Oct 2015 20:50:40 -0400 Received: by iofh134 with SMTP id h134so105225978iof.0; 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 Cc: David Daney 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> 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 */