From patchwork Thu Oct 8 22:10:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 7356781 Return-Path: X-Original-To: patchwork-linux-arm@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 DC7769F1B9 for ; Thu, 8 Oct 2015 22:13:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 01FEB207B3 for ; Thu, 8 Oct 2015 22:13:36 +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 2D994207B1 for ; Thu, 8 Oct 2015 22:13:35 +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 1ZkJPq-0005eZ-GK; Thu, 08 Oct 2015 22:11:58 +0000 Received: from mail-io0-x22d.google.com ([2607:f8b0:4001:c06::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZkJPF-0005Kw-L1 for linux-arm-kernel@lists.infradead.org; Thu, 08 Oct 2015 22:11:23 +0000 Received: by iofh134 with SMTP id h134so73902692iof.0 for ; Thu, 08 Oct 2015 15:11:01 -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=wMfu2QQIaLc3GkT1vtm2oWBKD+nA27wXFAypOiIOug4=; b=Ds1U+KXHcBgR1VufjMHrzANjM9F4gtjpnfDtkrLu+mbQ9JlQGAdVYBBC30e5kC2p4n t8+OBMhfooSX42FtArh7Fkb2yzJjA4BvbYjrL2bcsa1ep1iCRd8ee3B/VmXkKB47xocn SBVFO5cTdUYSKNu0vS+w6m4W496kIaQY9h5r79BU/GoscqpG/KEvQCTdGP+oBpuUj3Ac V+ejx2B7GSqBW0YVMnbV5pdoBBT+tUlhxj0+uJElct1zXCH3o6xeONG2pLi8U+V0jUWD PkiokU6U6Xt+kNTwBTjjjCgUnIvnavBINnDCexsLXN6q8V6/Th5XMeLV8rC2SOVLajEQ Sa7A== X-Received: by 10.107.130.217 with SMTP id m86mr13442434ioi.22.1444342260950; Thu, 08 Oct 2015 15:11:00 -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 y186sm154965iod.18.2015.10.08.15.10.55 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 08 Oct 2015 15:10:58 -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 t98MAsxS006246; Thu, 8 Oct 2015 15:10:54 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id t98MAsUh006245; Thu, 8 Oct 2015 15:10:54 -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 v5 3/4] PCI/MSI: Add helper function pci_msi_domain_get_msi_rid(). Date: Thu, 8 Oct 2015 15:10:49 -0700 Message-Id: <1444342250-6196-4-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1444342250-6196-1-git-send-email-ddaney.cavm@gmail.com> References: <1444342250-6196-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151008_151121_890232_02859294 X-CRM114-Status: GOOD ( 15.17 ) 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. Reviewed-by: Marc Zyngier Signed-off-by: David Daney Acked-by: Bjorn Helgaas --- 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 */