From patchwork Wed Sep 30 22:47:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 7303181 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 70FDCBEEA4 for ; Wed, 30 Sep 2015 22:49:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 89F5A20718 for ; Wed, 30 Sep 2015 22:49:22 +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 573DB20723 for ; Wed, 30 Sep 2015 22:49:21 +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 1ZhQAA-00025d-GH; Wed, 30 Sep 2015 22:47:50 +0000 Received: from mail-ig0-x22b.google.com ([2607:f8b0:4001:c05::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhQ9s-0001uU-QF for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2015 22:47:33 +0000 Received: by igxx6 with SMTP id x6so2341978igx.1 for ; Wed, 30 Sep 2015 15:47:12 -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=86itMYNIz2X9ObQ+TdXdIDD6BVQzOTch/ZIv9Sy3jdE=; b=J+HB2Hw9DrZhRbKRgk1AUi3+m4dL45vNuZWMRfRHnfYb0SbXeRN3IYaFHXRTJBeQ7i PEsYbVdeJY2C4vY6wK1xsH/7dchRMuQgJ0jtr6/eHaxUewUBCH9bbFco/knThMdIjc40 ad6DTrtw29IYKuI2hUGXpE2VmgqmaP4BDtWpSKsamEMzzepdZVG+/hfMmdEcwSi1ornS tXt53DJaxLuqpYbSw6rp+7aBZOIfBY75dud5mkrkq/j6jqg8MoloT9FDEPaCk0NOfzJ5 grksZrNVsqsANghV0Mx1ph/d1xVBL/El2n02SCm1Dh7tOCRle6497uXgvWoZIYgRygrC ONrg== X-Received: by 10.50.73.8 with SMTP id h8mr20135555igv.94.1443653232053; Wed, 30 Sep 2015 15:47:12 -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 g2sm1302677igi.15.2015.09.30.15.47.08 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 30 Sep 2015 15:47:08 -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 t8UMl7a1024974; Wed, 30 Sep 2015 15:47:07 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id t8UMl6AJ024973; Wed, 30 Sep 2015 15:47:06 -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 v3 3/4] PCI/MSI: Add helper function pci_msi_domain_get_msi_rid(). Date: Wed, 30 Sep 2015 15:47:01 -0700 Message-Id: <1443653222-24924-4-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1443653222-24924-1-git-send-email-ddaney.cavm@gmail.com> References: <1443653222-24924-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150930_154733_069970_375B8F24 X-CRM114-Status: GOOD ( 14.74 ) 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 --- drivers/pci/msi.c | 31 +++++++++++++++++++++++++++++++ include/linux/msi.h | 1 + 2 files changed, 32 insertions(+) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index d449714..92b6dc9 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,34 @@ struct irq_domain *pci_msi_create_default_irq_domain(struct device_node *node, return domain; } + +struct get_mis_id_data { + u32 alias; +}; + +static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data) +{ + struct get_mis_id_data *s = data; + + s->alias = 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) +{ + struct get_mis_id_data d; + + d.alias = 0; + pci_for_each_dma_alias(pdev, get_msi_id_cb, &d); + return of_msi_map_rid(&pdev->dev, domain->of_node, d.alias); +} #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 */