From patchwork Sat Aug 4 10:14:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10555657 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D4791822 for ; Sat, 4 Aug 2018 10:14:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25B252A14E for ; Sat, 4 Aug 2018 10:14:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A88F2A152; Sat, 4 Aug 2018 10:14:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7CC82A14F for ; Sat, 4 Aug 2018 10:14:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727350AbeHDMO0 (ORCPT ); Sat, 4 Aug 2018 08:14:26 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58502 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHDMO0 (ORCPT ); Sat, 4 Aug 2018 08:14:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=21I9FRcNAcLoA7xUcULIhM2a3ght92JDLMM2QVb336c=; b=J3em0ovfo+dzOpQcz7R7RbYso XQ3yeL/maeo7txWEEW1/9LaLKE/rVXZe1T9K/ifvEhbjqePbnHCf9dn6/KvTAjPa6TE5PbpeYoqTK z13zwQytT5Ib8AzRZH8d5XxDUkcMWedCsplAHP9j9hI8c0OjMlRhQbdLtDurV3bISPKPAJp1qk+vE C3J54RJeY4pJpCvjlzL+Wlv6je9jdw5SVzGHdQKNbCLUQGIhu2SncVWETi9QdML61unefmdHAUkO3 lpXKcKvINfy+4F03N3gSftu19IV4bts6PMvb4FYPGkfPSpl8KFiQBLlNy/SR2v/+9VyVU49aS1SGM 9tJwdi9QQ==; Received: from [46.125.249.69] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fltZa-0000Ll-Ci; Sat, 04 Aug 2018 10:14:10 +0000 From: Christoph Hellwig To: Lorenzo Pieralisi , Bjorn Helgaas Cc: Palmer Dabbelt , "Wesley W . Terpstra" , Arnd Bergmann , linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH 1/3] PCI: add a callback to struct pci_host_bridge for adding a new device Date: Sat, 4 Aug 2018 12:14:00 +0200 Message-Id: <20180804101402.10022-2-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180804101402.10022-1-hch@lst.de> References: <20180804101402.10022-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is currently no way for a PCIe bridge to impose constraints on devices added to it. For example, the Xilinx PCIe host bridge only supports 32-bit physical addresses (due to a limitation on the AXI port's address width). Thus, even devices that claim to support 64-bit DMA addresses must be restricted to 32-bit addresses when attached to this host controller. This patch adds a "add_device" method to struct pci_host_bridge that allows the host driver to act upon acting adding devices. Based on an earlier patch from Wesley W. Terpstra . Signed-off-by: Christoph Hellwig Acked-by: Lorenzo Pieralisi --- drivers/pci/probe.c | 6 ++++++ include/linux/pci.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ac876e32de4b..452190fb05e7 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2290,6 +2290,7 @@ static void pci_set_msi_domain(struct pci_dev *dev) void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) { + struct pci_host_bridge *host = pci_find_host_bridge(bus); int ret; pci_configure_device(dev); @@ -2328,6 +2329,11 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) ret = pcibios_add_device(dev); WARN_ON(ret < 0); + if (host->add_device) { + ret = host->add_device(dev); + WARN_ON(ret < 0); + } + /* Set up MSI IRQ domain */ pci_set_msi_domain(dev); diff --git a/include/linux/pci.h b/include/linux/pci.h index abd5d5e17aee..1524adbb30ab 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -485,6 +485,7 @@ struct pci_host_bridge { resource_size_t start, resource_size_t size, resource_size_t align); + int (*add_device)(struct pci_dev *dev); unsigned long private[0] ____cacheline_aligned; }; From patchwork Sat Aug 4 10:14:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10555659 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1EE9C15A6 for ; Sat, 4 Aug 2018 10:14:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 175F02A14E for ; Sat, 4 Aug 2018 10:14:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B98E2A152; Sat, 4 Aug 2018 10:14:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE1B02A14E for ; Sat, 4 Aug 2018 10:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727445AbeHDMO3 (ORCPT ); Sat, 4 Aug 2018 08:14:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58596 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHDMO3 (ORCPT ); Sat, 4 Aug 2018 08:14:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rrxMRGF3UYQv4miiHWfgGgZ7en8kVcEfCnnY62RSXwI=; b=c/wFVzt7V+wIOY+oWvA2P3ZkR L52lsenQKa856hKZ/6qUbtNDUhrf99ZgGbOvXpYEyRLnYO3gwdVU4ttaq8xyYjBLDBn1lvzEQyJ0T tRjNpgHZM8Z+r3ZGhvOxaO8FfrsSGwo4TpohRBoEXc6W3d7/suT4BvJFGO6V1LtF+XDTPuVgYJTYD PfphZ7FjLlzn0V3czWqpTSxCfgU1CTdNz5MIRsuOLgXZn6S6OQoPNQ+rkpHJTjZmP2t1IupmnLLr2 0MR5ZgC+hIlwrjppNdZUTP0yHGUMspuA5UcTvSjZ4yz1EU4YOQJOjRtnRYGDGQ3eixTxk9bMz8kE9 TlBWzjfuw==; Received: from [46.125.249.69] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fltZd-0000Ml-TK; Sat, 04 Aug 2018 10:14:14 +0000 From: Christoph Hellwig To: Lorenzo Pieralisi , Bjorn Helgaas Cc: Palmer Dabbelt , "Wesley W . Terpstra" , Arnd Bergmann , linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH 2/3] PCI/xilinx: Work-around for hardware DMA limit (32 bits) Date: Sat, 4 Aug 2018 12:14:01 +0200 Message-Id: <20180804101402.10022-3-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180804101402.10022-1-hch@lst.de> References: <20180804101402.10022-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This PCIe bridge only has a 32 bit bus master interface, thus truncating the DMA capability of all PCIe devices attached beneath it. This caps the child device capability so that these devices work on systems with physical memory beyond the 4GiB threshold. Based on an earlier patch from Wesley W. Terpstra . Signed-off-by: Christoph Hellwig --- drivers/pci/controller/pcie-xilinx.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c index 7b1389d8e2a5..ccfd91e0515f 100644 --- a/drivers/pci/controller/pcie-xilinx.c +++ b/drivers/pci/controller/pcie-xilinx.c @@ -197,6 +197,16 @@ static void __iomem *xilinx_pcie_map_bus(struct pci_bus *bus, return port->reg_base + relbus + where; } +/* + * This PCIe bridge only has a 32 bit bus master interface, thus truncating + * the DMA capability of all PCIe devices attached beneath it. + */ +static int xilinx_pcie_add_device(struct pci_dev *pdev) +{ + pdev->dev.bus_dma_mask = DMA_BIT_MASK(32); + return 0; +} + /* PCIe operations */ static struct pci_ops xilinx_pcie_ops = { .map_bus = xilinx_pcie_map_bus, @@ -665,6 +675,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev) bridge->ops = &xilinx_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle; + bridge->add_device = xilinx_pcie_add_device; #ifdef CONFIG_PCI_MSI xilinx_pcie_msi_chip.dev = dev; From patchwork Sat Aug 4 10:14:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10555661 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21D9815A6 for ; Sat, 4 Aug 2018 10:14:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 176D52A14F for ; Sat, 4 Aug 2018 10:14:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07AFF2A158; Sat, 4 Aug 2018 10:14:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0A2E2A14F for ; Sat, 4 Aug 2018 10:14:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727513AbeHDMOg (ORCPT ); Sat, 4 Aug 2018 08:14:36 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58774 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHDMOg (ORCPT ); Sat, 4 Aug 2018 08:14:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8Qd+GUpUrkQvqm0B7dhybBl5bzen+7pDFPiyHX6HQWc=; b=iszpsb8XrRhLWahHVI/uAv7Ls txkbzVRZRBiKtIPeqRfyqbxb5aUiYzZ0YidMv/N8bT07rYjRAljkijCzoJJIruO7gcpq3gWZ7ZtbB u50F+LdFXzHCoC9Q8f5vP4hPDaRFfgI+iL6e0nf0kLPxhKmyKzC9KQ4Im4vOWMY8WC05H40wxJbgb sIwpcps42ei2amH1vrERt8X9t72vk/c+n0lmofgeZFN8AoZk7/lIiNlrD3mttMJEbEtNgqLly2Z9z /QxfBB2RzlI63dZRB3Pq/TiR7tfUR40JS57dcmhovTAi15s53fBBBTmerTVGnTrAUqLnkhHkrU0yg 1wrelmjJw==; Received: from [46.125.249.69] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fltZh-0000P1-C4; Sat, 04 Aug 2018 10:14:18 +0000 From: Christoph Hellwig To: Lorenzo Pieralisi , Bjorn Helgaas Cc: Palmer Dabbelt , "Wesley W . Terpstra" , Arnd Bergmann , linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH 3/3] PCI/xilinx: Depend on OF instead of the ARCH Date: Sat, 4 Aug 2018 12:14:02 +0200 Message-Id: <20180804101402.10022-4-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180804101402.10022-1-hch@lst.de> References: <20180804101402.10022-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There isn't a hard dependency of the Xilinx AXI-PCIe host bridge on any architecture. For example: at SiFive we map RISC-V cores to Xilinx FPGAs and connect the Xilinx IP via a TileLink adapter, so the RISC-V Linux port will need to be able to enable PCIE_XILINX in order to have PCIe support. This patch decouples the PCIE_XILINX support from ARCH. Instead it just depends on OF, which I believe is the only true dependency. Signed-off-by: Palmer Dabbelt [hch: switch to OF instead of OF_PCI now that the latter is gone] Signed-off-by: Christoph Hellwig --- drivers/pci/controller/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig index cc9fa02d32a0..0f7ce5eaeac8 100644 --- a/drivers/pci/controller/Kconfig +++ b/drivers/pci/controller/Kconfig @@ -102,7 +102,7 @@ config PCI_HOST_GENERIC config PCIE_XILINX bool "Xilinx AXI PCIe host bridge support" - depends on ARCH_ZYNQ || MICROBLAZE || (MIPS && PCI_DRIVERS_GENERIC) || COMPILE_TEST + depends on OF || COMPILE_TEST help Say 'Y' here if you want kernel to support the Xilinx AXI PCIe Host Bridge driver.