From patchwork Tue Jun 19 14:16:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10474625 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.web.codeaurora.org (Postfix) with ESMTP id CBE6460383 for ; Tue, 19 Jun 2018 14:17:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B977C2860B for ; Tue, 19 Jun 2018 14:17:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADD6328C13; Tue, 19 Jun 2018 14:17:14 +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 5395B2860B for ; Tue, 19 Jun 2018 14:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937733AbeFSORN (ORCPT ); Tue, 19 Jun 2018 10:17:13 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:50832 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937635AbeFSORM (ORCPT ); Tue, 19 Jun 2018 10:17:12 -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=0m3s9cERDNIWZ8rQ7S7xuddWSDH9wy3yavLJQyb41os=; b=Ew2SjN98oLGYVeeraQ/0OPBWr wcsxbXxhVgy0ocE+xNcF12Yz/C4QiJEIeCoeTXeCR1lfptb+54qcQaZ8/KszdLZsD48N/DsVt7zdY +YAaLCZh6sxpezXKVynU8SIXhyWL7yIqG2AIHGhpKpoFxLSf1ojWqh0TUrMEO3SD4xYFTYeVLmVxz 2KLdyZntSexLOHzdnCvx7ZJ1G4mMpOqNdG4v+NkUg+NVmGQNyXs8Dvsc/aaUHPpWtr3UcCGAPtCdr mRMWrbOyvL+hmwlSHn8jikQpm1KaSlJFYe/PMyU+LChB5L26K+0qHeeHP+0jYqjcD89bH9iCxbpH/ XvD3bJvgQ==; Received: from 089144192009.atnat0001.highway.a1.net ([89.144.192.9] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVHRU-0001PX-QQ; Tue, 19 Jun 2018 14:17:09 +0000 From: Christoph Hellwig To: Lorenzo Pieralisi , Bjorn Helgaas Cc: Palmer Dabbelt , "Wesley W . Terpstra" , linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH 1/3] PCI: Add hooks for bus/bridge-specific fixups Date: Tue, 19 Jun 2018 16:16:58 +0200 Message-Id: <20180619141700.7842-2-hch@lst.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619141700.7842-1-hch@lst.de> References: <20180619141700.7842-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 From: "Wesley W. Terpstra" 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 at "add_dev" hook to pci_ops that allows the PCI infastructure to interpose when adding a device, which in the case of the Xilinx driver will be used to restrict the address ranges used for DMA. Signed-off-by: Wesley W. Terpstra [hch: simplified the prototype] Signed-off-by: Christoph Hellwig --- drivers/pci/probe.c | 3 +++ include/linux/pci.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ac876e32de4b..978e684cba2c 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2331,6 +2331,9 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) /* Set up MSI IRQ domain */ pci_set_msi_domain(dev); + if (bus->ops->add_dev) + bus->ops->add_dev(dev, bus); + /* 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 340029b2fb38..ea9609fc44fc 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -662,6 +662,7 @@ static inline int pcibios_err_to_errno(int err) struct pci_ops { int (*add_bus)(struct pci_bus *bus); void (*remove_bus)(struct pci_bus *bus); + void (*add_dev)(struct pci_dev *dev, struct pci_bus *bus); void __iomem *(*map_bus)(struct pci_bus *bus, unsigned int devfn, int where); int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val); int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);