From patchwork Wed Jun 8 11:04:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 9164291 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 B43F360572 for ; Wed, 8 Jun 2016 11:04:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A57D32521F for ; Wed, 8 Jun 2016 11:04:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A58F262AE; Wed, 8 Jun 2016 11:04:46 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 A37092521F for ; Wed, 8 Jun 2016 11:04:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424889AbcFHLEj (ORCPT ); Wed, 8 Jun 2016 07:04:39 -0400 Received: from foss.arm.com ([217.140.101.70]:52402 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424888AbcFHLEh (ORCPT ); Wed, 8 Jun 2016 07:04:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 13C273B0; Wed, 8 Jun 2016 04:05:12 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.203.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 496D53F253; Wed, 8 Jun 2016 04:04:35 -0700 (PDT) From: Lorenzo Pieralisi To: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Lorenzo Pieralisi , Arnd Bergmann , David Daney , Will Deacon , Bjorn Helgaas , Yinghai Lu , Catalin Marinas , Russell King Subject: [PATCH v3 2/4] PCI: host-generic: claim bus resources on PCI_PROBE_ONLY set-ups Date: Wed, 8 Jun 2016 12:04:48 +0100 Message-Id: <1465383890-13538-3-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1465383890-13538-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1465383890-13538-1-git-send-email-lorenzo.pieralisi@arm.com> 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 The PCI host generic driver does not reassign bus resources on systems that require the BARs set-up to be immutable (ie PCI_PROBE_ONLY) since that would trigger system failures. Nonetheless, PCI bus resources allocated to PCI bridge and devices must be claimed in order to be validated and inserted in the kernel resource tree, but the current driver omits the resources claiming and relies on arch specific kludges to prevent probing failure (ie preventing resources enablement on PCI_PROBE_ONLY systems). Add code to the PCI host generic driver that correctly claims bus resources upon probe on systems that are required to prevent reassignment after bus enumeration, so that the allocated resources can be enabled successfully upon PCI device drivers probing, without resorting to arch back-ends workarounds. Signed-off-by: Lorenzo Pieralisi Acked-by: Will Deacon Cc: Arnd Bergmann Cc: David Daney Cc: Will Deacon Cc: Bjorn Helgaas --- drivers/pci/host/pci-host-common.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pci-host-common.c b/drivers/pci/host/pci-host-common.c index 8cba7ab..1684882 100644 --- a/drivers/pci/host/pci-host-common.c +++ b/drivers/pci/host/pci-host-common.c @@ -154,8 +154,31 @@ int pci_host_common_probe(struct platform_device *pdev, } pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); - - if (!pci_has_flag(PCI_PROBE_ONLY)) { + /* + * For PCI bridges and PCI devices to be fully set-up, their + * resources must be initialized and inserted in the kernel + * resource tree, which implicitly means that the resources + * are correctly inserted in the kernel resource tree and are + * assigned a parent pointer to create the resource hierarchy. + * + * On PCI_PROBE_ONLY systems, the pci_bus_claim_resource() + * API claims the resources as set-up by firmware, which takes + * care of inserting them in the resource tree and setting their + * parent pointers accordingly. + * + * On !PCI_PROBE_ONLY systems, the firmware set-up is discarded, + * and resource assignment and insertion in the resource tree is + * carried out through the PCI resources API: + * + * (ie pci_bus_size_bridges() and pci_bus_assign_resources()) + * + * that sizes the bridges and assigns and inserts resources in the + * kernel resource tree (which also implies setting up their parent + * pointers), completing the resources set-up. + */ + if (pci_has_flag(PCI_PROBE_ONLY)) { + pci_bus_claim_resources(bus); + } else { pci_bus_size_bridges(bus); pci_bus_assign_resources(bus);