From patchwork Wed Aug 1 15: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: 10552443 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 9C7C915E9 for ; Wed, 1 Aug 2018 15:14:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CEFD2B6FC for ; Wed, 1 Aug 2018 15:14:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 806B82B701; Wed, 1 Aug 2018 15:14:15 +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 76FCE2B6FC for ; Wed, 1 Aug 2018 15:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389614AbeHARAX (ORCPT ); Wed, 1 Aug 2018 13:00:23 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:50126 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389550AbeHARAX (ORCPT ); Wed, 1 Aug 2018 13:00:23 -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=efo+Mo9rUYWYg3QPOnWnKAqACktaGjxWvEUvK0JXba8=; b=KWA9UDq3aDZ/vgCQm6FOxS4k1 REpaSNL3a8SS5Zgd9SlvWvPzlDRi4rgrsdtMuWHrbRovwqxRaBwNwY9ZjYgkoe86xjzgwKH0LDSZn BBR8EJ2Lc+wrC6oHH7SvuY6K3X+H9Z1OsrGNP55vYcjbLJ6PEzf10s0TH2S0tyN0rGXQ7bkQSm53j KH0OLzlb0e9WwaqMeiAsiVrq9QS5IfdWHs6NKyMVX871yeyc8YLhYQN87PNw0VmdUryq+AaAVTcxH MfqsI+Wwyp/gZEidxqjGsyqKl1y1lXqVOOg84lwY2gMNlBF0pQ5BzJoIUxS0PYTU0fs1E77wO6Jsx drF8a1dUg==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fkspF-0004tu-88; Wed, 01 Aug 2018 15:14:09 +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: Wed, 1 Aug 2018 17:14:01 +0200 Message-Id: <20180801151403.20660-2-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801151403.20660-1-hch@lst.de> References: <20180801151403.20660-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_dev" 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: Bjorn Helgaas --- drivers/pci/probe.c | 4 ++++ include/linux/pci.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ac876e32de4b..8736d78ffc66 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); @@ -2331,6 +2332,9 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) /* Set up MSI IRQ domain */ pci_set_msi_domain(dev); + if (host->add_dev) + host->add_dev(dev); + /* Notifier could use PCI capabilities */ dev->match_driver = false; ret = device_add(&dev->dev); diff --git a/include/linux/pci.h b/include/linux/pci.h index abd5d5e17aee..5eedae8e8f2b 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); + void (*add_dev)(struct pci_dev *dev); unsigned long private[0] ____cacheline_aligned; };