Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932195AbcDHARK (ORCPT ); Thu, 7 Apr 2016 20:17:10 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:35043 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756848AbcDHARB (ORCPT ); Thu, 7 Apr 2016 20:17:01 -0400 From: Yinghai Lu To: Bjorn Helgaas , David Miller , Benjamin Herrenschmidt , Linus Torvalds Cc: Wei Yang , TJ , Yijing Wang , Khalid Aziz , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH v11 09/60] powerpc/PCI: Keep resource idx order with bridge register number Date: Thu, 7 Apr 2016 17:15:22 -0700 Message-Id: <1460074573-7481-10-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1460074573-7481-1-git-send-email-yinghai@kernel.org> References: <1460074573-7481-1-git-send-email-yinghai@kernel.org> X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1403 Lines: 41 Same as sparc version. Make resource with consistent sequence like other arch or directly from pci_read_bridge_bases(), even when non-pref mmio is missing, or out of ordering in firmware reporting. Just hold i = 1 for non pref mmio, and i = 2 for pref mmio. Signed-off-by: Yinghai Lu --- arch/powerpc/kernel/pci_of_scan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index 526ac67..719f225 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c @@ -252,7 +252,7 @@ void of_scan_pci_bridge(struct pci_dev *dev) bus->resource[i] = res; ++res; } - i = 1; + i = 3; for (; len >= 32; len -= 32, ranges += 8) { flags = pci_parse_of_flags(of_read_number(ranges, 1), 1); size = of_read_number(&ranges[6], 2); @@ -265,6 +265,12 @@ void of_scan_pci_bridge(struct pci_dev *dev) " for bridge %s\n", node->full_name); continue; } + } else if ((flags & IORESOURCE_PREFETCH) && + !bus->resource[2]->flags) { + res = bus->resource[2]; + } else if (((flags & (IORESOURCE_MEM | IORESOURCE_PREFETCH)) == + IORESOURCE_MEM) && !bus->resource[1]->flags) { + res = bus->resource[1]; } else { if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) { printk(KERN_ERR "PCI: too many memory ranges" -- 1.8.4.5