From patchwork Mon Jun 17 08:35:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 10998537 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 188991575 for ; Mon, 17 Jun 2019 08:35:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09BDA28820 for ; Mon, 17 Jun 2019 08:35:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2B892880D; Mon, 17 Jun 2019 08:35:40 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 5292628820 for ; Mon, 17 Jun 2019 08:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727554AbfFQIfi (ORCPT ); Mon, 17 Jun 2019 04:35:38 -0400 Received: from gate.crashing.org ([63.228.1.57]:42189 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725837AbfFQIfh (ORCPT ); Mon, 17 Jun 2019 04:35:37 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x5H8ZH30015805; Mon, 17 Jun 2019 03:35:18 -0500 Message-ID: Subject: IORESOURCE_PCI_FIXES & __pci_bus_assign_resources() From: Benjamin Herrenschmidt To: linux-pci Cc: Bjorn Helgaas , Richard Henderson , Matt Turner Date: Mon, 17 Jun 2019 18:35:16 +1000 X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 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 Hi ! While working on consolidating resource assignment, I stumbled upon something alpha does (and maybe others I haven't spotted yet): On most platforms (not all), it uses the usual pair: pci_bus_size_bridges(bus); pci_bus_assign_resources(bus); to reassign everything. However, before doing so, it first calls pcibios_claim_one_bus() which, on those platforms (ie those who don't set PCI_PROBE_ONLY), will effectively claim only resources that have IORESOURCE_PCI_FIXED. Now, let's leave alone for now the fact that this is will really only work if those resources aren't behind a bridge as, to the best of my undertanding of the code at this point, we aren't going to take them into account when sizing & locating bridges. But that's not my point right now :-) From what I can tell, these days, pci_bus_assign_resources() will already claim those fixed resources via pdev_assign_fixed_resources(). However, it does so *after* it has assigned and claimed resoures for all the sibling devices on that bus. That looks wrong to me. Shouldn't we claim the fixed resources first ? IE something like: ? Now, I suspect most of the time it happens to work due to the fact that the fixed resources are generally IO resources in the legacy low ranges ( < 0x1000) and PCIBIOS_MIN_IO is *generally* set to 0x1000 but it still sounds fishy to me. I don't think I have HW at hand with that type of fixed stuff to test with at the moment, so this is very much academic right now but I worry that when I convert archs such as alpha who does that claiming before the rest of the assignment, switching doing things the other way around will break. Any thoughts ? Cheers, Ben. --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1345,11 +1345,12 @@ void __pci_bus_assign_resources(const struct pci_bus *bus, struct pci_bus *b; struct pci_dev *dev; + list_for_each_entry(dev, &bus->devices, bus_list) + pdev_assign_fixed_resources(dev); + pbus_assign_resources_sorted(bus, realloc_head, fail_head); list_for_each_entry(dev, &bus->devices, bus_list) { - pdev_assign_fixed_resources(dev); - b = dev->subordinate; if (!b) continue;